![]() |
![]() |
A record is a set of named fields of various types, unlike an array, which is composed of identical anonymous entries. A record's field can be any previously defined type, including another record type.
The following example shows a record type declaration (BYTE_AND_IX), three signals of that type, and some assignments.
constant LEN: INTEGER := 8;
subtype BYTE_VEC is BIT_VECTOR(LEN-1 downto 0);
type BYTE_AND_IX is
record
BYTE: BYTE_VEC;
IX: INTEGER range 0 to LEN;
end record;
signal X, Y, Z: BYTE_AND_IX;
signal DATA: BYTE_VEC;
signal NUM: INTEGER;
. . .
X.BYTE <= "11110000";
X.IX <= 2;
DATA <= Y.BYTE;
NUM <= Y.IX;
Z <= X;
As shown in the above example, you can read values from or assign values to records in two ways.
X.BYTE <= DATA;
X.IX <= LEN;
The individual fields of a record type object are accessed by the object name, a period, and a field name; X.BYTE or X.IX. To access an element of the BYTE field's array, use the array notation X.BYTE(2).