VHDL:无法将任何内容分配给整数数组输出端口
我无法为定义为整数数组的输出端口分配任何值。在行为模拟中,我得到的输出是“uuu”。 我尝试使用8位整数数组作为输入,排序并输出到另一个8位整数数组。 但是数组可以是任意长度的。 我计划使用计数排序。但在这里,我无法通过基本的输出数组分配。 代码有什么问题 设计规范:VHDL:无法将任何内容分配给整数数组输出端口,vhdl,Vhdl,我无法为定义为整数数组的输出端口分配任何值。在行为模拟中,我得到的输出是“uuu”。 我尝试使用8位整数数组作为输入,排序并输出到另一个8位整数数组。 但是数组可以是任意长度的。 我计划使用计数排序。但在这里,我无法通过基本的输出数组分配。 代码有什么问题 设计规范: library ieee; use ieee.std_logic_1164.all; package sorting_pkg is type intarray is array(natural range <>
library ieee;
use ieee.std_logic_1164.all;
package sorting_pkg is
type intarray is array(natural range <>) of std_logic_vector(7 downto 0);
end package;
library ieee;
use ieee.std_logic_1164.all;
library work;
use work.sorting_pkg.all;
use IEEE.NUMERIC_STD.all;
use ieee.std_logic_unsigned.all;
entity HWsort is
generic (
N : integer:= 10 );
port(
inStream : in intarray(0 to N-1);
outStream : out intarray(0 to N-1)
);
end HWsort;
architecture Behavioral of HWsort is
begin
outStream <= inStream;
end Behavioral;
ieee库;
使用ieee.std_logic_1164.all;
包裹分拣包装为
intarray类型是标准逻辑向量(7到0)的数组(自然范围);
端包装;
图书馆ieee;
使用ieee.std_logic_1164.all;
图书馆工作;
使用work.sorting_pkg.all;
使用IEEE.NUMERIC_STD.all;
使用ieee.std_logic_unsigned.all;
实体排序是
一般的(
N:整数:=10);
港口(
河道内:河道内(0至N-1);
外流:外流入列(0到N-1)
);
结束排序;
HWsort的行为体系结构
开始
外扩-内扩,外扩=>外扩);
模拟tb:过程
开始
等待100ns;
河道内(0至9)x“22”,
1=>x“12”,
2=>x“1A”,
3=>x“4A”,
4=>x“02”,
5=>x“5B”,
6=>x“66”,
7=>x“09”,
8=>x“35”,
9=>x“71”);
等待
结束过程;
结束行为;
这是您的代码,根据标准编辑和直接引用实体HWsort
的要求,对未使用的软件包进行少量更正,并在100
和ns
之间留出空间
library ieee;
use ieee.std_logic_1164.all;
package sorting_pkg is
type intarray is array(natural range <>) of std_logic_vector(7 downto 0);
end package;
use work.sorting_pkg.all;
entity HWsort is
generic (
N : integer:= 10 );
port(
inStream : in intarray(0 to N-1);
outStream : out intarray(0 to N-1)
);
end HWsort;
architecture Behavioral of HWsort is begin
outStream <= inStream;
end Behavioral;
entity tb_Sort is end tb_Sort;
library ieee;
use ieee.std_logic_1164.all;
use work.sorting_pkg.all;
architecture Behavioral of tb_Sort is
signal inStream : intarray(0 to 9);
signal outStream : intarray(0 to 9);
begin
uut: entity work.HWsort port map (inStream => inStream, outStream => outStream);
sim_tb:process begin
wait for 100 ns;
inStream <= (
0 => x"22",
1 => x"12",
2 => x"1A",
3 => x"4A",
4 => x"02",
5 => x"5B",
6 => x"66",
7 => x"09",
8 => x"35",
9 => x"71");
wait;
end process;
end Behavioral;
ieee库;
使用ieee.std_logic_1164.all;
包裹分拣包装为
intarray类型是标准逻辑向量(7到0)的数组(自然范围);
端包装;
使用work.sorting_pkg.all;
实体排序是
一般的(
N:整数:=10);
港口(
河道内:河道内(0至N-1);
外流:外流入列(0到N-1)
);
结束排序;
HWsort的行为体系结构已开始
外扩-内扩,外扩=>外扩);
sim_tb:进程开始
等待100纳秒;
内流x“22”,
1=>x“12”,
2=>x“1A”,
3=>x“4A”,
4=>x“02”,
5=>x“5B”,
6=>x“66”,
7=>x“09”,
8=>x“35”,
9=>x“71”);
等待
结束过程;
结束行为;
这是模拟200 ns后的输出:
关于你的问题:你的代码没有问题。
编辑除了
HWsort
的组件声明与实体不同外,如:缺少泛型,如提到的user1155120。为什么有两个包排序副本\u pkg是您的代码?两个实体使用相同的intarray类型声明,即使看起来相同,每个声明也是唯一的。uut在tb_排序中与您提供的内容不绑定。组件名称和实例名称匹配,但与HWsort不匹配(HWsort也有一个不带默认值的整数generic,并且在中没有rst端口模式)。在细化过程中提供a和任何实际的警告或错误消息。实例化HWSort而不是排序,分析一次sorting_pkg,证明N的通用值,在波形转储中显示分配到instream和EXTREAM后,运行进程更长时间。注:rst不用于HWSort。嘿,感谢您指出这些错误,并按照您的建议进行了更改。您可以检查上面更新的代码。但是,我无法消除设计的无限性。请您详细说明这些包需要进行哪些分析。您会注意到@JHBonarius在组件实例化中使用了一个实体。您的组件声明与HWSort的实体声明不匹配。将泛型子句添加到组件声明中。组件声明和实体声明必须匹配。除了他提到的数字文本和标识符(单位名称ns)之间的空格外,您在问题中没有使用tb_排序中未签名的包numeric_std、std_logic_。
library ieee;
use ieee.std_logic_1164.all;
package sorting_pkg is
type intarray is array(natural range <>) of std_logic_vector(7 downto 0);
end package;
use work.sorting_pkg.all;
entity HWsort is
generic (
N : integer:= 10 );
port(
inStream : in intarray(0 to N-1);
outStream : out intarray(0 to N-1)
);
end HWsort;
architecture Behavioral of HWsort is begin
outStream <= inStream;
end Behavioral;
entity tb_Sort is end tb_Sort;
library ieee;
use ieee.std_logic_1164.all;
use work.sorting_pkg.all;
architecture Behavioral of tb_Sort is
signal inStream : intarray(0 to 9);
signal outStream : intarray(0 to 9);
begin
uut: entity work.HWsort port map (inStream => inStream, outStream => outStream);
sim_tb:process begin
wait for 100 ns;
inStream <= (
0 => x"22",
1 => x"12",
2 => x"1A",
3 => x"4A",
4 => x"02",
5 => x"5B",
6 => x"66",
7 => x"09",
8 => x"35",
9 => x"71");
wait;
end process;
end Behavioral;