Guest
Hi,
I am trying to use an array of integers as an input to an entity. The number of
integers in the array is determined from a generic, but the integer values
should also be constrained by the generic.
For example:
entity ex0 is
generic(n : natural := 4);
port(
input1 : in integer range 0 to n-1;
input2 : in std_ulogic_vector(n-1 downto 0);
input3 : in array(n-1 downto 0) of integer range 0 to n-1;
output : std_ulogic
);
end entity ex0;
Inputs 1 & 2 will work, but 3 will produce a parse error (I know it is
incorrect, but it shows what I want to do). How can this be accomplished? Can
this be accomplished?
I understand that if I do not constrain the integers, they will be set to
32-bits each which will be a lot of extra wiring (it will also make
elaborating the design longer?) and wasted resources on bits that won't be
used. I cannot define types because the size of integer really does depend on
the generic (such as for input 1).
I am trying to use an array of integers as an input to an entity. The number of
integers in the array is determined from a generic, but the integer values
should also be constrained by the generic.
For example:
entity ex0 is
generic(n : natural := 4);
port(
input1 : in integer range 0 to n-1;
input2 : in std_ulogic_vector(n-1 downto 0);
input3 : in array(n-1 downto 0) of integer range 0 to n-1;
output : std_ulogic
);
end entity ex0;
Inputs 1 & 2 will work, but 3 will produce a parse error (I know it is
incorrect, but it shows what I want to do). How can this be accomplished? Can
this be accomplished?
I understand that if I do not constrain the integers, they will be set to
32-bits each which will be a lot of extra wiring (it will also make
elaborating the design longer?) and wasted resources on bits that won't be
used. I cannot define types because the size of integer really does depend on
the generic (such as for input 1).