首页 文章

VHDL - 信号端口映射问题

提问于
浏览
-1

我已经定义了一个带有输入和输出端口的实体,它们都是std类型的逻辑向量 .

在体系结构中,有一个进程正在运行,它会更改输出端口的值并检查输入端口的值是什么 .

现在,在我的另一个名为top.vhd的vhdl文件中,我使用for generate循环创建了几个这样的实体 .

我需要的是以某种方式将输出端口的值连接到输入端口但我无法弄清楚如何执行此操作 .

让我们说我的第一个.vhd文件中的实体如下所示:

entity testt1 is

   Port ( 
      var_in     : in   STD_LOGIC_VECTOR (3 downto 0);
      var_out    : out  STD_LOGIC_VECTOR (3 downto 0);
   );
end testt1;

architecture Behavioral of testt1 is

.....process that changes the value of the var_out port and checks the value of the in port..... 

end Behavioral;

现在在我的主要.vhd文件名为top.vhd,在我端口映射后我需要能够将输入端口的值设置为输出端口的值,但我似乎无法弄清楚如何执行此操作 .

很高兴得到任何帮助 .

1 回答

  • 1

    你可以使用数组 . 例如,您希望在顶层模块中实例化N = 8个testt1单元 . 您将需要一个K = N 1 = 9个元素的数组来将所有内容连接在一起 .

    entity top ()
    
    architecture rtl of top is
      component testt1
        port(var_in   : in  std_logic_vector(3 downto 0);
             var_out  : out std_logic_vector(3 downto 0));
      end component;
    
      type my_array is array (8 downto 0) of std_logic_vector(3 downto);
      signal var  : my_array;
    
    begin
    
       var(0) <= "0001"; -- input val to first test1 unit
    
       GEN_REG: 
       for i in 0 to 7 generate
          gen_unit : testt1 port map
            ( var_in  => var(i),
              var_out => var(i+1) );
       end generate GEN_REG;
    
       -- var(8) will be output of last test1 unit
    
    end rtl;
    

相关问题