I am desperately trying to assign a constant that is an array of length 1 in VHDL, but it doesn't seem to work (with GHDL), it complains that I can't assign a literal of the type which is inside the array, into the array.
package test is
constant length : integer := 1; -- this could come from a different package
type integer_array is array ((length - 1) downto 0) of integer;
constant my_array : integer_array := (1);
end test;
When I try to compile this with GHDL I get the error message test.vhdl:8:46:error: can't match integer literal with type array type "integer_array"
If I change length
to 2
though and use (1, 2)
as literal, it works perfectly.
So how do I initialise an array of length 1?