测试门系统的结构设计

Structural design for testing a gate system

我正在使用 VHDL 进行数字和计算机设计基础一书中的实验 3。这就是它想要的。

我的模块 1、2 和 3 都是单独工作的。当我尝试将它们放在顶部模块中时,我开始遇到问题。当我尝试模拟程序时失败了,我不确定如何修复。

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

entity Displetter is
    Port ( mux_in : in  STD_LOGIC;
           Cath : out  STD_LOGIC_VECTOR (7 downto 0);
           An : out  STD_LOGIC_VECTOR (3 downto 0));
end Displetter;

architecture Behavioral of Displetter is

begin
  process(mux_in)
  begin
      if(mux_in = '0') then
                Cath <= "11000111"; --L pgfedcba 0s are what's lit up
      elsif (mux_in = '1') then
                Cath <= "10001001"; -- H pgfedcba
      end if;
  end process;

  An <= "0111";
end Behavioral;

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


entity MUX8 is
    Port ( D : in  STD_LOGIC_VECTOR (7 downto 0);
           S : in  STD_LOGIC_VECTOR (2 downto 0);
           MUXOUT : out  STD_LOGIC);
end MUX8;

architecture Behavioral of MUX8 is

begin
    MUXOUT <= D(0) when (S="000") else
            D(1) when (S="001") else
            D(2) when (S="010") else
            D(3) when (S="011") else
            D(4) when (S="100") else
            D(5) when (S="101") else
            D(6) when (S="110") else
            D(7);

end Behavioral;

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

entity Displetter is
    Port ( mux_in : in  STD_LOGIC;
           Cath : out  STD_LOGIC_VECTOR (7 downto 0);
           An : out  STD_LOGIC_VECTOR (3 downto 0));
end Displetter;

architecture Behavioral of Displetter is

begin
  process(mux_in)
  begin
      if(mux_in = '0') then
                Cath <= "11000111"; --L pgfedcba 0s are what's lit up
      elsif (mux_in = '1') then
                Cath <= "10001001"; -- H pgfedcba
      end if;
  end process;

  An <= "0111";
end Behavioral;


--Top Module

library IEEE;
use IEEE.STD_LOGIC_1164.ALL;

entity TopMod is
    Port ( s6 : in  STD_LOGIC;
           s7 : in  STD_LOGIC;
           Cath : out  STD_LOGIC_VECTOR (7 downto 0);
           An : out  STD_LOGIC_VECTOR (3 downto 0);
           s0 : in  STD_LOGIC;
           s1 : in  STD_LOGIC;
           s2 : in  STD_LOGIC);
end TopMod;

architecture Behavioral of TopMod is

COMPONENT Gates
  PORT(
      s6 : in  STD_LOGIC;
         s7 : in  STD_LOGIC;
         a0 : out  STD_LOGIC;
         a1 : out  STD_LOGIC;
         a2 : out  STD_LOGIC;
         a3 : out  STD_LOGIC;
         a4 : out  STD_LOGIC;
         a5 : out  STD_LOGIC;
         a6 : out  STD_LOGIC;
         a7 : out  STD_LOGIC
      );
  END COMPONENT;

COMPONENT MUX8
  PORT(
    D : in  STD_LOGIC_VECTOR (7 downto 0);
      S : in  STD_LOGIC_VECTOR (2 downto 0);      
    MUXOUT : OUT std_logic
    );
  END COMPONENT;

COMPONENT Displetter
  PORT(
    mux_in : in  STD_LOGIC;
      Cath : out  STD_LOGIC_VECTOR (7 downto 0);
      An : out  STD_LOGIC_VECTOR (3 downto 0))
  );
  END COMPONENT;

  signal mout;
begin
  GATE : PORT MAP(
    s6 => s6;
    s7 => s7;
  );
  MUX : PORT MAP(
    D<7> => a7,
    D<6> => a6,
    D<5> => a5,
    D<4> => a4,
    D<3> => a3,
    D<2> => a2,
    D<1> => a1,
    D<0> => a0,

    s<0> => s0,
    s<1> => s1,
    s<2> => s2
    MUXOUT => mout
  );

  Disp : PORT MAP(
    Cath => Cath,
    An => An,
    mux_in => mout
  );

end Behavioral;

这些是我注意到的一些最明显的问题。请考虑尝试以下一些方法并报告您看到的实际错误。

您需要信号来连接组件

在您的顶级架构中,所有 a0...a7 端口都需要信号将组件连接在一起。

组件实例化

声明组件后,实例化它们:

labelname: componentName

此外,您的端口映射中需要圆括号。

考虑将您的组件放在单独的文件中(如果您还没有的话),这可能会使错误消息更容易阅读。