我正在尝试将数组大小(整数 ArraySize)从顶级文件传递给组件,但出现错误:
[Synth 8-561] 范围表达式无法解析为常量 [/UnconArray.vhd":39]
我想知道是否有办法做到这一点。另外,如果必须将不受约束的数组定义为常量,那有什么意义呢?
无约束测试.vhd
library IEEE;
use IEEE.STD_LOGIC_1164.ALL;
entity UnconstrainedTest is
Port ( clk : in std_logic;
reset: in std_logic;
LED0 : out std_logic := '0';
LED1 : out std_logic := '0'
);
end UnconstrainedTest;
architecture Behavioral of UnconstrainedTest is
component UnconArray is
port( clk_1 : in std_logic;
ArraySize : in integer;
LED_0 : out std_logic
);
end component;
begin
A1: UnconArray port map (
clk_1 => clk,
ArraySize => 12,
LED_0 => LED0
);
A2: UnconArray port map (
clk_1 => clk,
ArraySize => 8,
LED_0 => LED1
);
end Behavioral;
组件 UnconArray.vhd
begin
library IEEE;
use IEEE.STD_LOGIC_1164.ALL;
entity UnconArray is
-- generic (depth : integer := 2);
Port ( clk_1 : in std_logic;
ArraySize : in integer;
LED_0 : out std_logic
);
end UnconArray;
architecture Behavioral of UnconArray is
type Array_type is array (integer range <>) of integer;
signal MyUnconArray : Array_type (0 to ArraySize);
-- type Array_type is array (0 to ArraySize) of integer;
-- signal MyUnconArray : Array_type;
begin
MyUnconArray <= (1, 2, 3);
process (clk_1)
begin
if rising_edge(clk_1) then
if ( MyUnconArray(0) = 1 )then
LED_0 <= '1';
else
LED_0 <= '0';
end if;
end if;
end process;
end Behavioral;