Files
IEEE754Adder/SpecialCasesCheck.vhd

44 lines
1004 B
VHDL
Raw Normal View History

2019-08-17 17:41:27 +02:00
library IEEE;
use IEEE.STD_LOGIC_1164.ALL;
2019-08-17 18:45:31 +02:00
entity SpecialCasesCheck is
2019-08-17 17:41:27 +02:00
port(
2019-08-17 18:45:31 +02:00
X, Y: in std_logic_vector(31 downto 0);
isNan, isZero: out std_logic
2019-08-17 17:41:27 +02:00
);
2019-08-17 18:45:31 +02:00
end SpecialCasesCheck;
2019-08-17 17:41:27 +02:00
2019-08-17 18:45:31 +02:00
architecture SpecialCasesCheckArch of SpecialCasesCheck is
component TypeCheck is
port(
N: in std_logic_vector(31 downto 0);
NaN, INF: out std_logic
);
end component;
2019-08-17 17:41:27 +02:00
2019-08-17 18:45:31 +02:00
signal xNan: std_logic;
signal xInf: std_logic;
signal xSign: std_logic;
signal yNan: std_logic;
signal yInf: std_logic;
signal ySign: std_logic;
signal isSameAbsValue: std_logic;
2019-08-17 17:41:27 +02:00
2019-08-17 18:45:31 +02:00
begin
xCheck: TypeCheck
port map (N => X, NaN => xNan, INF => xInf);
yCheck: TypeCheck
port map (N => Y, NaN => yNan, INF => yInf);
2019-08-17 17:41:27 +02:00
2019-08-17 18:45:31 +02:00
xSign <= X(31);
ySign <= Y(31);
isSameAbsValue <= '0'; -- TODO
isNan <= xNan or yNan or (xInf and xSign and yInf and (not ySign)) or (xInf and (not xSign) and yInf and ySign);
isZero <= (xSign and (not ySign) and isSameAbsValue) or ((not xSign) and ySign and isSameAbsValue);
end SpecialCasesCheckArch;
2019-08-17 17:41:27 +02:00