Programmable Logic/VHDL Data Types

This page is going to discuss some of the basic data types of VHDL.

Bit
0 and 1

Boolean
Boolean is another predefined type that has value FALSE and TRUE.

Integer
This integer values varies from -2147483648 to 2147483648.

Real
Real numbers ranging from �1.0E38 to þ1.0E38. Not synthesizable

Character
Single ASCII character or a string of such characters. Not synthesizable.

Physical
Used to inform physical quantities, like time, voltage, etc. Useful in simulations. Not synthesizable

Arrays
Arrays allow many identical data types to be created. These data types are accessed using a number called an index. An example array declaration is as follows:

type tIntegerArray is array ( 7 downto 0 ) of integer;

This declaration will create a new data type that is an array. This array will contain 8 integers with indexes of the numbers 7, 6, 5, ... 1, 0.

Once declared, an array can be used as any data type would: signal sBunchOfInts: tIntegerArray;

A individual element of an array can then be accessed with using : sBunchOfInts(2) <= 4;

Many newer synthesis tools will expand arrays into many signals with the array appended on the end of the signal name as a suffix. This helps organize repetitive VHDL code and allows std_logic_vectors to be used in for generate and for loops in VHDL code. This reduces the lines of code, and helps organize the code and make it more maintainable.

Records
Records allow one to group related data types together. It is analogous to a "struct" in C programming. Although records do not add any additional functionality to a module, they do assist in organizing code and making it more maintainable. Here is an example declaration of a record:

type rStatus is record read_failure: std_logic; write_failure: std_logic; failure_count: std_logic_vector( 7 downto 0 ); end record;

Once the record is declared, a port, signal, or variable can then be declared using the record as a type:

decoder_status : in rStatus;

signal sStatus:     rStatus; signal sStatus_next: rStatus;

variable vStatus: rStatus;

The record type can then be accessed using the ".": sStatus_next.failure_count <= sStatus.failure_count + x"01";

Although they used to be limited to test benches and other simulation only VHDL modules, many of the newer synthesis tools will correctly expand record types out into their individual parts. This allows the organizational and maintainability benefits of record types to be used in RTL and other synthesizable code.

ieee.std_logic_1164
The ieee.std_logic_1164 library was created to give a standard representation of digital circuit logic values. It defines the type std_logic and the various manipulations of std_logic (and, or, not, etc...). When writing VHDL for a synthesizable circuit, this is usually a required library.

ieee.numeric_std
ieee.numeric_std defines signed and unsigned types with their arithmetic. It is based on std_logic_vector, so it differs from integer.

ieee.std_logic_arith
this is not a standard library, despite being in the "ieee" library. Always use numeric_std instead.

More details here