VHDL Programming

(C. Jardin) #1

154 Chapter Six


color’RIGHTOF (blue) returns purple.

color’LEFTOF(green) returns yellow.

reverse_color’RIGHTOF(blue) returns green.

reverse_color’LEFTOF(green) returns blue.

For ascending ranges, the following is true:

’SUCC(x) = ’RIGHTOF(x);
’PRED(x) = ’LEFTOF(x);

For descending ranges, the opposite is true:

’SUCC(x) = ’LEFTOF(x);
’PRED(x) = ’RIGHTOF(x);

What happens if the value passed to ’SUCC,’PRED, and so on is at the
limit of the type? For instance, for type color, what is the value of the
expression shown below:

y := red;
x := color’PRED(y);

The second expression causes a runtime error to be reported, because
a range constraint has been violated.

Function Array Attributes


Function array attributes return the bounds of array types. An operation
that requires accessing every location of an array can use these attributes
to find the bounds of the array.
The four kinds of function array attributes are:

array’LEFT(n), which returns the left bound of index range n

array’RIGHT(n), which returns the right bound of index range n

array’HIGH(n), which returns the upper bound of index range n

array’LOW(n), which returns the lower bound of index range n

These attributes are exactly like the value type attributes that were
discussed earlier, except that these attributes work with arrays.
For ascending ranges, the following is true:

array’LEFT = array’LOW
array’RIGHT = array’HIGH
Free download pdf