Types 在Modelsim上进行模拟时,类型与VHDL代码不匹配,尽管进行了彻底检查
我请求一些帮助,因为我完全陷入了我的VHDL项目,包括在NIOSII上实现笛卡尔到极坐标转换器。我所有的VHD文件都编译没有错误,但是当我想在Modelsim上模拟整个块时,我得到的是Types 在Modelsim上进行模拟时,类型与VHDL代码不匹配,尽管进行了彻底检查,types,simulation,vhdl,modelsim,Types,Simulation,Vhdl,Modelsim,我请求一些帮助,因为我完全陷入了我的VHDL项目,包括在NIOSII上实现笛卡尔到极坐标转换器。我所有的VHD文件都编译没有错误,但是当我想在Modelsim上模拟整个块时,我得到的是 # Loading work.counter(a) # ** Failure: (vsim-3807) Types do not match between component and entity for port "rn". # Time: 0 ps Iteration: 0 Instance: /
# Loading work.counter(a)
# ** Failure: (vsim-3807) Types do not match between component and entity for port "rn".
# Time: 0 ps Iteration: 0 Instance: /bench_conversor/uut/compt File: C:/Users/Sandjiv/Desktop/test_VHDL/counter.vhd Line: 23
# ** Failure: (vsim-3807) Types do not match between component and entity for port "thetan".
# Time: 0 ps Iteration: 0 Instance: /bench_conversor/uut/compt File: C:/Users/Sandjiv/Desktop/test_VHDL/counter.vhd Line: 24
# Fatal error in file C:/Users/Sandjiv/Desktop/test_VHDL/counter.vhd
# while elaborating region: /bench_conversor/uut/compt
# Load interrupted
这应该是很容易发现的错误,但我已经检查了一千次我的类型,它们似乎都匹配。以下是计数器、conversor(整个模块)及其工作台的代码。再一次,它们都是编译的,但我只在Modelsim上的模拟中得到这些错误
计数器.VHD
library ieee;
use ieee.std_logic_1164.all;
use IEEE.numeric_std.all;
use IEEE.std_logic_signed.all;
entity COUNTER is
port ( counter_en : in std_logic; --BESOINS???
rn : out signed(31 downto 0);
thetan : out signed(31 downto 0);
Etheta : out std_logic;
SD : in std_logic;
CLK,RESET : in std_logic);
end COUNTER;
architecture A of COUNTER is
signal theta : signed (31 downto 0);
signal r : signed (31 downto 0);
begin
process(CLK,RESET)
begin -- process
-- activities triggered by asynchronous reset (active high)
if RESET = '1' then
r <= "00000000000000000000000000000000";
theta <= "00000000000000000000000000000000";
Etheta <= '0';
-- activities triggered by rising edge of clock
elsif CLK'event and CLK = '1' then
if counter_en = '1' then
if SD = '1' then
if theta /= "000000000000000000000000000000010" then --VALUE THAT CAN BE CHANGED : THETA_MAX = 4095
Etheta <='0';
if r = "00000000000000000000000000001000" then --VALUE THAT CAN BE CHANGED : RMAX = 2000
r <= "00000000000000000000000000000000";
theta <= theta + "0000000000000000000000000000001";
else
r <= r + "00000000000000000000000000000001";
end if;
else
theta <= "00000000000000000000000000000001";
Etheta <= '1';
end if;
else
theta <= theta;
r <= r;
Etheta <= '0';
end if;
else
r <= "00000000000000000000000000000000";
theta <= "00000000000000000000000000000000";
Etheta <= '0';
end if;
end if;
rn <= r;
thetan <= theta;
end process;
end A;
长凳式旋转器
library ieee;
use ieee.std_logic_1164.all;
use IEEE.numeric_std.all;
use IEEE.std_logic_signed.all;
entity bench_conversor is
end bench_conversor;
architecture BEHAVIOR of bench_conversor is
component CONVERSOR
port(
CLK : in STD_LOGIC ;
RESET_Main : in STD_LOGIC ;
Conversor_en : in STD_LOGIC;
Conversor_end : out STD_LOGIC) ;
end component;
-- inputs
signal Conversor_en : std_logic;
signal clk : std_logic;
signal reset_main : std_logic;
-- output
signal Conversor_end : std_logic;
-- clock period definition
constant clk_period : time := 10 ns;
BEGIN
-- Instantiate the Unit Under Test (UUT)
uut: CONVERSOR PORT MAP (
CLK => CLK,
RESET_Main => Reset_main,
Conversor_en => Conversor_en,
Conversor_end => Conversor_end
);
-- Clock process definitions( clock with 50% duty cycle is generated here.
clk_process: process
begin
clk <= '0';
wait for clk_period/2; --for 5 ns signal is '0'
clk <= '1';
wait for clk_period/2; --for next 5 ns signal is '1'
end process;
-- stimulus process
stim_process : process
begin
wait for 50 ns;
conversor_en <= '0';
Reset_main <='1';
wait for 50 ns;
conversor_en <= '0';
Reset_main <='1';
wait; -- va attendre pour toujours
end process;
end BEHAVIOR;
ieee库;
使用ieee.std_logic_1164.all;
使用IEEE.numeric_std.all;
使用IEEE.std\u logic\u signed.all;
实体工作台会话是
端部工作台/反转器;
bench_conversor的架构行为是
组件转换器
港口(
CLK:标准逻辑中;
RESET_Main:在标准_逻辑中;
Conversor_en:标准逻辑;
Conversor_端:输出标准逻辑);
端部元件;
--投入
信号转换器:标准逻辑;
信号时钟:标准逻辑;
信号复位主电路:标准逻辑;
--输出
信号转换器端:标准逻辑;
--时钟周期定义
恒定时钟周期:时间=10纳秒;
开始
--实例化被测单元(UUT)
uut:CONVERSOR端口映射(
时钟=>CLK,
重置_Main=>重置_Main,
Conversor_en=>Conversor_en,
Conversor\u end=>Conversor\u end
);
--时钟过程定义(此处生成占空比为50%的时钟。
clk_流程:流程
开始
clk您使用的是不同的库,它们都有自己的、不兼容的std_逻辑实现
删除IEEE.std\u logic\u arith.all
(也可能是IEEE.std\u logic\u signed.all
)的include,并改为使用IEEE.numeric\u std.all
。后者是可移植的标准化版本,应该用于新设计
您可能需要转换一些代码(尚未全部查看),因为您将无法再使用std\u logic\u vector
进行算术运算-您应该使用UNSIGNED
和SIGNED
类型,而您似乎已经在对大多数信号进行运算了
use IEEE.numeric_std.all;
use IEEE.std_logic_signed.all;
啊
摆脱标准逻辑以及标准逻辑运算,只使用标准逻辑1164和数字标准
另一张海报几乎是对的——标准逻辑的定义是正确的(由_1164定义),但有符号和无符号的定义是不正确的(因为标准逻辑和标准逻辑都是有符号的)
但他对此太客气了…:-)
这里有很多不同的不兼容库,实体端口是一种签名类型,组件端口是另一种不兼容的签名类型
如果混合使用std_logic_vector和signed,则可能会有一些剩余错误,但如果只使用一个库,错误消息应该会变得更有意义
一个典型的混淆源是,如果编译器能在两个不同的库中找到像“+”这样的两个或多个定义,它会将它们都视为隐藏的,而不是随机选取其中一个,并可能得到您不期望的定义…再看几点代码:您使用了“conv_integer”从邪恶的软件包中:numeric_std将其称为“to_integer”(一个更好的名称,它告诉您转换的方向!)此外(在计数器中),重置赋值将更简单,如“r'0”);“并且比较为“if theta/=2 then…”我还好奇1600万位数据字在实践中的效果如何!非常感谢您的宝贵解释和重置提示;)当你学习自己的时候,你不会想太多的事情,比如说。。。我知道现在该做什么了!非常感谢,我认为不兼容库的问题会直接出现在编译时。因为它没有,我没有检查它更多的是。。。我现在知道该怎么做了:)它们在编译时没有出现,因为模块(a)对模块(b)一无所知,反之亦然。只有当它们被加载到Modelsim中并进行了详细阐述(考虑针对缺失的DLL启动C程序)时,您才会发现它们不匹配。。。
use IEEE.numeric_std.all;
use IEEE.std_logic_signed.all;