On Sat, 27 Dec 2003 23:03:11 -0800, "Charlie" <Charlie@no_spam.com>
wrote:
>Hello,
>
>I'm trying to code a simple state machine in VHDL. When I simulate it it
>seems to run okay, but when I run it for real inside an FPGA it just seems
>to get stuck in the first state. The first state has an IF statement in it,
>if I remove this IF statement the FSM runs without getting stuck. The
>following shows how I have coded the FSM:
>
> state_machine : process(RST, FAST_CLK)
[...]
>
> when STATE_00 =>
> if SIG_A = SIG_B then -- just 2 signals
> fsm_state <= STATE_01;
> else
> fsm_state <= STATE_02;
> end if;
>
>So, does anyone have any idea on what I'm doing wrong? I'm using the XILINX
>ISE software. If anyone needs any further details then just let me know.
Not sure. First problem is the meaning of "=" between two signals, where
those signals may be "X" or "U" for example (assuming they are of type
std_[u]logic, and driven correctly)
To_01(Sig_A) forces the unknown values into known (0,1) states, which
could help if the problem were seen in simulation.
Alternatively
> when STATE_00 =>
fsm_state <= STATE_02;
> if SIG_A = SIG_B then -- just 2 signals
> fsm_state <= STATE_01;
> end if;
should be equivalent to the above, but safer if there is any doubt about
the equality test.
But most likely, your synthesis tool doesn't know how to generate an
equality test between two signals, only between a single signal and a
known value, like "Sig_A = '1'"
In which case, note that "SIG_A = SIG_B" is equivalent to
"(Sig_A XOR SIG_B) = '0'", which SHOULD be recognisable by any synthesis
tool.
- Brian