It is possible to write more general VHDL codes using attributes. The desired properties of objects or types are then determined by the attributes during the elaboration phase. Attributes can be classified into the following categories:
Syntax:
The bounds of a range
...'left[(n)] left bound (of the nth dimension)
...'right[(n)]right bound (of the nth dimension)
...'high[(n)] upper bound (of the nth dimension)
...'low[(n)] lower bound (of the nth dimension)
Length of arrays
...'length[(n)]number of elements (in the nth dimension)
Ranges
...'range[(n)]range ..to/downto.. (of the nth dimension)
...'reverse_range[(n)]range ..downto/to.. (of the nth dimension)
Example:
The bounds of ranges
type T_RAM_DAT is array (0 to 511) of integer;
variable RAM_DAT: T_RAM_DAT;
...
for I in RAM_DAT'low to RAM_DAT'high loop
...
The bounds of ranges for a multidimensional array
variable MEM (0 to 15, 7 downto 0) of MEM_DAT;
...
MEM'left(1) is 0
MEM'right(1) is 15
MEM'left(2) is 7
MEM'right(2) is 0
MEM'low(2) is 0
MEM'high(2) is 7
Length of arrays
type BIT4 is array (0 to 3) of BIT;
type BIT_STRANGE is array (10 to 30) of BIT;
...
BIT4'length is 4
BIT_STRANGE'length is 21
Ranges
function VEC2INT (INVEC: bit_vector) return integer is
...
begin
for I in INVEC'range loop
...
Syntax:
Values
type'succ(value)Value of the parameter whose position
is one larger than the position of value
type'pred(value)Value of the parameter whose position
is one less than the position of value
type'leftof(value)Value of the parameter that is to the
left of value
type'rightof(value)Value of the parameter that is to the
right of value
Position information
type'pos(value)Position of value
type'val(position)Value of position
Base type
type'base Base type to the subtype type
Example:
type COLOR is (RED, BLUE, GREEN, YELLOW, BROWN, BLACK);
subtype TLCOL is COLOR range RED to GREEN;
...
COLOR'low is RED
COLOR'succ(RED) is BLUE
TLCOL'base'right is BLACK
COLOR'base'left is RED
TLCOL'base'succ(GREEN) is YELLOW
Several characteristics of signals can be tested by signal attributes. For example, whether a signal changed its value or has been stable for a certain amount of time can be determined by these attributes.
The predefined attributes for signals are explained in Section
7.4 on page .