3 VHDL Data-Types
3 VHDL Data-Types
Dr. Bharat Garg, Assistant Professor, TIET, Patiala FPGA Based System Design (PVL204) 1
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 type declaration.
Dr. Bharat Garg, Assistant Professor, TIET, Patiala FPGA Based System Design 2
DATA TYPES: CLASSIFICATION
The VHDL 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.
The possible types in VHDL: Type
1. Scalar types: Values belonging to
these types appear in a sequential Scalar type
Composite
Access type File
type
order.
2. Composite types: These are
composed of elements of a single Integer type Array
type (an array type) or elements
of different types (a record type). Floating
record
point
3. Access types: These provide
access to objects of a given type Enumeration
(via pointers). type
4. File types: These provides access
to objects that contain a sequence Physical type
of values of a given type.
Dr. Bharat Garg, Assistant Professor, TIET, Patiala FPGA Based System Design 3
SUBTYPES
Subtypes are useful for range checking and for imposing additional
constraints on types.
Dr. Bharat Garg, Assistant Professor, TIET, Patiala FPGA Based System Design 4
SCALAR TYPES
Dr. Bharat Garg, Assistant Professor, TIET, Patiala FPGA Based System Design 5
ENUMERATION TYPES
Dr. Bharat Garg, Assistant Professor, TIET, Patiala FPGA Based System Design 6
ENUMERATION TYPES (CONT.)
• The predefined type BIT has the literals '0' and ‘1'.
Dr. Bharat Garg, Assistant Professor, TIET, Patiala FPGA Based System Design 7
INTEGER TYPES
An integer type defines a type whose set of values fall within a specified
integer range.
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;
Dr. Bharat Garg, Assistant Professor, TIET, Patiala FPGA Based System Design 8
INTEGER SUBTYPES
When type natural is used in calculations, the calculations are carried out
using the base type, integer, and then checked to ensure that they fit the
subtype range of natural.
Dr. Bharat Garg, Assistant Professor, TIET, Patiala FPGA Based System Design 9
INTEGER TYPES
Dr. Bharat Garg, Assistant Professor, TIET, Patiala FPGA Based System Design 10
FLOATING POINT TYPES
A floating point type has a set of values in a given range of real numbers.
Dr. Bharat Garg, Assistant Professor, TIET, Patiala FPGA Based System Design 11
FLOATING POINT TYPES (CONT.)
The exponent represents a power of ten and the exponent value must be an
integer.
Dr. Bharat Garg, Assistant Professor, TIET, Patiala FPGA Based System Design 12
PHYSICAL TYPES
The physical data type is used for values which have associated units.
Therefore, a physical type contains values that represent measurement of
some physical quantity, like time, length, voltage, and current.
Values of this type are expressed as integer multiples of a base unit.
type CURRENT is range 0 to 1 E9
units
nA; -- (base unit) nano-ampere
uA = 1000 nA; -- micro-ampere
mA = 1000 μA; --milli-ampere
amp = 1000 mA; -- ampere
end units;
subtype FILTER_CURRENT is CURRENT range 10 μA to 5 mA;
The only predefined physical type is TIME and its range of base values,
which again is implementation dependent, must at least be -(231 - 1) to
+(231 - 1).
Dr. Bharat Garg, Assistant Professor, TIET, Patiala FPGA Based System Design 14
COMPOSITE DATE TYPES: (1) ARRAY
Declaration:
type data_bus is array (0 to 31) of BIT;
Variable x: data_bus;
Variable y: BIT;
Y := x(12);
Variable x: data_bus;
Variable y: BIT;
Y := x(12);
Dr. Bharat Garg, Assistant Professor, TIET, Patiala FPGA Based System Design 15
COMPOSITE DATE TYPES: (2) RECORD
Dr. Bharat Garg, Assistant Professor, TIET, Patiala FPGA Based System Design 16
ACCESS TYPE
The VHDL access type will not be discussed in detail in this module.
Dr. Bharat Garg, Assistant Professor, TIET, Patiala FPGA Based System Design 17
QUESTIONS?
Dr. Bharat Garg, Assistant Professor, TIET, Patiala FPGA Based System Design 18