Guest
Hi,
There are two clocks in my design. On the main clock, a state machine
runs. It is encoded as a type (leaving the decision on the exact
encoding to the synthesizer). I want to set a signal on "enable" when
the machine is in a certain state, so I do:
if reset
...
elsif rising_edge(clk1) then
if machine_state = active then
my_enable <= '1';
else
my_enable <= '0';
end if;
end if;
This works fine, of course. But suppose I have another enable signal,
which should depend on the same event but works with a different
clock. How do I synchronize the state of the machine between the two
clocks ? At the moment I do a process:
if reset
...
elsif rising_edge(clk2) then
my_enable_sync <= my_enable;
my_enable2 <= my_enable_sync;
end if;
This works, because I know that the "Active" state is very long and
I'm not sensitive to exact timing. This double FF ensures no
metastability and correct syncing of my_enable to the clk2 domain.
Questions:
1) Is this a valid way to accomplish my goal ?
2) What is a faster / tighter way to do this synchronization, if I
care about every clock cycle ?
10x
R
There are two clocks in my design. On the main clock, a state machine
runs. It is encoded as a type (leaving the decision on the exact
encoding to the synthesizer). I want to set a signal on "enable" when
the machine is in a certain state, so I do:
if reset
...
elsif rising_edge(clk1) then
if machine_state = active then
my_enable <= '1';
else
my_enable <= '0';
end if;
end if;
This works fine, of course. But suppose I have another enable signal,
which should depend on the same event but works with a different
clock. How do I synchronize the state of the machine between the two
clocks ? At the moment I do a process:
if reset
...
elsif rising_edge(clk2) then
my_enable_sync <= my_enable;
my_enable2 <= my_enable_sync;
end if;
This works, because I know that the "Active" state is very long and
I'm not sensitive to exact timing. This double FF ensures no
metastability and correct syncing of my_enable to the clk2 domain.
Questions:
1) Is this a valid way to accomplish my goal ?
2) What is a faster / tighter way to do this synchronization, if I
care about every clock cycle ?
10x
R