VHDL-2008 defines
type integer_vector is array (natural range <>) of integer
and it can be used to create arrays of unlimited integers simply:
signal sUnconsrainedIntA : integer_vector(0 to 1) := (others => 0);
However, how to declare an array of bounded integers, for example:
-- does not work:
-- signal sConstrainedTestIntA : integer_vector(0 to 1) range 0 to 3 := (others => 0);
-- ** Error: filetest.vhd(65): Range constraints cannot be applied to array types.
-- ** Error: filetest.vhd(65): Range expression is type Integer; expecting type std.STANDARD.INTEGER_VECTOR
-- What you can do is:
type my_int_array is array (natural range <>) of integer range 0 to 3;
signal sConstrainedIntA : my_int_array(0 to 1) := (others => 0);
Is there a way to limit integers in an array without a custom type?
source
share