0
0
Verilogprogramming~10 mins

Sequence detector FSM in Verilog - Interactive Code Practice

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

Complete the code to declare the input signal for the FSM.

Verilog
module seq_detector(input clk, input rst, input [1], output reg detected);
Drag options to blanks, or click blank then click option'
Ain_bit
Binput_bit
Cbit_in
Ddata_in
Attempts:
3 left
💡 Hint
Common Mistakes
Using a signal name that is not declared in the module inputs.
Confusing output signals with input signals.
2fill in blank
medium

Complete the code to define the state type using an enum.

Verilog
typedef enum logic [1:0] {IDLE, [1], MATCHED, ERROR} state_t;
Drag options to blanks, or click blank then click option'
ASEEN1
BCHECK
CDETECT
DWAIT
Attempts:
3 left
💡 Hint
Common Mistakes
Using generic state names that don't reflect the sequence detection.
Choosing states that are not part of the FSM design.
3fill in blank
hard

Fix the error in the always block sensitivity list.

Verilog
always_ff @(posedge clk or [1]) begin
Drag options to blanks, or click blank then click option'
Aposedge rst
Bnegedge rst
Cnegedge clk
Drst
Attempts:
3 left
💡 Hint
Common Mistakes
Using posedge rst when reset is active low.
Omitting the reset signal from the sensitivity list.
4fill in blank
hard

Fill both blanks to complete the state transition condition.

Verilog
if (current_state == IDLE && data_in == [1]) next_state = [2];
Drag options to blanks, or click blank then click option'
A1
B0
CSEEN1
DMATCHED
Attempts:
3 left
💡 Hint
Common Mistakes
Confusing input bit values for transitions.
Assigning wrong next state for the given input.
5fill in blank
hard

Fill all three blanks to complete the output logic for sequence detection.

Verilog
always_ff @(posedge clk or negedge rst) begin
  if (!rst) detected <= 0;
  else if (current_state == [1] && data_in == [2]) detected <= [3];
  else detected <= 0;
end
Drag options to blanks, or click blank then click option'
ASEEN1
BMATCHED
C1
D0
Attempts:
3 left
💡 Hint
Common Mistakes
Setting output high in wrong states.
Using incorrect input bit value for detection.