VHDL 中的索引数组
我有一个数组:
type offsets_type is array (4 downto 0) of std_logic_vector (4 downto 0);
signal av : offsets_type;
我想这样做,本质上是: av[addr] += 1;
但这行:
av(to_integer(unsigned(addr))) <= unsigned(av(to_integer(unsigned(addr))) + 1;
产生此错误:to_integer 在这种情况下不能有这样的操作数。
我也尝试过使用 conv_integer
,但这会给出错误的索引类型
错误。
有什么解决办法吗?谢谢。
I have an array:
type offsets_type is array (4 downto 0) of std_logic_vector (4 downto 0);
signal av : offsets_type;
I want to do this, essentially: av[addr] += 1;
But this line:
av(to_integer(unsigned(addr))) <= unsigned(av(to_integer(unsigned(addr))) + 1;
yields this error:to_integer can not have such operands in this context.
I've also tried using conv_integer
, but that gives Wrong type of index
as an error.
Any solutions? Thanks.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
您的代码中存在一些问题:
unsigned
,而左侧是std_logic_vector
addr
的类型,但您尚未与我们共享。如果您在类型定义中使用“unsigned”,则会更容易。通过这种方式,您可以表达位模式实际上是您想要在整数算术中使用的东西。
这将为您节省一些类型转换:
编辑:您确实使用了
ieee.numeric_std.all
,不是吗?There are a few problems in your code:
unsigned
, while the left-hand side isstd_logic_vector
addr
, but you have not shared that with us.It will be easier if you use "unsigned" in your type definitions. This way, you express that the bit pattern is actually something you want to use in integer arithmetic.
This will save you a few type conversions:
Edit: you did use
ieee.numeric_std.all
didn't you?