Aggiunto controllo risultato NaN

This commit is contained in:
2019-08-17 18:45:31 +02:00
parent a1b9650580
commit 47cc74e0d0
18 changed files with 380 additions and 109 deletions

View File

@@ -1,59 +1,43 @@
library IEEE;
use IEEE.STD_LOGIC_1164.ALL;
entity TypeCheck is
entity SpecialCasesCheck is
port(
N: in std_logic_vector(31 downto 0);
NaN, INF: out std_logic
X, Y: in std_logic_vector(31 downto 0);
isNan, isZero: out std_logic
);
end TypeCheck;
end SpecialCasesCheck;
architecture TypeCheckArch of TypeCheck is
signal G_Bus: std_logic_vector(7 downto 0);
signal T_Bus: std_logic_vector(22 downto 0);
signal G: std_logic := '1';
signal T: std_logic := '0';
architecture SpecialCasesCheckArch of SpecialCasesCheck is
component TypeCheck is
port(
N: in std_logic_vector(31 downto 0);
NaN, INF: out std_logic
);
end component;
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;
begin
G_Bus <= N(30 downto 23);
T_Bus <= N(22 downto 0);
xCheck: TypeCheck
port map (N => X, NaN => xNan, INF => xInf);
yCheck: TypeCheck
port map (N => Y, NaN => yNan, INF => yInf);
xSign <= X(31);
ySign <= Y(31);
G_compute: process (G_Bus)
variable G_tmp: std_logic;
begin
G_tmp := '1';
for i in G_Bus'range loop
G_tmp := G_tmp and G_Bus(i);
end loop;
G <= G_tmp;
end process;
isSameAbsValue <= '0'; -- TODO
T_compute: process (T_Bus)
variable T_tmp: std_logic;
begin
T_tmp := '0';
for i in T_Bus'range loop
T_tmp := T_tmp or T_Bus(i);
end loop;
T <= T_tmp;
end process;
NaN <= G and T;
INF <= G and (not T);
end TypeCheckArch;
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;
--entity SpecialCasesCheck is
-- port(
-- X, Y: in std_logic_vector(31 downto 0);
-- isNan, isZero: out std_logic
-- );
--end SpecialCasesCheck;
--
--
--architecture SpecialCasesCheckArch of SpecialCasesCheck is
--
--begin
--
--end SpecialCasesCheckArch;