arrays - VHDL 2D 整数数组

标签 arrays vhdl

谁能告诉我为什么不能模拟这段代码。行为检查语法是正确的。我正在尝试创建一个二维整数数组,它是恒定的。

library IEEE;
use IEEE.STD_LOGIC_1164.ALL;
use IEEE.STD_LOGIC_UNSIGNED.all;
use IEEE.STD_LOGIC_ARITH.all;

--selection function 1

entity S1 is
    Port ( 
    i : in  STD_LOGIC_VECTOR (5 downto 0);
    o : out  STD_LOGIC_VECTOR (3 downto 0));
end S1;

architecture Behavioral of S1 is

  type matrix is array(0 downto 3, 0 downto 15) of INTEGER range 0 to 15;
  constant m : matrix := 
      ((14, 4, 13, 1, 2, 15, 11, 8, 3, 10, 6, 12, 5, 9, 0, 7),
      (0, 15, 7, 4, 14, 2, 13, 1, 10, 6, 12, 11, 9, 5, 3, 8),
      (4, 1, 14, 8, 13, 6, 2, 11, 15, 12, 9, 7, 3, 10, 5, 0),
      (15, 12, 8, 2, 4, 9, 1, 7, 5, 11, 3, 14, 10, 0, 6, 13));

  signal row : STD_LOGIC_VECTOR(1 downto 0);
  signal col : STD_LOGIC_VECTOR(3 downto 0);

begin

    row <= i(5) & i(0);
    col <= i(4 downto 1);
    o <= conv_std_logic_vector(m(conv_integer(row), conv_integer(col)), 4);

end Behavioral;

解决方案:应该是(0 到 N)而不是(0 到 N)。错误信息不是很清楚。

最佳答案

你需要一个更好的语法检查器。

GHDL 报告:

ghdl -a --ieee=synopsys nullrange.vhd
nullrange.vhd:18:7: too many elements associated
nullrange.vhd:18:7: range length is beyond subtype length
nullrange.vhd:18:7: too many elements associated
nullrange.vhd:18:7: range length is beyond subtype length
nullrange.vhd:19:6: too many elements associated
nullrange.vhd:19:6: subaggregate length mismatch
nullrange.vhd:20:6: too many elements associated
nullrange.vhd:20:6: subaggregate length mismatch
nullrange.vhd:21:6: too many elements associated
nullrange.vhd:21:6: subaggregate length mismatch
nullrange.vhd:17:10: default value length does not match object type length
ghdl: compilation error

(0 downto 3) 被称为“空范围”,它是合法的但没有成员。所以初始化聚合中的元素太多了……

关于arrays - VHDL 2D 整数数组,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/21266555/

相关文章:

vector - 具有 32 位向量的 VHDL OR 逻辑

ruby-on-rails - Rails 3. 如何获得两个数组之间的差异?

c - 如何从C语言的字符串数组中删除特定的字符串?

c++ - 用分配的最后一个值覆盖数组?

output - 用于更改输出的 VHDL 内部信号 - 不起作用?

vhdl - 从同一语句分配两个信号

Javascript 字符串到嵌套数组

javascript - 数组出了什么问题?

c# - C# 上的 Vhdl 解析器

vhdl - 等效于 VHDL 中的#ifdef 用于模拟/综合分离?