Complete the code to declare the state register.
reg [1:0] [1]; // 2-bit state register
The state register is usually named state to hold the current FSM state.
Complete the code to define the state encoding for RED.
localparam RED = 2'b[1];
The RED state is encoded as 2'b00 in this FSM.
Fix the error in the always block sensitivity list.
always @([1]) begin if (reset) state <= RED; else state <= next_state; end
The sensitivity list must include the clock and asynchronous reset signals with posedge.
Fill both blanks to complete the next state logic for RED to GREEN transition.
always @(*) begin
case(state)
RED: if(timer [1] RED_TIME) next_state = [2]; else next_state = RED;
default: next_state = RED;
endcase
endThe FSM moves from RED to GREEN when the timer reaches or exceeds RED_TIME.
Fill all three blanks to complete the output logic for traffic lights.
always @(*) begin
case(state)
RED: begin
red_light = [1];
yellow_light = [2];
green_light = [3];
end
// other states omitted
endcase
endIn RED state, red_light is ON (1), yellow_light and green_light are OFF (0).
