Consider this simple FSM code snippet in Verilog. What will be the value of state after 3 clock cycles?
module fsm(input clk, input reset, output reg [1:0] state); parameter S0 = 2'b00, S1 = 2'b01, S2 = 2'b10; always @(posedge clk or posedge reset) begin if (reset) state <= S0; else begin case(state) S0: state <= S1; S1: state <= S2; S2: state <= S0; default: state <= S0; endcase end end endmodule
Trace the state changes on each clock rising edge starting from reset.
The FSM starts at S0 (00) after reset. On first clock, it moves to S1 (01), second clock to S2 (10), third clock back to S0 (00). After 3 clocks, the state is S0 (00).
Which option best explains why FSMs use clock signals to model sequential behavior?
Think about how FSMs move from one state to another in a controlled manner.
FSMs use clock signals to update their state only at specific times (clock edges). This synchronization ensures the FSM progresses through states in a predictable, step-by-step sequence.
Given this FSM Verilog code, what is the main reason the FSM does not transition states correctly?
module fsm(input clk, input reset, output reg [1:0] state); parameter S0 = 2'b00, S1 = 2'b01, S2 = 2'b10; always @(posedge clk or posedge reset) begin if (reset) state <= S0; else begin case(state) S0: state <= S1; S1: state <= S2; S2: state <= S0; endcase end end endmodule
Consider the difference between blocking and non-blocking assignments in sequential logic.
In sequential logic (inside always @(posedge clk)), non-blocking assignments (<=) must be used to ensure proper state updates. Using blocking assignments (=) can cause race conditions and incorrect behavior.
Choose the code snippet that correctly implements a Moore FSM with states S0 and S1, where output is based only on the current state.
Remember Moore FSM outputs depend only on state, not inputs or transitions.
Option C separates output logic (combinational, based on state) from state update logic (sequential, on clock). This matches Moore FSM design principles.
Which option best describes how FSMs model sequential behavior in digital circuits?
Think about how digital circuits remember past events to behave sequentially.
FSMs combine memory elements (flip-flops) that hold the current state and combinational logic that computes the next state. The clock signal triggers state updates, enabling sequential behavior.