J
John
Guest
Hi
To keep this question short I've only included brief snipet's of code which
I hope show what I'm doing.
I'm designing a device in VHDL which contains a couple of state machines.
In my state machines I usually have a couple of IF statements e.g.
*** each state is clocked on the rising edge of FAST_CLK
when STATE_0 =>
if sig_x = '1' then
go to the next state
endif;
when STATE_1 =>
if sig_x = '0' then
go to another state
endif;
Now if I use the above example the state machine seems to get stuck in a
state. The only way I can overcome this is by doing the following:
p : process(FAST_CLK)
begin
if rising_edge(FAST_CLK) then
synced <= sig_x;
endif;
end process p;
*** each state is clocked on the rising edge of FAST_CLK
when STATE_0 =>
if synced = '1' then
go to the next state
endif;
when STATE_1 =>
if synced = '0' then
go to another state
endif;
So, basically I synchronize sig_x with FAST_CLK and then everything works.
Is this the correct way of doing it, or am I missing something obvious? Is
it normal to do this with every state machine?
Thanks for any info or advice,
To keep this question short I've only included brief snipet's of code which
I hope show what I'm doing.
I'm designing a device in VHDL which contains a couple of state machines.
In my state machines I usually have a couple of IF statements e.g.
*** each state is clocked on the rising edge of FAST_CLK
when STATE_0 =>
if sig_x = '1' then
go to the next state
endif;
when STATE_1 =>
if sig_x = '0' then
go to another state
endif;
Now if I use the above example the state machine seems to get stuck in a
state. The only way I can overcome this is by doing the following:
p : process(FAST_CLK)
begin
if rising_edge(FAST_CLK) then
synced <= sig_x;
endif;
end process p;
*** each state is clocked on the rising edge of FAST_CLK
when STATE_0 =>
if synced = '1' then
go to the next state
endif;
when STATE_1 =>
if synced = '0' then
go to another state
endif;
So, basically I synchronize sig_x with FAST_CLK and then everything works.
Is this the correct way of doing it, or am I missing something obvious? Is
it normal to do this with every state machine?
Thanks for any info or advice,