源程序实体和testbench的COMPONENT不匹配
时间:10-02
整理:3721RD
点击:
如题。
单独在Modelsim中仿真结果是正确的
在Actel公司的Libero中检查无错,也可以综合,但启动Modelsim仿真时则显示如下错误:
** Failure: (vsim-3807) Types do not match between component and entity for port "num"
检查程序,两者是完全对应的,请各位大神解答,谢谢
-- edges_counter.vhd
----------------------
LIBRARY ieee;
USE ieee.std_logic_1164.all;
----------------------
ENTITY edges_counter IS
PORT(clk:IN STD_LOGIC;
num:BUFFER NATURAL RANGE 0 TO 100000
);
END edges_counter;
----------------------
ARCHITECTURE edges_counter OF edges_counter IS
SIGNAL a:NATURAL RANGE 0 TO 100000;
SIGNAL b:NATURAL RANGE 0 TO 100000;
BEGIN
PROCESS(clk)
VARIABLE temp1 : NATURAL RANGE 0 TO 100000;
BEGIN
IF(clk'EVENT AND clk='1')THEN
temp1 := temp1+1;
a<=temp1;
END IF;
END PROCESS;
PROCESS(clk)
VARIABLE temp2 : NATURAL RANGE 0 TO 100000;
BEGIN
IF(clk'EVENT AND clk='0')THEN
temp2 := temp2+1;
b<=temp2;
END IF;
END PROCESS;
num<=a+b;
END edges_counter;
---------------------------
-- testbench.vhd
---------------------
LIBRARY ieee;
USE ieee.std_logic_1164.all;
--USE ieee.numeric_std.ALL;
---------------------
ENTITY testbench IS
END testbench;
---------------------
ARCHITECTURE testbench OF testbench IS
COMPONENT edges_counter IS
PORT(clk:IN STD_LOGIC;
num:BUFFER NATURAL RANGE 0 TO 100000
);
END COMPONENT edges_counter;
SIGNAL clk:STD_LOGIC;
SIGNAL num:NATURAL RANGE 0 TO 100000;
BEGIN
SIMINSTANCE:edges_counter PORT MAP(clk,num);
clk_generationROCESS
BEGIN
clk<='1';
wait for 20 ns;
clk<='0';
wait for 20 ns;
END PROCESS clk_generation;
END testbench;
----------------------
单独在Modelsim中仿真结果是正确的
在Actel公司的Libero中检查无错,也可以综合,但启动Modelsim仿真时则显示如下错误:
** Failure: (vsim-3807) Types do not match between component and entity for port "num"
检查程序,两者是完全对应的,请各位大神解答,谢谢
-- edges_counter.vhd
----------------------
LIBRARY ieee;
USE ieee.std_logic_1164.all;
----------------------
ENTITY edges_counter IS
PORT(clk:IN STD_LOGIC;
num:BUFFER NATURAL RANGE 0 TO 100000
);
END edges_counter;
----------------------
ARCHITECTURE edges_counter OF edges_counter IS
SIGNAL a:NATURAL RANGE 0 TO 100000;
SIGNAL b:NATURAL RANGE 0 TO 100000;
BEGIN
PROCESS(clk)
VARIABLE temp1 : NATURAL RANGE 0 TO 100000;
BEGIN
IF(clk'EVENT AND clk='1')THEN
temp1 := temp1+1;
a<=temp1;
END IF;
END PROCESS;
PROCESS(clk)
VARIABLE temp2 : NATURAL RANGE 0 TO 100000;
BEGIN
IF(clk'EVENT AND clk='0')THEN
temp2 := temp2+1;
b<=temp2;
END IF;
END PROCESS;
num<=a+b;
END edges_counter;
---------------------------
-- testbench.vhd
---------------------
LIBRARY ieee;
USE ieee.std_logic_1164.all;
--USE ieee.numeric_std.ALL;
---------------------
ENTITY testbench IS
END testbench;
---------------------
ARCHITECTURE testbench OF testbench IS
COMPONENT edges_counter IS
PORT(clk:IN STD_LOGIC;
num:BUFFER NATURAL RANGE 0 TO 100000
);
END COMPONENT edges_counter;
SIGNAL clk:STD_LOGIC;
SIGNAL num:NATURAL RANGE 0 TO 100000;
BEGIN
SIMINSTANCE:edges_counter PORT MAP(clk,num);
clk_generationROCESS
BEGIN
clk<='1';
wait for 20 ns;
clk<='0';
wait for 20 ns;
END PROCESS clk_generation;
END testbench;
----------------------
num端口有问题,你现在用的是自然数,最好用std_logic_vector试试看。
I could not see any assertion to 'num' in test bench...
但是我所写的是计算时钟信号边缘的程序,如果用std_logic_vector来代替感觉不太好
在另外一个sram的程序中,我定义地址addr为integer型的也是出现同样的错误,给actel公司发邮件,他们说综合以后addr变成了
addr : out std_logic_vector(2 downto 0);
也是建议我将addr改成std_logic_vector,但这样如果要对addr进行加减还需要再申明std_logic_signed
是不是不能将端口定义为integer或natural型呢?因为即使定义了综合后也会被转换成std_logic_vector。
谢谢
这个没有关系吧,各种类型是可以相互转换的啊