Enumeration Type


Enumeration Type:

Enumeration type is used when it is represent values that are required for a specific operation. All values in an enumeration are user defined and cannot be any one from predefined types. These values may be character literals or named identifiers. For examples we can use values as ‘0’,’1’…..’a’,’b’,c’……..ADD, SUB, MUL…….

Note here that we cannot use the numeric values such as 0, 1 etc VHDL will give error during synthesis, but we are to use them as character literals as ‘0’ , ‘1’ .

Syntax:

TYPE TYPE_NAME is (value{,value});

BIT Type:

A bit type object can hold value ‘0’ or ‘1’. It is an enumerate type defined in the std library. The syntax of BIT type as defined in std library is :

TYPE BIT is (‘0’, ‘1’);

Here 0 and 1 represent numeric values which are also integers, but the values in enumerated type can only be characters so 0 and 1 are pu in single quote (‘ ’).

Character Type

All the 256 printable and non-printable characters including many special characters are defined in package standard. It is enumerated type having a listing of VHDL character codes. The definition of 256 characters of CHARACTER type is given below:

TYPE CHARACTER is (

NUL, SOH, STX, ETX, EOT, ENQ, ACK, BEL, BS, HT, LF, VT, FF, CR, SO, SI, DLE, DC1, DC2, DC3, DC4, NAK, SYN, ETB, CAN, EM, SUB, ESC, FSP, GSP, RSP, USP,  ‘ ‘, ‘!’, ‘”‘, ‘#’, ‘$’, ‘%’, ‘&’, ”’, ‘(‘, ‘)’, ‘*’, ‘+’, ‘,’, ‘-‘, ‘.’, ‘/’, ‘0’, ‘1’, ‘2’, ‘3’, ‘4’, ‘5’, ‘6’, ‘7’, ‘8’, ‘9’, ‘:’, ‘;’, ‘<‘, ‘=’, ‘>’, ‘?’, ‘@’, ‘A’, ‘B’, ‘C’, ‘D’, ‘E’, ‘F’, ‘G’, ‘H’, ‘I’, ‘J’, ‘K’, ‘L’, ‘M’, ‘N’, ‘O’, ‘P’, ‘Q’, ‘R’, ‘S’, ‘T’, ‘U’, ‘V’, ‘W’, ‘X’, ‘Y’, ‘Z’, ‘[‘, ‘\’, ‘]’, ‘^’, ‘_’, ‘`’, ‘a’, ‘b’, ‘c’, ‘d’, ‘e’, ‘f’, ‘g’, ‘h’, ‘i’,  ‘j’, ‘k’, ‘l’, ‘m’, ‘n’, ‘o’, ‘p’, ‘q’, ‘r’, ‘s’, ‘t’, ‘u’, ‘v’, ‘w’, ‘x’, ‘y’, ‘z’, ‘{‘, ‘|’, ‘}’, ‘~’, DEL, C128, C129, C130, C131, C132, C133, C134, C135, C136, C137, C138, C139, C140,C141,  C142, C143, C144,C145, C146, C147, C148, C149, C150, C151,……… ‘ý’, ‘þ’, ‘ÿ’);

Boolean Type

Boolean type data object can have a single value. Either ‘FALSE’ or ‘TRUE.’ That’s it. The logical operations that can be performed on Boolean variables are “and, or, not, nand, nor, xor.”

Declaration Syntax

Type BOOLEAN is (FALSE, TRUE);

Example of initializing a Boolean variable and a signal with and without an initial value:

a) Uninitalized

variable DONE: BOOLEAN;
signal enable: BOOLEAN;

b) Initialized value

variable DONE: BOOLEAN:= FALSE;
signal enable: BOOLEAN:= TRUE;

SEVERITY Type

Severity levels may be used during test benches and act as log of certain behaviour of the circuit to indicate if any error occurs and what is its severity. The different severity level are NOTE, WARNING, ERROR, FAILURE

type SEVERITY_LEVEL is (NOTE, WARNING, ERROR, FAILURE);

Default values of an uninitalized object

When we declare a data object without value, its default value is set to the leftmost listed value from the library.

For example, in library enumeration for different data type is given as :

type bit is (‘0’, ‘1’);

type SEVERITY_LEVEL is (NOTE, WARNING, ERROR, FAILURE);

Type BOOLEAN is (FALSE, TRUE);

TYPE CHARACTER is ( NUL, SOH, STX, ETX, EOT, ENQ, ACK, BEL, BS, HT, LF, VT, FF, CR, SO, SI, DLE, DC1, DC2, DC3, DC4, NAK, SYN, ETB, CAN, EM, SUB, ESC, FSP, GSP, RSP, USP, ‘ ‘, ‘!’, ‘”‘, ‘#’, ‘$’, ‘%’, ‘&’, ”’, ‘(‘, ‘)’, ‘*’, ‘+’, ‘,’, ‘-‘, ‘.’, ‘/’, ‘0’, ‘1’, ‘2’, ‘3’, ‘4’, ‘5’, ‘6’, ‘7’, ‘8’, ‘9’, ‘:’, ‘;’, ‘<‘, ‘=’, ‘>’, ‘?’, ‘@’, ‘A’, ‘B’, ‘C’, ‘D’, ‘E’, ‘F’, ‘G’, ‘H’, ‘I’, ‘J’, ‘K’, ‘L’, ‘M’, ‘N’, ‘O’, ‘P’, ‘Q’, ‘R’, ‘S’, ‘T’, ‘U’, ‘V’, ‘W’, ‘X’, ‘Y’, ‘Z’, ‘[‘, ‘\’, ‘]’, ‘^’, ‘_’, ‘`’, ‘a’, ‘b’, ‘c’, ‘d’, ‘e’, ‘f’, ‘g’, ‘h’, ‘i’,  ‘j’, ‘k’, ‘l’, ‘m’, ‘n’, ‘o’, ‘p’, ‘q’, ‘r’, ‘s’, ‘t’, ‘u’, ‘v’, ‘w’, ‘x’, ‘y’, ‘z’, ‘{‘, ‘|’, ‘}’, ‘~’, DEL, C128, C129, C130, C131, C132, C133, C134, C135, C136, C137, C138, C139, C140,C141, C142, C143, C144,C145, C146, C147, C148, C149, C150, C151,……… ‘ý’, ‘þ’,‘ÿ’);

So default value for data objects of datatype bit is ‘0’. And the same goes for all data types as mentioned in the table below

S. no.
Datatype
Default initial value
1.
Boolean
FALSE
2.
Bit
0
3.
Character
NULL
4.
Severity level
NOTE

Questions

  1. Write short note on along with the syntax and usage of each of the following.

    Enumeration type, Severity type, Character type, boolean type, bit type

  2. Differentiate between boolean and bit type
  3. Write the default values that may be assigned to an uninitialized object

error: Content is protected !!