VHDL Data TypesComposite Types (Cont.)
TYPE binary IS ( ON, OFF );
VARIABLE switch : switch_info;
switch.status := ON; -- status of the switch
switch.IDnumber := 30; -- e.g. number of the switch
- Used to group elements of possibly different types into a single VHDL object
- Elements are indexed via field names
- Examples of record declaration and usage :
The second VHDL composite type is the record. An object of type record may contain elements of different types. Again, a record element may be of any data type, including another record.
A TYPE declaration is used to define a record. Note that the types of a record's elements must be defined before the record is defined. Also notice that there is no semi-colon after the word RECORD. The RECORD and END RECORD keywords bracket the field names. After the RECORD keyword, the record's field names are assigned and their data types are specified.
In the above example, a record type, switch_info, is declared. This example makes use of the binary enumerated type declared previously. Note that values are assigned to record elements by use of the field names.