add seq_detector_1011
This commit is contained in:
@@ -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
|
||||
Reference in New Issue
Block a user