2012-08-01 70 views
1

我正在使用VHDL,但我的模擬器不支持以下示例代碼中的未受影響的波形,我需要在開始作業分配之前運行該代碼。我在線閱讀,我可以通過相同的波形Z,但我不知道如何做到這一點,以便我可以得到與未受影響的關鍵字相同的結果......它如何被重寫,以便產生相同的結果?VHDL新手,不支持不受影響的波形

PS:我需要在作業的下一部分使用if-then-else語句重寫它,並且我知道在這種情況下我可以使用next關鍵字。這是我在作業之前需要運行的一本教科書的代碼。

感謝您的幫助。

library IEEE; 
use IEEE.std_logic_1164.all; 

entity pr_encoder is 
port ( S0, S1,S2,S3: in std_logic; 
      Z : out std_logic_vector (1 downto 0)); 
end entity pr_encoder; 

architecture behavioral of pr_encoder is 
begin 
    Z <= "00" after 5 ns when S0 = '1' else 
    "01" after 5 ns when S1 = '1' else 
    unaffected when S2 = '1' else 
    "11" after 5 ns when S3 = '1' else 
    "00" after 5 ns; 
end architecture behavioral; 

編輯:如果我註釋掉行了,我會實現我想要的結果?

回答

2

不,如果您只是對unaffected發表評論,行爲將會改變。

看來你正在描述一個latch。 (這在同步設計中不推薦)。確實Z更新如果S2 /= '1'並且不是如果S2 = '1'

確實可以將您的任務包裝在進程和if-else結構中,但不需要next語句。

process (S0, S1, S2, S3) is 
begin 
    if S0 = '1' then 
     Z <= "00" after 5 ns; 
    elsif S1 = '1' then 
     Z <= "01" after 5 ns; 
    elsif S2 = '1' then 
     null;     -- do nothing 
    elsif S3 = '1' then 
     Z <= "11" after 5 ns; 
    else 
     Z <= "00" after 5 ns; 
    end if; 
end process; 

或者你可以保持選擇賦值語句因爲你現在已經和改變的條件,使unaffected默認的(其他)的情況下。

Z <= "00" after 5 ns when S0 = '1' else 
    "01" after 5 ns when S1 = '1' else 
    "11" after 5 ns when S2 /= '1' and S3 = '1' else 
    "00" after 5 ns when S2 /= '1'; 
    -- else unaffected is implicit 

方的言論:

我從來沒有聽說過有關unaffected關鍵字之前,我認爲這是使用非常有限。因此它可能不是所有的工具來支持?

你的模擬器是什麼?