in my Verilog code, the ns
value does not get assigned to any of the values in the next state logic
. As I coded the next state logic
to assign a value to the ns
state variable whenever there is a transition in the ps
.
Here is the FSM code snippet
// State registers
always@(posedge clk, negedge rst) begin
if(!rst) ps <= S1;
else ps <= ns;
end
assign present_state = ps;
assign next_state = ns;
// Next state logic
always@(ps, start) begin
case(ps)
S1: ns = start ? S2 : S1;
S2: ns = S3;
S3: ns = S1;
//default : ns = S1;
endcase
end
Here is the tb code snippet
initial begin
#0 rst = 0; start = 0;
#2 rst = 1;
#10 a = 3; b = 4;
#10 start = 1;
My intention is for the ps <= ns
to seamlessly transtion from S1
to S2
to S3
back to S1
and so forth, however for some reason despite the always_comb
next state logic block, the state change of ps
at t=0, does not assign the ns
to a valid state ? Resulting in all further ps <= ns
assignments to be always 'x
states
Is there a flaw in this logic ?
A swift help is much appreciated
Thanks