# Programmable Logic/VHDL Data Types

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

## std.standard
### 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

## User defined types
### 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:
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:
A individual element of an array can then be accessed with using:
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:
Once the record is declared, a port, signal, or variable can then be declared using the record as a type:
The record type can then be accessed using the ".":
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.

### Subtypes
## Common Libraries
### 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.

#### Defined Data Types

| Name | Range | Synthesizable values | Description |
| std_logic | 'U' - Uninitialized 'X' - Forcing Unknown '0' - Forcing 0 '1' - Forcing 1 'Z' - High Impedance 'W' - Weak Unknown 'L' - Weak 0 'H' - Weak '1' '-' - Don't care | '1', '0', 'Z' | std_logic is an enumeration that represents the different possible states of a signal in a logic circuit |
| std_logic_vector | A string of std_logic such as "01001XZ" | Strings containing '1', '0', and/or 'Z' | std_logic_vector is a string of std_logic values. It allows the easy representation of buses and other multiple signal values |

### 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