Warning: file_get_contents(/data/phpspider/zhask/data//catemap/3/arrays/14.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Arrays VHDL二维整数数组_Arrays_Vhdl - Fatal编程技术网

Arrays VHDL二维整数数组

Arrays VHDL二维整数数组,arrays,vhdl,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);

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

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;
IEEE库;
使用IEEE.STD_LOGIC_1164.ALL;
使用IEEE.STD_LOGIC_UNSIGNED.all;
使用IEEE.STD_LOGIC_ARITH.all;
--选择功能1
实体S1是
港口(
i:标准逻辑向量(5到0);
o:输出标准逻辑向量(3到0);
S1端;
S1的行为体系结构
类型矩阵是整数范围为0到15的数组(0到3,0到15);
常数m:矩阵=
((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));
信号行:标准逻辑向量(1到0);
信号列:标准逻辑向量(3到0);
开始

行您需要一个更好的语法检查器

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到3)称为“空范围”,它是合法的,但没有成员。所以初始化聚合中有太多的元素…

当你说它不能被模拟时,你是什么意思?它不跑吗?还是产生了无效的结果?我看到的一件事是,您将2D向量定义为0到3。这应该是3到0。我不知道当你倒转的时候会发生什么。谢谢。我应该用case语句来实现它。不一定。反转范围
(3向下到0)
或其方向
(0到3)
可能更容易。谢谢,我了解问题所在。错误消息的形式不是很清楚。“0到3”是如何有效的?这是合法的。。。从这个意义上说,这是有效的。“0 downto 0”(单个元素数组的范围)和“0 downto 1”(表示空范围)有合法的用途,因此没有基本的理由停在这里。