Type Declaration

Declaration ---- used in ----> Package
Entity
Architecture
Process
Procedure
Function


Syntax

type type_name is type_definition;

See LRM section 4.1 and chapter 3


Rules and Examples

Scalar types hold only one value. Predefined scalar types include integer, real, bit, boolean and character.
User defined numeric types may be declared
type T_INT is range 0 to 9;
type T_REAL is range -9.9 to 9.9;
type BUS_VAL is range 0 to 255;
User defined enumerated types may be defined with either characters or identifiers as literals:
type MY_STATE is (RESET,IDLE,ACKA);
type MY_LOGIC is ('X','0','1','Z');
Objects of a user-defined type cannot directly be assigned to or from objects of a different type. For more details see Subtypes and type conversions
Composite types (arrays and records) hold more than one value. Array types have multiple elements of the sname type. Record types have named fields of differing types:
type T_PACKET is record
  BYTE_ID: std_ulogic;
  PARITY : std_ulogic;
  ADDRESS: integer range 0 to 3;
  DATA   : std_ulogic_vector(3 downto 0);
end record;
Record type objects are assigned using aggregates. Individual fields are assigned using a selected name
signal TX_DATA : T_PACKET;
...
TX_DATA.ADDRESS <= 3;
Physical types are for describing physical quantities with units, e.g.voltage, temperature, area, etc. The predefined type time is a physical type, which can be expressed in the following units:
fs  (femtosecond)
ps  (picosecond)
ns  (nanosecond)
us  (microsecond)
ms  (millisecond)
sec (second)
min (minute)
hr  (hour).
Other types which may be declared are file types, access types and physical types.
Access types are dynamic pointer addressed types, useful for modelling potentially large structures, e.g.memory, FIFO queues e.t.c. For more details see the LRM section 3.13


Synthesis Issues

Most logic synthesis tools accept the following types integer, boolean, bit, user-defined enumerated types, bit_vector, linear arrays and records of other supported types, plus the stc_logic_1164 types.

Synthesis tools will infer an appropriate number of bits for enumerated and integer types. It may be possible to specify the encoding to be used in each case.

Access, file and physical types are unsupported.


Whats New in '93

In VHDL-93, the keywords end record may be followed by the type name for clarity and consistency.

The predefined types character and string support an extended character set, including those used in most European languages.