2011-03-15 72 views
-2
-----------begin part1.vhdl--------------------- 


library ieee; 
use ieee.std_logic_1164.all; 

entity part1 is 
    generic (width : integer :=7); 
    PORT(a, b, c, d: IN std_logic_vector(width downto 0); 
     sel: IN std_logic_vector(1 downto 0); 
     result: OUT std_logic_vector(width downto 0) 
    ); 
end part1; 

architecture muxbehav of part1 is 

BEGIN 

    result <=  a after 5 ns when sel="00" else 
        b after 5 ns when sel="01" else 
        c after 5 ns when sel="10" else 
        d after 5 ns; 
end muxbehav; 

-----------end part1.vhdl--------------------- 

    -----------begin part1_tb.vhdl------------------ 

library ieee; 
use ieee.std_logic_1164.all; 


entity part1_tb is 
    generic(width : integer := 7); 
end part1_tb; 

architecture tb of part1_tb is 

    signal t_a: std_logic_vector(width downto 0):="00000000"; 
    signal t_b: std_logic_vector(width downto 0):="00000000"; 
    signal t_c: std_logic_vector(width downto 0):="00000000"; 
    signal t_d: std_logic_vector(width downto 0):="00000000"; 
    signal t_s: std_logic_vector(1 downto 0); 
    signal t_o: std_logic_vector(width downto 0); 

component part1 
    generic(width : integer); 
    PORT(a, b, c, d: IN std_logic_vector(width downto 0); 
     sel: IN std_logic_vector(1 downto 0); 
     result: OUT std_logic_vector(width downto 0) 
    ); 
    end component; 

    begin 

    U_part1: part1 generic map(width) port map(a=>t_a, b=>t_b, c=>t_c, d=>t_d, sel=>t_s, result=>t_o); 

    process 

     begin 

     t_a <= "11111111"; 
     t_b <= "00000001"; 
     t_c <= "10101010"; 
     t_d <= "01010101"; 

     wait for 10 ns; 
     t_s <= "00"; 
     wait for 6 ns; 
     assert (t_o="11111111") report "Error input a" severity error; 

     wait for 10 ns; 
     t_s <= "01"; 
     wait for 6 ns; 
     assert (t_o="00000001") report "Error input b" severity error; 

     wait for 10 ns; 
     t_s <= "10"; 
     wait for 6 ns; 
     assert (t_o="10101010") report "Error input c" severity error; 

     wait for 10 ns; 
     t_s <= "11"; 
     wait for 6 ns; 
     assert (t_o="01010101") report "Error input d" severity error; 

     wait; 

    end process; 
end tb; 

-----------end part1_tb.vhdl------------------ 

你好,这是我写的VHDL我的第一个代码。这是一个简单的4至1 MUX,可以接受任何宽度的矢量。但是,当我尝试运行我的测试平台时,GHDL只是挂起。我已经看过类似于我的测试平台,但我仍然无法找到我为什么挂着。有任何想法吗?简单VHDL 4比1个MUX测试平台吊

+0

“挂起”,你的意思是模拟运行没有发生任何事情,或者模拟时间停止前进? – 2011-03-15 08:01:38

+0

您可以发布您的平台的详细信息和版本GHDL的?和你的编译/运行命令? – 2011-03-15 21:22:01

+0

什么是“等待”的过程做的结束?它迫使它停止吗? 对不起,我不知道VHDL那么好..更多的Verilog人。 – user623879 2011-03-15 00:46:31

回答

1

嗯。我看不出有任何理由让它挂起。

我刚刚在Ubuntu 10.04的ghdl0.29上试过了你的代码 - 对我来说工作正常(因为它没有打印任何消息而退出,所以它看起来就像你的代码工作:)在gtkwave中波浪看起来也令人信服。

你可以尝试删除你的文件夹work和可执行文件并重新编译?

对不起,这不是真的,让你迈出的答案!