This code does not compile:
type array_1_t is array (0 to 73) of std_logic_vector(31 downto 0);
type array_2_t is array (0 to 22) of std_logic_vector(31 downto 0);
signal my_array_1: array_1_t;
alias my_array_2_1: array_2_t is my_array_1(0 to 22);
alias my_array_2_2: array_2_t is my_array_1(23 to 45);
alias my_array_2_3: array_2_t is my_array_1(46 to 73);
The error is "The type of aliased object does not match the type in the alias declaration."
Both of these arrays are of std_logic_vector(31 downto 0). When then does this code not compile?
Best Answer
The element type is the same but not the types themselves.
IEEE Std 1076-2008 6.6.2 Object aliases:
and 6.6 Alias declarations, 6.6.1 General
How can a named entity have two different types? The alias has a subtype indication type mark that's different from the thing being aliased.
So how should an alias of array slice be created in this case?
Declare type array_1_t as an unbounded array type so you can constrain it in the aliases:
A package declaration is used here for illustration purposes providing a minimal, complete, and verifiable example.