gpt4 book ai didi

vhdl - 如何索引 vhdl std_logic_vector?

转载 作者:行者123 更新时间:2023-12-01 19:43:20 24 4
gpt4 key购买 nike

我有以下声明:

signal count:STD_LOGIC_VECTOR (3 downto 0);
signal txbuff:STD_LOGIC_VECTOR (7 downto 0);
  1. dout 是 std_logic 输出
  2. 我正在使用 IEEE.NUMERIC_STD.ALL

我想使用向量计数作为 txbuff 的索引。我尝试过的许多事情如下:

count<=std_logic_vector(unsigned(count)-1);
dout<=txbuff(unsigned(count));

但我收到以下错误:

Line 99. Wrong index type for txbuff.

最佳答案

您需要一个整数作为索引类型。 (或者对于其他数组,您可以使用任何离散类型,例如枚举)。

其他答案已经向您展示了如何使用类型转换函数到达那里:我会问,为什么不首先将“count”设置为整数,例如自然范围0到15?它会以同样的方式综合,并生成更清晰、更简单的代码。

关于vhdl - 如何索引 vhdl std_logic_vector?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/29660579/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com