VHDL MUX 测试台问题

VHDL MUX Test Bench Issue

我正在尝试通过 P. Ashenden 的书学习 VHDL:Designer's Guide to VHDL。第一章的练习 10 要求您用 VHDL 编写 2 对 1(我假设 1 位宽)MUX 并对其进行仿真。作为一个完全的菜鸟,我提前道歉。这是我的第一个 VHDL 代码。

我的 MUX 在合成中没有产生任何错误或警告。我的测试台也不会产生错误或警告。但是,除了信号名称外,模拟完全空白。

我试过在线查看大量其他 MUX 示例(以及书中的基准测试示例),当我尝试对它们进行综合时,所有这些都出现错误,所以我没有足够的信心使用它们作为指南,并没有从中得到太多。我不确定我在这里做错了什么。我会包括模拟图像,但我没有足够的代表点:(

此外,我意识到一个好的 MUX 也应该有接收不到 select input/high 阻抗值等的情况。在这种情况下,我只是想获得玩具模型工作。

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;

使用类型位(在包标准中声明)时,包 std_logic_1164 不需要 use 子句。

您在 MUXtop 中的流程语句 choose 没有导致流程在模拟中持续执行的敏感性子句。 (它不会做任何事情,直到你超过可能设置为无穷大的增量循环迭代限制)。

我添加了一个敏感度列表,注释掉了两个设计单元中多余的 use 子句,并添加了一些更多的刺激步骤以及最后的 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;

这给出了:

(可点击)