在 vhdl 中重置整数数组的最佳方法是什么?

What is the best way to reset an array of integers in vhdl?

我是 vhdl 的新手,我没有找到解决这个看似微不足道的问题的好方法。我正在寻找一种重置整数数组的好方法。

type integer_vector is array (0 to N) of integer;
...
process(...)
variable tab: integer_vector;
...
if reset = '1' then
 tab := ?? 

是否有类似于 tab <= (others=>(others=>'0')) 的东西适用于 std_logic_vector?我不想使用 for 循环,因为综合不支持这个。

当数组的元素为integer时,可以:

tab := (others => 0);

您示例中的内部 (others=>'0')'0' 分配给数组的每个 std_logic_vector 中的所有 std_logic 元素,因此当元素为 integer ,这简直就是0,如上图

Morten 的代码看起来不错,所以请说明报告此问题的综合工具和版本。一些综合工具可能太原始而无法接受此代码:在其他情况下,可能会有综合选项来打开必要的行为。 (还要检查你是否严格按照他的指示进行操作:(others => 0); 要求整数,而 (others => '0'); 要求位)。

但是,对于合成,请注意两点:
(a) 范围整数会更好;它试图生成 32 位整数(尽管合成的后期阶段可能 trim 它们)

举个例子。

subtype my_int is natural range 0 to 99; -- needs 7 bits
type my_int_vector is array ( 0 to N) of my_int;

可能会产生更小的硬件,并且肯定会让 reader 清楚地知道需要更小的整数。

(b) 为了在一次操作中重置整个数组,它需要在寄存器中实现全部,这会产生巨大的硬件。

如果你安排每个时钟周期重置一个位置(通常在状态机中),用一个计数器索引遍历整个数组,那么数组可以实现为块内存,节省很多space.