Type
Used In
- Package
- Entity
- Architecture
- Process
- Procedure
- Function
Reference Manual
VHDL-93:- Section 4.1
- Section 3.0
Syntax
type type_name is type_definition;
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 same 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;
Other types which may be declared are file types, access types and physical types.
Physical types are for describing physical quantities with units, i.e. voltage, temperature, area, etc. The predefined type time is a physical type which can be expressed in the following units:
Type | Units |
---|---|
fs | femtosecond |
ps | picosecond |
ns | nanosecond |
us | microsecond |
ms | millisecond |
sec | second |
min | minute |
hr | hour |
Access types are dynamic pointer addressed types, useful for modeling potentially large structures, i.e. memory, FIFO queues, etc. For more details see the reference manual.
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 std_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.
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.