【发布时间】:2017-06-14 09:38:04
【问题描述】:
VHDL-2008 定义
type integer_vector is array (natural range <>) of integer
它可以用来创建不受约束的整数数组就好了:
signal sUnconsrainedIntA : integer_vector(0 to 1) := (others => 0);
但是,如何声明约束整数数组,例如:
-- does not work:
-- signal sConstrainedTestIntA : integer_vector(0 to 1) range 0 to 3 := (others => 0);
-- ** Error: filetest.vhd(65): Range constraints cannot be applied to array types.
-- ** Error: filetest.vhd(65): Range expression is type Integer; expecting type std.STANDARD.INTEGER_VECTOR
-- What you can do is:
type my_int_array is array (natural range <>) of integer range 0 to 3;
signal sConstrainedIntA : my_int_array(0 to 1) := (others => 0);
有没有办法在没有自定义类型的情况下约束数组中的整数?
【问题讨论】:
-
我猜不是。正如您所写,
integer_vector是一个具有完整范围的整数数组。如果你想改变它,你必须自己定义一个不同的类型。 -
如何定义一个自定义类型,然后可以在以后进行约束,例如类型 slv_array 是 std_logic_vector 的数组(自然范围 );信号 sSlvA : slv_array(0 to 1)(1 downto 0) := (others => (others => '0'));
-
我不确定 VHDL-2008,但在此之前,你不能这样做。而且我想VHDL-2008仍然不可能。
-
类型
integer是受约束类型(标量类型、数值类型),而std_logic_vector是枚举类型(std_logic)的无约束数组类型。
标签: vhdl