2015-07-21 153 views
0

我想通過P. Ashenden的書學習VHDL:VHDL設計者指南。第1章的練習10要求您以VHDL編寫2對1(我假設爲1位寬)MUX並對其進行仿真。我爲提供一個完整的noob提前道歉。這是我的第一個VHDL代碼。VHDL MUX測試臺問題

我的MUX在綜合中沒有產生任何錯誤或警告。我的測試臺也不會產生錯誤或警告。但是,除了信號的名稱之外,仿真完全變爲空白。

我試過了很多其他MUX示例在線(以及本書的一個長凳測試示例),當我嘗試合成它們時,所有這些都給出了錯誤,所以我沒有足夠的信心使用它他們作爲指導,並沒有得到很多。我不確定我在這裏做錯了什麼。我會包含一個模擬圖像,但我沒有足夠的重點:(

此外,我意識到,一個好的MUX也應該有案件,當它沒有收到選擇輸入/高阻抗值,等..在這種情況下,我只是試圖讓玩具模型工作

的MUX代碼:

library IEEE; 
use IEEE.STD_LOGIC_1164.ALL; 

entity MUXtop is 
    Port (a, b, sel: in bit; 
     z: out bit); 
end MUXtop; 

architecture behav of MUXtop is 
begin 
    choose: process is 
    begin 
     if sel = '0' then 
      z <= b; 
     else 
      z <= a; 
     end if; 
    end process choose; 
end architecture behav; 

測試臺代碼:

LIBRARY ieee; 
USE ieee.std_logic_1164.ALL; 

ENTITY MUXtest IS 
END MUXtest; 

ARCHITECTURE behavior OF MUXtest IS 

-- Component Declaration for the Unit Under Test (UUT) 

    COMPONENT MUXtop 
    PORT(
     a : IN bit; 
     b : IN bit; 
     sel : IN bit; 
     z : OUT bit 
     ); 
    END COMPONENT MUXtop; 


    --Inputs 
    signal a : bit := '0'; 
    signal b : bit := '0'; 
    signal sel : bit := '0'; 

    --Outputs 
    signal z : bit; 

BEGIN 

-- Instantiate the Unit Under Test (UUT) 
    uut: MUXtop PORT MAP (
      a => a, 
      b => b, 
      sel => sel, 
      z => z 
      ); 

    -- Stimulus process 
    stimulus: process 
    begin 
     wait for 10 ns; 
     a <= '1'; 
     wait for 10 ns; 
     sel <= '1'; 
     wait for 10 ns; 
     b <= '1'; 
     wait; 
    end process stimulus; 
END architecture behavior; 

回答

1

你不」 t需要使用cl在使用類型位(在包標準中聲明)時使用包std_logic_1164。

MUXtop中的進程語句choose沒有敏感性子句,它會導致進程在仿真中持續執行。 (只有當你的Delta循環迭代限制可能設置爲無窮大時纔會執行任何操作)。

我加了一個敏感列表,在這兩個設計單位註釋掉多餘的使用條款,並增加了一些更多的刺激措施,以及最終的wait for 10 ns;,讓您的測試平臺可以看到的最後一個動作:

library IEEE; 
-- use IEEE.STD_LOGIC_1164.ALL; 

entity MUXtop is 
    Port (a, b, sel: in bit; 
     z: out bit); 
end MUXtop; 

architecture behav of MUXtop is 
begin 
    choose: process (a, b, sel) -- is 
    begin 
     if sel = '0' then 
      z <= b; 
     else 
      z <= a; 
     end if; 
    end process choose; 
end architecture behav; 

LIBRARY ieee; 
-- USE ieee.std_logic_1164.ALL; 

ENTITY MUXtest IS 
END MUXtest; 

ARCHITECTURE behavior OF MUXtest IS 

-- Component Declaration for the Unit Under Test (UUT) 

    COMPONENT MUXtop 
    PORT(
     a : IN bit; 
     b : IN bit; 
     sel : IN bit; 
     z : OUT bit 
     ); 
    END COMPONENT MUXtop; 


    --Inputs 
    signal a : bit := '0'; 
    signal b : bit := '0'; 
    signal sel : bit := '0'; 

    --Outputs 
    signal z : bit; 

BEGIN 

-- Instantiate the Unit Under Test (UUT) 
    uut: MUXtop PORT MAP (
      a => a, 
      b => b, 
      sel => sel, 
      z => z 
      ); 

    -- Stimulus process 
    stimulus: process 
    begin 
     wait for 10 ns; 
     a <= '1'; 
     wait for 10 ns; 
     sel <= '1'; 
     wait for 10 ns; 
     sel <= '0';  -- added 
     wait for 10 ns; -- added 
     b <= '1'; 
     wait for 10 ns; -- added 
     wait; 
    end process stimulus; 
END architecture behavior; 

這給:

muxtest.png (點擊)