VHDL - 确定2d阵列的范围

ale*_*vey 6 vhdl multidimensional-array

我有两个2D数组:

type array1x1D is array (0 to 10) of std_logic_vector(0 to 10); -- Array of arrays
type array2D is array (0 to 10, 0 to 10) of std_logic; -- Real 2D array
Run Code Online (Sandbox Code Playgroud)

如何访问std_logic_vectors前者的范围和后者的范围?我当然可以使用变量来跟踪它们的大小,但我宁愿避免这种情况.我试图使用GENERATE语句循环数组.

Mor*_*mer 9

array1x1D:

VHDL-2002:std_logic_vector(0 downto 10)如果要获取此部件的范围,则需要子类型,从而将类型拆分为:

subtype array1x1D_element is std_logic_vector(0 to 10);
type array1x1D is array (0 to 10) of array1x1D_element; -- Array of arrays
Run Code Online (Sandbox Code Playgroud)

那你可以做array1x1D_element'range.

VHDL-2008:使用添加的'element属性(可能是为了这个目的:-),然后写array1x1D'element'range.

array2D:

通过索引访问不同的维度'range,因此使用array2D'range(1)array2D'range(2).