我在 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
所以第二个语句完美地工作。这是什么原因?另外,如果第一个语句是错误的,为什么模拟器不输出错误?