Files
IEEE754Adder/NaNCheck.vhd

46 lines
854 B
VHDL
Raw Permalink Normal View History

2019-08-17 19:22:19 +02:00
library IEEE;
use IEEE.STD_LOGIC_1164.ALL;
entity NaNCheck is
2019-08-29 15:12:25 +02:00
2019-08-17 19:22:19 +02:00
port(
2019-08-29 15:12:25 +02:00
X, Y : in std_logic_vector(31 downto 0);
IS_NAN : out std_logic
2019-08-17 19:22:19 +02:00
);
2019-08-29 15:12:25 +02:00
2019-08-17 19:22:19 +02:00
end NaNCheck;
architecture NaNCheckArch of NaNCheck is
2019-08-29 15:12:25 +02:00
2019-08-17 19:22:19 +02:00
component TypeCheck is
2019-08-29 15:12:25 +02:00
2019-08-17 19:22:19 +02:00
port(
2019-08-29 15:57:03 +02:00
N : in std_logic_vector(30 downto 0);
2019-08-29 15:12:25 +02:00
NAN, INF : out std_logic
2019-08-17 19:22:19 +02:00
);
2019-08-29 15:12:25 +02:00
2019-08-17 19:22:19 +02:00
end component;
2019-08-29 15:12:25 +02:00
signal X_NAN : std_logic;
signal X_INF : std_logic;
signal X_SIGN : std_logic;
signal Y_NAN : std_logic;
signal Y_INF : std_logic;
signal Y_SIGN : std_logic;
2019-08-17 19:22:19 +02:00
begin
2019-08-29 15:12:25 +02:00
2019-08-17 19:22:19 +02:00
xCheck: TypeCheck
2019-08-29 15:57:03 +02:00
port map (N => X(30 downto 0), NAN => X_NAN, INF => X_INF);
2019-08-29 15:12:25 +02:00
2019-08-17 19:22:19 +02:00
yCheck: TypeCheck
2019-08-29 15:57:03 +02:00
port map (N => Y(30 downto 0), NAN => Y_NAN, INF => Y_INF);
2019-08-17 19:22:19 +02:00
2019-08-29 15:12:25 +02:00
X_SIGN <= X(31);
Y_SIGN <= Y(31);
2019-08-17 19:22:19 +02:00
2019-08-29 15:12:25 +02:00
IS_NAN <= X_NAN or Y_NAN or (X_INF and X_SIGN and Y_INF and (not Y_SIGN)) or (X_INF and (not X_SIGN) and Y_INF and Y_SIGN);
2019-08-17 19:22:19 +02:00
end NaNCheckArch;