The code I am using is the following. I am using five states as this is a Moore model, and non-overlapping sequence is assumed. The state logic is correct as far as I can tell. However, when I run it, there is one test case that it does not pass.
The fact that I have trouble understanding is that it passes all cases after that with 1100 as the input and leaves out just one. I don't have the testbench for this, and only the test cases are used to determine the validity of design. The test case that didn't pass had the sequence X=1,X=1,X=0,X=0.
module sequence_detector_fsm (
input Clk,
input X,
output Y
);
parameter A=0, B=1, C=2, D=3, E=4;
reg [2:0] PS, NS;
always @(posedge Clk) begin
PS <= NS;
end
always @(PS,NS,X) begin
case (PS)
A : NS = X ? B : A;
B : NS = X ? C : A;
C : NS = X ? C : D;
D : NS = X ? B : E;
E : NS = X ? B : A;
default : NS = A;
endcase
end
assign Y = (PS==E);
endmodule