用于模拟的具有动态长度的数组

Array with dynamic length for simulation

在 VHDL 中,有没有办法为仿真提供一个动态大小的数组?

我想将其用作列表,即测试台重复将值附加到末尾,然后遍历列表。数组的长度不是静态已知的。

VUnit (https://github.com/VUnit/vunit/tree/master/vunit/vhdl/array) provides the functionality you're looking for. It provides a protected type array_t which has a method append that does the dynamic sizing. Here is some code from the testbench for this utility (https://github.com/VUnit/vunit/blob/master/vunit/vhdl/array/test/tb_array.vhd) 的数组实用程序,体现了 append 方法

variable arr : array_t;
...
arr.init;
...
arr.append(11);
check_equal(arr.length, 1);
check_equal(arr.get(0), 11);

arr.append(7);
check_equal(arr.length, 2);
check_equal(arr.get(1), 7);