Strange FSM behavior: it goes straight to "work" state without "wait2work"

Status
Not open for further replies.

Pavelll

Newbie level 1
Joined
Jul 18, 2012
Messages
1
Helped
0
Reputation
0
Reaction score
0
Trophy points
1,281
Activity points
1,287
Strange FSM behavior: it goes straight to "work" state without "wait2work"

Hello friends!
I use FSM in my project and it behaves very strange.
Code:
always @(*)
        case (state_global)

        `WAIT : if      (wait2pass) state_next_global = `PASS;
                else if (wait2work) state_next_global = `WORK;
		else		    state_next_global = `WAIT;

        `PASS : if      (pass2wait) state_next_global = `WAIT;

        `WORK : if      (work2wait) state_next_global = `WAIT;


        default : 		    state_next_global = `PASS;

        endcase 

always @(posedge CLK or negedge RSTn) if (!RSTn) state_global<=`WAIT;
        			      else state_global<=state_next_global;
During simulation there is never high ¨wait2work¨ signal but the state machine turns in ¨WORK¨ state. Why does it happen?
Thanks.
 

Re: Strange FSM behavior

FSM has three states, which needs 2-bits to cover all the possible states. I guess one possibility is that only 1-bit is assigned.
BTW, `PASS and `WORK state should add 'else' branch to avoid latch.



- - - Updated - - -
 

Status
Not open for further replies.
Cookies are required to use this site. You must accept them to continue using the site. Learn more…