Predefined Attributes 149
len3 := t_4valmd’LENGTH(1); -- returns 4
len4 := t_4valmd’LENGTH(2); -- returns 4
END PROCESS;
Type t_4valX1is a four-element array of type t_4val. The range of
the array is specified using the predefined attributes ’LOWand ’HIGHof the
t_4val type. Assigning the length of type t_4valX1 to len1returns
the value 4, the number of elements in array type t_4valX1. The assign-
ment to len2also returns the value 4, because the range of type t_valX2
is from ’LOWto ’HIGHof element type t_4valX1.
The assignments to len3and len4make use of a multidimensional
array type t_4valmd. Because a multidimensional array has more than
one range, an argument is used to specify a particular range. The range
defaults to the first range, if none is specified. In the type t_4valmd
example, the designer can pick the first or second range, because there
are only two to choose from. To pick a range, the argument passed to the
attribute specifies the number of the range starting at 1. An argument
value of 1 picks the first range, an argument value of 2 picks the second
range, and so on.
The assignment to len3in the previous example passed in the value 1
to pick the first range. The first range is from t_4val’LOWto t_4val’HIGH,
or four entries. The second range is exactly the same as the first; there-
fore, both assignments return 4 as the length of the array.
If the argument to ’LENGTHis not specified, it defaults to 1. This was the
case in the first examples of ’LENGTH, when no argument was specified.
There was only one range, so the correct range was selected.
Value Block Attributes
There are two attributes that form the set of attributes that work with
blocks and architectures. Attributes ’STRUCTUREand ’BEHAVIORreturn
information about how a block in a design is modeled. Attribute ’BEHAVIOR
returns true if the block specified by the block label, or architecture
specified by the architecture name, contains no component instantiation
statements. Attribute ’STRUCTUREreturns true if the block or architec-
ture contains only component instantiation statements and/or passive
processes.
The following two examples illustrate how these attributes work. The
first example contains only structural VHDL: