我遇到了在两个VHDL模块之间共享“数组数组”的问题。
我在VHDL子模块中声明了一个“数组数组”,如下所示,
type avg_log is array (0 to 31) of std_Logic_vector(19 downto 0);
signal V1 :avg_log :=(others=>others=>'0');
我想将V1()()
的所有元素发送到顶层模块,我尝试使用PORT& GENERIC,但我收到了一条错误消息。
有人可以帮助我吗?
答案 0 :(得分:2)
您需要在程序包中定义type
,然后通过use
将其包含在两个实体中,如下所示:
library ieee;
use ieee.std_logic_1164.all;
package p_avg is
type avg_log is array (0 to 31) of std_Logic_vector(19 downto 0);
end package p_avg;
然后在您的实体中
use work.p_avg.all;
entity my_e is
port(
...
V1 : out avg_log := (others => (others => '0'));
...
);
end entity;
然后在周围架构的端口映射中使用它(包括也必须包含在内)...还有其他方法,但这是我建议的方式......
答案 1 :(得分:0)
下面的整个示例,定义了p_avg包(如BennyBarns建议的那样),my_e子模块my_e和tb top模块;可以用ModelSim编译:
library ieee;
use ieee.std_logic_1164.all;
package p_avg is
type avg_log is array (0 to 31) of std_logic_vector(19 downto 0);
end package p_avg;
library ieee;
use ieee.std_logic_1164.all;
library work;
use work.p_avg.all;
entity my_e is
port(
v1_o : out avg_log);
end entity;
architecture sim of my_e is
begin
v1_o <= (others => (others => '0'));
end architecture;
library ieee;
use ieee.std_logic_1164.all;
library work;
use work.p_avg.all;
entity tb is
end entity;
architecture sim of tb is
signal v1 : avg_log;
begin
my_e_1 : entity work.my_e
port map(
v1_o => v1);
end architecture;