VHDL Data Types
VHDL Data Types
NAME: A.Harshvardhan
C-18
Artificial Intelligence
Modelling Of Digital Circuits
Prof. Rahul Agarwal
VHDL Data Types
DATA TYPES
Every data object in VHDL can hold a value that belongs to a set of
values. This set of values is specified by using a type declaration.
A type is a name that has associated with it a set of values and a set of
operations.
The language also provides the facility to define new types by using type
declarations and also to define a set of operations on these types by
writing functions that return values of this new type.
All the possible types that can exist in the language can be categorized
into the following four major categories:
1. Scalar types: Values belonging to these types appear in a sequential
order.
2. Composite types: These are composed of elements of a single type (an
array type) or elements of different types (a record type).
3. Access types: These provide access to objects of a given type (via
pointers).
4. File types: These provides access to objects that contain a sequence of
values of a given type.
SUBTYPES
A subtype is a type with a constraint.
The constraint specifies the subset of values for the type.
The type is called the base type of the subtype.
An object is said to belong to a subtype if it is of the base type
and if it satisfies the constraint.
Subtype declarations are used to declare subtypes.
An object can be declared to either belong to a type or to a
subtype.
Examples of subtypes are
subtype MY_INTEGER is INTEGER range 48 to 156 ;
type DIGIT is ('0', '1', '2', '3', '4', '5', '6', '7', '8', '9') ;
subtype MIDDLE is DIGIT range '3' to '7' ;
A subtype need not impose a constraint. In such a case, the
subtype simply gives another name to an already existing type.
For example:
subtype NUMBER is DIGIT;
SCALAR TYPES
The values belonging to this type are ordered, that is, relational
operators can be used on these values.
For example, BIT is a scalar type and the expression '0' < 1' is
valid.
There are four different kinds of scalar types:
1. enumeration,
2. integer,
3. physical,
4. floating point.
Integer types, floating point types, and physical types are
classified as numeric types since the values associated with
these types are numeric.
Further, enumeration and integer types are called discrete types
since these types have discrete values associated with them.
Enumeration Types
An enumeration type declaration defines a type that has a set of
user-defined values consisting of identifiers and character
literals.
Examples are
type MVL is ('U','0','1','Z);
type MICRO_OP is (LOAD, STORE, ADD, SUB, MUL, DIV);
subtype ARITH_OP is MICRO_OP range ADD to DIV;
Examples of objects defined for these types are
signal CONTROL_A: MVL;
signal CLOCK: MVL range '0' to '1';
variable IC: MICRO_OP := STORE;
variable ALU: ARITH_OP;
Contd…
The predefined enumeration types of the language are
CHARACTER, BIT, BOOLEAN, and SEVERITY_LEVEL.
Values belonging to the type CHARACTER constitute the 128
characters of the ASCII character set. These values are called
character literals and are always written between two single
quotes (' ').
Examples are
'A', '_', '" (the single quote character itself),
'3' (the character literal 3)
The predefined type BIT has the literals '0' and 1’
BOOLEAN has the literals FALSE and TRUE
Type SEVERITY_LEVEL has the values NOTE, WARNING,
ERROR, and FAILURE
Integer Types
An integer type defines a type whose set of values fall within a
specified integer range.
Examples of integer type declarations are
type INDEX is range 0 to 15;
type WORD_LENGTH is range 31 downto 0;
subtype DATA_WORD is WORD_LENGTH range 15 downto
0;
type MY_WORD is range 4 to 6;
Some object declarations using these types are
constant MUX_ADDRESS: INDEX := 5;
signal DATA_BUS: DATA_WORD;
Floating Point Types
A floating point type has a set of values in a given range of real
numbers. Examples of floating point type declarations are
type TTL_VOLTAGE is range -5.5 to -1.4;
type REAL_DATA is range 0.0 to 31.9;
An example of an object declaration is
variable LENGTH: REAL_DATA range 0.0 to 15.9;
...
variable L1, L2, L3: REAL_DATA range 0.0 to 15.9;