7

我需要声明计数器要在二维数组中获取的值。另外,我如何从数组中选择元素并使用它们(比如将它们分配给另一个变量)我如何声明这个二维数组的元素?

type lutable is array (0 to 4, 0 to 63) of integer range 0 to 4000;
4

1 回答 1

13

在二维数组中,例如:

type lutable is array (0 to 4, 0 to 2) of integer range 0 to 4000;

signal sample_array: lutable;

您可以将元素分配给另一个信号,如下所示:

out_signal<=sample_array(in_a, in_b);

数组的内容可以声明为默认值(注意,并非所有综合工具都支持!):

signal sample_array: lutable:=( (1000, 2000, 3000),
                        (4000, 3000, 2000),
                        (100, 200, 300),
                        (1,2,3),
                        (5,6,7));

或在常量数组上,例如:

signal sample_array: lutable;
constant sample_array_init: lutable:=(  (1000, 2000, 3000),
                        (4000, 3000, 2000),
                        (100, 200, 300),
                        (1,2,3),
                        (5,6,7));
 ...
 sample_array<=sample_array_init;
 ...

或者,当然,逐个元素:

 sample_array(1,1)<=1000;
 ...
于 2013-06-18T06:30:42.727 回答