我有一个数组:
type offsets_type is array (4 downto 0) of std_logic_vector (4 downto 0);
signal av : offsets_type;
Run Code Online (Sandbox Code Playgroud)
我想这样做,基本上:av[addr] += 1;
但这一行:
av(to_integer(unsigned(addr))) <= unsigned(av(to_integer(unsigned(addr))) + 1;
Run Code Online (Sandbox Code Playgroud)
产生此错误:
to_integer can not have such operands in this context.
我也试过使用conv_integer,但这给出Wrong type of index了一个错误.
有解决方案吗 谢谢.
Phi*_*ppe 13
您的代码中存在一些问题:
unsigned,而左侧则为std_logic_vectoraddr,但您尚未与我们分享.如果在类型定义中使用"unsigned",将会更容易.这样,您表示位模式实际上是您想要在整数运算中使用的东西.
type offsets_type is array (4 downto 0) of unsigned (4 downto 0);
signal av : offsets_type;
signal addr :unsigned(2 downto 0);
Run Code Online (Sandbox Code Playgroud)
这将为您节省一些类型转换:
av(to_integer(addr)) <= av(to_integer(addr)) + "1";
Run Code Online (Sandbox Code Playgroud)
编辑:你确实使用过ieee.numeric_std.all不是吗?