![]() |
![]() |
IEEE VHDL describes two site-specific packages, each containing a standard set of types and operations; the STANDARD package and the TEXTIO package.
The STANDARD package of data types is included in all VHDL source files by an implicit use clause. The TEXTIO package defines types and operations for communication with a standard programming environment (terminal and file I/O). You do not need this package for synthesis, therefore, Foundation Express does not support it.
The Foundation Express implementation of the STANDARD package is illustrated in the following example. This STANDARD package is a subset of the IEEE VHDL STANDARD package. Differences are described in the Unsupported Data Types section of this chapter.
package STANDARD is
type BOOLEAN is (FALSE, TRUE);
type BIT is ('0', '1');
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);
type INTEGER is range -2147483647 to 2147483647;
subtype NATURAL is INTEGER range 0 to 2147483647;
subtype POSITIVE is INTEGER range 1 to 2147483647;
type STRING is array (POSITIVE range <>)
of CHARACTER;
type BIT_VECTOR is array (NATURAL range <>)
of BIT;
end STANDARD;
The BOOLEAN data type is actually an enumerated type with two values, FALSE and TRUE, where FALSE < TRUE. Logical functions such as equality (=) and comparison (<) functions return a BOOLEAN value.
Convert a BIT value to a BOOLEAN value as follows.
BOOLEAN_VAR := (BIT_VAR = '1');
The BIT data type represents a binary value as one of two characters, 0 or 1. Logical operations, such as AND, can take and return BIT values.
Convert a BOOLEAN value to a BIT value as follows.
if (BOOLEAN_VAR) then
BIT_VAR := '1';
else
BIT_VAR := '0';
end if;
The CHARACTER data type enumerates the ASCII character set. Nonprinting characters are represented by a three-letter name, such as NUL for the null character. Printable characters are represented by themselves, in single quotation marks, as follows.
variable CHARACTER_VAR: CHARACTER;
. . .
CHARACTER_VAR := 'A';
The INTEGER data type represents positive and negative whole numbers.
The NATURAL data type is a subtype of INTEGER that is used to represent natural (nonnegative) numbers.
The POSITIVE data type is a subtype of INTEGER that is used to represent positive (nonzero and nonnegative) numbers.
The STRING data type is an unconstrained array of CHARACTER data types. A STRING value is enclosed in double quotation marks, as follows.
variable STRING_VAR: STRING(1 to 7);
. . .
STRING_VAR := "Rosebud";
The BIT_VECTOR data type represents an array of BIT values.