add seq_detector_1011

This commit is contained in:
Elie Deletang
2026-11-29 10:34:26 +01:00
parent bc3ff55602
commit 796dd9e640
10 changed files with 829 additions and 93 deletions
+45
View File
@@ -0,0 +1,45 @@
module seq_detector_1011 (
input logic clk,
input logic rst,
input logic in,
output logic detected
);
typedef enum logic [2:0]
{
IDLE,
S1,
S10,
S101,
S1011
} state_t;
state_t current_state, next_state;
always_ff @(posedge clk) begin
if (rst) begin
current_state <= IDLE;
end else begin
current_state <= next_state;
end
end
always_comb begin
next_state = IDLE;
case (current_state)
IDLE : if (in) next_state = S1; else next_state = IDLE;
S1 : if (in) next_state = S1; else next_state = S10;
S10 : if (in) next_state = S101; else next_state = IDLE;
S101 : if (in) next_state = S1011; else next_state = S10;
S1011 : if (in) next_state = S1; else next_state = S10;
default : next_state = IDLE;
endcase
end
assign detected = (current_state == S1011);
endmodule