如何在VHDL中声明二维数组及其元素

时间:2013-06-18 05:03:56

标签: vhdl

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

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

1 个答案:

答案 0 :(得分:12)

在2D数组中,例如:

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;
 ...