0
0
Verilogprogramming~10 mins

Why FSMs model sequential behavior in Verilog - Test Your Understanding

Choose your learning style9 modes available
Practice - 5 Tasks
Answer the questions below
1fill in blank
easy

Complete the code to declare a clock-sensitive block in Verilog.

Verilog
always @(posedge [1]) begin
    // sequential logic here
end
Drag options to blanks, or click blank then click option'
Aclk
Breset
Cdata
Denable
Attempts:
3 left
💡 Hint
Common Mistakes
Using data or reset signals instead of the clock in the sensitivity list.
2fill in blank
medium

Complete the code to define a state register that updates on the clock edge.

Verilog
reg [1:0] state;
always @(posedge clk) begin
    state <= [1];
end
Drag options to blanks, or click blank then click option'
Anext_state
Bstate
Cinput_signal
Dreset
Attempts:
3 left
💡 Hint
Common Mistakes
Assigning state to itself, which causes no state change.
3fill in blank
hard

Fix the error in the state transition logic by completing the conditional statement.

Verilog
always @(posedge clk) begin
    if (reset) begin
        state <= 2'b00;
    end else if (input_signal [1] 1'b1) begin
        state <= 2'b01;
    end
end
Drag options to blanks, or click blank then click option'
A!=
B==
C=
D<=
Attempts:
3 left
💡 Hint
Common Mistakes
Using = instead of == in the if condition.
4fill in blank
hard

Fill both blanks to complete the combinational logic for next state assignment.

Verilog
always @(*) begin
    case (state)
        2'b00: next_state = (input_signal [1] 1'b1) ? 2'b01 : 2'b00;
        2'b01: next_state = (input_signal [2] 1'b0) ? 2'b00 : 2'b01;
        default: next_state = 2'b00;
    endcase
end
Drag options to blanks, or click blank then click option'
A==
B!=
C<=
D>=
Attempts:
3 left
💡 Hint
Common Mistakes
Using assignment operators instead of comparison operators in conditions.
5fill in blank
hard

Fill all three blanks to complete the FSM module with state, next_state, and clock sensitivity.

Verilog
module fsm(input clk, input reset, input input_signal, output reg [1:0] state);
    reg [1:0] [1];

    always @([2]) begin
        if (reset) begin
            state <= 2'b00;
        end else begin
            state <= [3];
        end
    end
endmodule
Drag options to blanks, or click blank then click option'
Anext_state
Bposedge clk
Dnegedge reset
Attempts:
3 left
💡 Hint
Common Mistakes
Using wrong sensitivity list like reset edge instead of clock edge.
Confusing state and next_state registers.