I am attempting to pass an array size ( integer ArraySize) from a Top-level file to a component, but get the error:
[Synth 8-561] range expression could not be resolved to a constant [/UnconArray.vhd":39]
I am wondering if there is a way to do this. Also, if a unconstrained array has to be defined as a constant, then what's the point?
UnconstrainedTest.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;
The component 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;
MyUnconArray <= (1, 2, 3);when simulating - there aren't enough elements in the expression, the values ofArraySizeare 12 and 8 in UnconstrainedTest. Use a generic, fix the assignment.0. You hardly need an array in this example.