0
我有兩個進程使用的信號它們之間進行同步的值,則使用的信號是休耕的方式:如何讓兩個過程來改變相同的信號
type state_machine_1 is
(st1_state_idle, st1_state_1, st1_state_2, st1_state_3,
st1_state_4,st1_state_5,st1_state_6);
type state_machine_2 is
(st2_state_idle, st2_state_1, st2_state_2);
--...
signal st1 : state_machine_1;
signal st2 : state_machine_2;
signal sync_sig : std_logic;
--...
st1_proc: process (CLK, RESET)
begin
if (RESET = '1') then
st1 <= st1_state_idle;
sync_sig <= '0';
elsif rising_edge(CLK) then
case st1 is
when st1_state_idle =>
--...
sync_data_is_ready_for_cau <= '0';
if (START = '1') then
st1 <= st_state_1;
else
st1 <= st1_state_idle;
end if;
----------------
when st_state_1 =>
--...
st1 <= st_state_2;
----------------
when st_state_2 =>
--...
st1 <= st_state_3;
----------------
when st_state_3 =>
--...
if (sync_sig = '0') then
st1 <= st_state_5;
else
st1 <= st_state_4;
end if;
----------------
when 4 =>
if (sync_sig = '0') then
st1 <= st_state_5;
else
st1 <= st_state_4;
end if;
----------------
when st_state_5 =>
--...
sync_sig <= '1';
st1 <= st_state_1;
end case;
end if;
end process;
st2_proc: process (CLK, RESET, reset_for_st2)
begin
if (RESET = '1' or reset_for_st2 = '1') then
st2 <= st2_state_idle;
elsif (rising_edge(CLK)) then
case st2 is
when st2_state_idle =>
if (sync_sig = '1') then
st2 <= st2_state_1;
else
st2 <= st2_state_idle;
end if;
----------------
when st2_state_1 =>
--...
st2 <= st2_state_2;
----------------
when st_state_2 =>
--...
st2 <= st2_state_3;
----------------
when st2_state_3 =>
--...
sync_sig <= '0';
st2 <= st2_state_idle;
----------------
end case;
end if;
end process;
所有--...
是邏輯不接觸同步信號,不接觸狀態信號(有些情況下,如果等待某個信號來提升狀態)。因此,放入同步信號的值之間不會有任何衝突,但仿真(Altera Model-Sim)會給信號賦予一個U
值。我如何使用信號在進程之間進行同步?
也許[this](http://stackoverflow.com/questions/9084975/vhdl-driving-signal-from-different-processes)可以幫助你。 – hr0m