I am getting started on a design that will have many 2D arrays (13x32) in which about 50 data fields are packed. The arrays get transferred across 32-bit interfaces and stored to memory as 32-bit values, so it makes good sense to use a 2D array type for the object.
The data within that array is used as the individual fields, so it would be nice to use aliases to do the assignment and manipulation of the fields. However since there are lots (12 or so) of these arrays throughout the design, I'd need to define the 50 aliases in 12 different places, which becomes unwieldy.
My preference would be define a "record alias" in a package which could be applied to any 13x32 array. Then the definition would be in one place (so if it were to change, I'd only need to modify it in one place) and I'd be able to assign it on one line instead of 50.
I'd envision something like:
type SCD_ARRAY is array(12 downto 0) of STD_LOGIC_VECTOR(31 downto 0));
type RECORD_ALIAS_TYP is record
ADDR : STD_LOGIC_VECTOR(7 downto 0);
DATA : STD_LOGIC_VECTOR(7 downto 0);
. . .
end record;
variable IN_SCD_ARRAY : SCD_ARRAY;
variable OUT_SCD_ARRAY : SCD_ARRAY;
alias IN_SCD : RECORD_ALIAS_TYP is IN_SCD_ARRAY;
alias OUT_SCD : RECORD_ALIAS_TYP is OUT_SCD_ARRAY;
. . .
OUT_SCD.ADDR <= IN_SCD.ADDR + 1;
Obviously, "record aliases" don't exist (there would need to be some way to tie the record fields to the actual data object). Can anyone think of a way to do this (perhaps an alias to a pointer or an alias to an alias?).
Thanks,
Steve
The data within that array is used as the individual fields, so it would be nice to use aliases to do the assignment and manipulation of the fields. However since there are lots (12 or so) of these arrays throughout the design, I'd need to define the 50 aliases in 12 different places, which becomes unwieldy.
My preference would be define a "record alias" in a package which could be applied to any 13x32 array. Then the definition would be in one place (so if it were to change, I'd only need to modify it in one place) and I'd be able to assign it on one line instead of 50.
I'd envision something like:
type SCD_ARRAY is array(12 downto 0) of STD_LOGIC_VECTOR(31 downto 0));
type RECORD_ALIAS_TYP is record
ADDR : STD_LOGIC_VECTOR(7 downto 0);
DATA : STD_LOGIC_VECTOR(7 downto 0);
. . .
end record;
variable IN_SCD_ARRAY : SCD_ARRAY;
variable OUT_SCD_ARRAY : SCD_ARRAY;
alias IN_SCD : RECORD_ALIAS_TYP is IN_SCD_ARRAY;
alias OUT_SCD : RECORD_ALIAS_TYP is OUT_SCD_ARRAY;
. . .
OUT_SCD.ADDR <= IN_SCD.ADDR + 1;
Obviously, "record aliases" don't exist (there would need to be some way to tie the record fields to the actual data object). Can anyone think of a way to do this (perhaps an alias to a pointer or an alias to an alias?).
Thanks,
Steve