Complete the code to declare the input signal for the FSM.
module seq_detector(input clk, input rst, input [1], output reg detected);The input signal is named data_in to represent the incoming bit stream.
Complete the code to define the state type using an enum.
typedef enum logic [1:0] {IDLE, [1], MATCHED, ERROR} state_t;
The state SEEN1 represents the FSM having detected the first bit of the sequence.
Fix the error in the always block sensitivity list.
always_ff @(posedge clk or [1]) begin
posedge rst when reset is active low.The reset signal is usually active low, so the sensitivity list uses negedge rst.
Fill both blanks to complete the state transition condition.
if (current_state == IDLE && data_in == [1]) next_state = [2];
When in IDLE state and input bit is 0, FSM moves to SEEN1 state.
Fill all three blanks to complete the output logic for sequence detection.
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
The output detected is set to 1 when the FSM is in MATCHED state and input bit is 1.
