我在VHDL中遇到了一个问题 . 我正在研究一个实体 . 我只包括库STD_LOGIC_1164和NUMERIC_STD . 我用两种不同的配置对两个信号A和B进行了比较:
定义(在相关的合适位置):
library IEEE;
use IEEE.STD_LOGIC_1164.ALL;
use IEEE.NUMERIC_STD.All;
signal A : STD_LOGIC_VECTOR(15 downto 0);
signal B : STD_LOGIC_VECTOR(63 downto 0);
第一配置:
report "A = " & integer'image(to_integer(unsigned(A)));
report "B(15 downto 0) = " & image(to_integer(unsigned(B(15 downto 0))));
if A=B(15 downto 0) then
report "Equal";
else
report "Un-Equal";
end if;
第二配置:
report "A = " & integer'image(to_integer(unsigned(A)));
report "B(15 downto 0) = " & image(to_integer(unsigned(B(15 downto 0))));
if unsigned(A)=unsigned(B(16 down to 0)) then
report "Equal";
else
report "Un-Equal";
end if;
如您所见,我在第二种情况下只包含了“无符号”的强制转换功能 . A和B(15 downto 0)相等时的模拟报告如下:
对于第一个声明:
A=1000
B(15 downto 0)=1000
Un-Equal
对于第二个声明:
A=1000
B(15 downto 0)=1000
Equal
所以第二个声明完美无缺 . 这是什么原因?此外,如果第一个语句错误,为什么模拟器不输出错误?