Data Types 91
value := ((e1, e2,..., en), --E1
value := ((e1, e2,..., en), --E2
value := (((......
value := (((......
value := ((e1, e2,..., en) ) --En
In the statement part of the romexample, there is one conditional signal
assignment statement. The output port data is assigned a value based on
the value of the csinput. The data type of the value assigned to port data
must be of type data_outbecause port data has a type of data_out.By
addressing the rom_dataconstant with an integer value, a data type of
data_outis returned.
A single value can be returned from the array of arrays by using the
following syntax:
bit_value := rom_data(addr) (bit_index);
The first index (addr) returns a value with a data type of data_out. The
second index (bit_index) indexes the data_outtype and returns a single
element of the array.
MULTIDIMENSIONAL ARRAYS
The constant rom_datain the romexample was represented using an
array of arrays. Following is another method for representing the data
with a multidimensional array:
TYPE mem_data_md IS ARRAY(0 TO memsize, 0 TO width) OF
std_logic;
CONSTANT rom_data_md : mem_data :=
( ( ‘ 0 ’, ‘ 0 ’, ‘ 0 ’, ‘ 0 ’),
( ( ‘ 0 ’, ‘ 0 ’, ‘ 0 ’, ‘ 1 ’),
( ( ‘ 0 ’, ‘ 0 ’, ‘ 1 ’, ‘ 0 ’),
( ( ‘ 0 ’, ‘ 0 ’, ‘ 1 ’, ‘ 1 ’),
( ( ‘ 0 ’, ‘ 1 ’, ‘ 0 ’, ‘ 0 ’),
( ( ‘ 0 ’, ‘ 1 ’, ‘ 0 ’, ‘ 1 ’),
( ( ‘ 0 ’, ‘ 1 ’, ‘ 1 ’, ‘ 0 ’),
(( ‘ 0 ’, ‘ 1 ’, ‘ 1 ’, ‘ 1 ’) );
The declaration shown here declares a two-dimensional array type
mem_data_md. When constant rom_data_mdis declared using this type, the
initialization syntax remains the same, but the method of accessing an el-
ement of the array is different. In the following example, a single element
of the array is accessed:
X := rom_data_md(3, 3);