OpenCores
URL https://opencores.org/ocsvn/special_functions_unit/special_functions_unit/trunk

Subversion Repositories special_functions_unit

[/] [special_functions_unit/] [Open_source_SFU/] [rsqrt_vhdl/] [rsqrt_ieee.vhd] - Blame information for rev 4

Details | Compare with Previous | View Log

Line No. Rev Author Line
1 4 divadnauj
-- Log2 IEEE754 case detect
2
library ieee;
3
        use ieee.std_logic_1164.all;
4
        use ieee.numeric_std.all;
5
 
6
entity rsqrt_ieee is
7
        port      (i_data                                       : in    std_logic_vector(31 downto 0);
8
                                o_case                                  : out std_logic_vector(31 downto 0);
9
                                o_case_en                               : out std_logic);
10
end entity;
11
 
12
architecture rtl of rsqrt_ieee is
13
 
14
        signal s_sgn    : std_logic;
15
        signal s_exp    : std_logic_vector(7 downto 0);
16
        signal s_mantis: std_logic_vector(22 downto 0);
17
 
18
begin
19
        s_sgn   <= i_data(i_data'left);
20
        s_exp   <= i_data(i_data'left-1 downto 23);
21
        s_mantis        <= i_data(22 downto 0);
22
 
23
        process(s_sgn, s_exp, s_mantis)
24
        begin
25
 
26
                if s_sgn = '1' then
27
                        o_case_en       <= '1';
28
                        if s_exp = X"00" then
29
                                o_case <= X"FF800000";          -- -inf
30
                        else
31
                                o_case <= X"FFFFFFFF";          -- NaN
32
                        end if;
33
 
34
                else
35
                        if s_exp = X"00" then
36
                                o_case_en       <= '1';
37
                                o_case <= X"7F800000";          -- +inf
38
                        elsif s_exp = X"FF" then
39
                                o_case_en       <= '1';
40
                                if s_mantis = "00000000000000000000000" then
41
                                        o_case <= X"00000000";
42
                                else
43
                                        o_case <= X"FFFFFFFF"; -- NaN
44
                                end if;
45
                        else
46
                                o_case_en       <= '0';
47
                                o_case <= X"FFFFFFFF";          -- (dont care)
48
                        end if;
49
 
50
                end if;
51
 
52
        end process;
53
 
54
end rtl;
55
 

powered by: WebSVN 2.1.0

© copyright 1999-2022 OpenCores.org, equivalent to Oliscience, all rights reserved. OpenCores®, registered trademark.