Practice - 5 Tasks
Answer the questions below
1fill in blank
easyComplete the code to declare the state register.
Verilog
reg [1:0] [1] ;
Drag options to blanks, or click blank then click option'
Attempts:
3 left
💡 Hint
Common Mistakes
Using input or output instead of state for the register name.
✗ Incorrect
The state register holds the current state of the FSM.
2fill in blank
mediumComplete the code to define the next state logic.
Verilog
always @(*) begin
case (state)
2'b00: next_state = [1];
default: next_state = 2'b00;
endcase
end Drag options to blanks, or click blank then click option'
Attempts:
3 left
💡 Hint
Common Mistakes
Choosing the current state as next state incorrectly.
✗ Incorrect
The next state after 2'b00 is 2'b01 as per the state diagram.
3fill in blank
hardFix the error in the state update block.
Verilog
always @(posedge clk or posedge reset) begin if ([1]) state <= 2'b00; else state <= next_state; end
Drag options to blanks, or click blank then click option'
Attempts:
3 left
💡 Hint
Common Mistakes
Using clk instead of reset in the if condition.
✗ Incorrect
The reset signal asynchronously resets the state to 2'b00.
4fill in blank
hardFill both blanks to complete the output logic based on state.
Verilog
always @(*) begin case ([1]) 2'b01: output_signal = [2]; default: output_signal = 1'b0; endcase end
Drag options to blanks, or click blank then click option'
Attempts:
3 left
💡 Hint
Common Mistakes
Using next_state instead of state for output logic.
✗ Incorrect
The output depends on the current state. When state is 2'b01, output_signal is 1.
5fill in blank
hardFill all three blanks to complete the full FSM module skeleton.
Verilog
module fsm(clk, reset, output_signal); input [1]; input [2]; output reg [3]; reg [1:0] state, next_state; always @(posedge clk or posedge reset) begin if (reset) state <= 2'b00; else state <= next_state; end always @(*) begin case (state) 2'b00: next_state = 2'b01; 2'b01: next_state = 2'b10; default: next_state = 2'b00; endcase end always @(*) begin case (state) 2'b01: output_signal = 1'b1; default: output_signal = 1'b0; endcase end endmodule
Drag options to blanks, or click blank then click option'
Attempts:
3 left
💡 Hint
Common Mistakes
Confusing input and output declarations.
✗ Incorrect
The module inputs are clk and reset, and output is output_signal.