The way they are written gives them a spatial position. The 7 is left of the 3, which is left of the 5, and so on. These can be easily given a position by indicating the position of the first and the last. Let's say the 4 is at position five and the 2 is at position nine, then the number at position seven must be 3. This is how an array definition is given. The position in an array of values is called an {\it index} and the range the index can have (i.e., the position of the first and last values) is called the {\it index range} given by an {\it index constraint}. An example of an array definition is \begin{verbatim} type memory is array (range 0 to 65535) of integer;The array type is the ideal representation of a memory circuit because memory is a collection of values that are referenced by position. The type definition gives the name of the type, indicates it is an array of integer values and specifies that there are 65536 values numbered from 0 to 65535. This array type is called a one-dimensional array, since conceptually it could be thought of as 65526 values placed in particular positions on a line.
A type definition can also use positions with greater than one dimension. For example, the truth table of the xor function of two variables can be thought of as a two-dimensional array of 0 and 1 values. The index of a two-dimensional array has two values, one for the position in one direction and the other for the position in the other direction. We might write the two dimensional array of the xor function as
1 1 | 0 |
= | 0 (0,1) | = | 1 (1,0) | = | 1 (1,1) | = | 0 |
The grammar rule for an array definition is: There are two aspects of this rule that have not been discussed yet, the unconstrained array type and using a subtype for a range. When a subtype is indicated for a range then the range of that subtype will be the range of the index.
An unconstrained array type is an array type that has an unspecified range of values in its index. An object can not be declared an unconstrained array type because there is no way to know its size. However, the unconstrained array type can be used to declare subtypes that constrain the array by specifying the ranges of its index. Bit_vector and string are built-in unconstrained array types. Their definition is Vectors of different lengths can be declared by using a subtype to constrain the bit_vector type. The section on subtypes discusses why it is useful to use a subtype for this purpose instead of creating different array types with different lengths.