The following coding examples demonstrate the uses of multi-dimensional array signals and variables in assignments.
1.Make the following declarations:
subtype WORD8 is STD_LOGIC_VECTOR (7 downto 0);
type TAB05 is array (4 downto 0) of WORD8;
type TAB03 is array (2 downto 0) of TAB05;
signal WORD_A : WORD8;
signal TAB_A, TAB_B : TAB05;
signal TAB_C, TAB_D : TAB03;
constant CNST_A : TAB03 := (
("00000000","01000001","01000010","10000011","00001100"),
("00100000","00100001","00101010","10100011","00101100"),
("01000010","01000010","01000100","01000111","01000100"));
2.You can now specify:
°A multi-dimensional array signal or variable:
TAB_A <= TAB_B; TAB_C <= TAB_D; TAB_C <= CNST_A;
°An index of one array:
TAB_A (5) <= WORD_A; TAB_C (1) <= TAB_A;
°Indexes of the maximum number of dimensions:
TAB_A (5) (0) <= ’1’; TAB_C (2) (5) (0) <= ’0’
°A slice of the first array
TAB_A (4 downto 1) <= TAB_B (3 downto 0);
°An index of a higher level array and a slice of a lower level array:
TAB_C (2) (5) (3 downto 0) <= TAB_B (3) (4 downto 1); TAB_D (0) (4) (2 downto 0)
\\ <= CNST_A (5 downto 3)
3.Add the following declaration:
subtype MATRIX15 is array(4 downto 0, 2 downto 0) of STD_LOGIC_VECTOR (7 downto 0);
signal MATRIX_A : MATRIX15;
4.You can now specify:
°A multi-dimensional array signal or variable:
MATRIXA <= CNST_A
°An index of one row of the array:
MATRIXA (5) <= TAB_A;
°Indexes of the maximum number of dimensions
MATRIXA (5,0) (0) <= ’1’;
Note: Indexes can be variable.