2014-05-09 27 views
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值。我如何使用信号在进程之间进行同步?

+0

也许[this](http://stackoverflow.com/questions/9084975/vhdl-driving-signal-from-different-processes)可以帮助你。 – hr0m

回答

0

只有在模拟开始时没有reset激活时才会出现'U'(未初始化)。由于您在sync_sig上有多个驱动程序,因此在两个FSM冲突时实际应该获得'X'。如果解析类型有多个驱动程序,这是正常和预期的行为。

看起来您希望每个FSM都在'1'和'0'之间切换sync_sig的状态。这可以通过在单独的过程中用每个FSM驱动的置位和清除信号来独立描述JK触发器来实现。这样做将消除多个驱动程序并允许FSM互操作。

为了在未来避免此问题,请考虑使用未解决的std_ulogicstd_ulogic_vector来代替。如果您错误地描述了多个驱动程序,则会出现编译器错误。解决的类型确实非常适合行为模拟和管理双向IO。他们应该从未成为整个设计信号的“默认”。

相关问题