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

Subversion Repositories special_functions_unit

[/] [special_functions_unit/] [Open_source_SFU/] [exp2_vhdl/] [parts/] [exp2_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 exp2_ieee is
7
        generic (BX                                             :               natural := 7);
8
        port      (i_data                                       : in    std_logic_vector(31 downto 0);
9
                                o_case                                  : out std_logic_vector(31 downto 0);
10
                                o_case_en                               : out std_logic);
11
end entity;
12
 
13
architecture rtl of exp2_ieee is
14
 
15
        signal s_sgn    : std_logic;
16
        signal s_exp    : std_logic_vector(7 downto 0);
17
        signal s_mantis: std_logic_vector(22 downto 0);
18
 
19
begin
20
        s_sgn   <= i_data(i_data'left);
21
        s_exp   <= i_data(i_data'left-1 downto 23);
22
        s_mantis        <= i_data(22 downto 0);
23
 
24
        process(s_sgn, s_exp, s_mantis)
25
        begin
26
 
27
                if to_integer(unsigned(s_exp)) < (127 - BX) then -- -subn, -0.0, +0.0, +subn and exp<127-BX
28
                        o_case          <= X"3F800000"; -- +1
29
                        o_case_en       <= '1';
30
 
31
                elsif s_exp > X"86" then
32
                        o_case_en       <= '1';
33
                        if s_mantis /= "00000000000000000000000" and s_exp = X"FF" then -- NaN
34
                                o_case <= X"FFFFFFFF"; -- NaN
35
                        else
36
                                if s_sgn = '0' then-- +inf
37
                                        o_case <= X"7F800000"; -- +inf
38
                                else -- -inf
39
                                        o_case <= X"00000000"; -- 0     
40
                                end if;
41
                        end if;
42
 
43
                else
44
                        o_case_en       <= '0';
45
                        o_case <= X"00000000";
46
                end if;
47
 
48
        end process;
49
end rtl;
50
 

powered by: WebSVN 2.1.0

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