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

Subversion Repositories fpu100

[/] [fpu100/] [trunk/] [fpupack.vhd] - Blame information for rev 21

Details | Compare with Previous | View Log

Line No. Rev Author Line
1 2 jidan
-------------------------------------------------------------------------------
2
--
3
-- Project:     <Floating Point Unit Core>
4
--      
5
-- Description: FPU package wich contains constants and functions needed in the FPU core
6
-------------------------------------------------------------------------------
7
--
8
--                              100101011010011100100
9
--                              110000111011100100000
10
--                              100000111011000101101
11
--                              100010111100101111001
12
--                              110000111011101101001
13
--                              010000001011101001010
14
--                              110100111001001100001
15
--                              110111010000001100111
16
--                              110110111110001011101
17
--                              101110110010111101000
18
--                              100000010111000000000
19
--
20
--      Author:          Jidan Al-eryani 
21
--      E-mail:          jidan@gmx.net
22
--
23
--  Copyright (C) 2006
24
--
25
--      This source file may be used and distributed without        
26
--      restriction provided that this copyright statement is not   
27
--      removed from the file and that any derivative work contains 
28
--      the original copyright notice and the associated disclaimer.
29
--                                                           
30
--              THIS SOFTWARE IS PROVIDED ``AS IS'' AND WITHOUT ANY     
31
--      EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED   
32
--      TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS   
33
--      FOR A PARTICULAR PURPOSE. IN NO EVENT SHALL THE AUTHOR      
34
--      OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,         
35
--      INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES    
36
--      (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE   
37
--      GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR        
38
--      BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF  
39
--      LIABILITY, WHETHER IN  CONTRACT, STRICT LIABILITY, OR TORT  
40
--      (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT  
41
--      OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE         
42
--      POSSIBILITY OF SUCH DAMAGE. 
43
--
44
 
45
library  ieee;
46
use ieee.std_logic_1164.all;
47
use ieee.std_logic_unsigned.all;
48
 
49
package fpupack is
50
 
51
 
52
        -- Data width of floating-point number. Deafult: 32
53
        constant FP_WIDTH : integer := 32;
54
 
55
        -- Data width of fraction. Deafult: 23
56
        constant FRAC_WIDTH : integer := 23;
57
 
58
        -- Data width of exponent. Deafult: 8
59
        constant EXP_WIDTH : integer := 8;
60 6 jidan
 
61
        --Zero vector
62
        constant ZERO_VECTOR: std_logic_vector(30 downto 0) := "0000000000000000000000000000000";
63 2 jidan
 
64
        -- Infinty FP format
65
        constant INF  : std_logic_vector(30 downto 0) := "1111111100000000000000000000000";
66
 
67
        -- QNaN (Quit Not a Number) FP format (without sign bit)
68 6 jidan
    constant QNAN : std_logic_vector(30 downto 0) := "1111111110000000000000000000000";
69 2 jidan
 
70
    -- SNaN (Signaling Not a Number) FP format (without sign bit)
71
    constant SNAN : std_logic_vector(30 downto 0) := "1111111100000000000000000000001";
72
 
73
    -- count the  zeros starting from left
74
    function count_l_zeros (signal s_vector: std_logic_vector) return std_logic_vector;
75
 
76
    -- count the zeros starting from right
77
        function count_r_zeros (signal s_vector: std_logic_vector) return std_logic_vector;
78
 
79
end fpupack;
80
 
81
package body fpupack is
82
 
83
    -- count the  zeros starting from left
84
        function count_l_zeros (signal s_vector: std_logic_vector) return std_logic_vector is
85
                variable v_count : std_logic_vector(5 downto 0);
86
        begin
87
                v_count := "000000";
88
                for i in s_vector'range loop
89
                        case s_vector(i) is
90
                                when '0' => v_count := v_count + "000001";
91
                                when others => exit;
92
                        end case;
93
                end loop;
94
                return v_count;
95
        end count_l_zeros;
96
 
97
 
98
        -- count the zeros starting from right
99
        function count_r_zeros (signal s_vector: std_logic_vector) return std_logic_vector is
100
                variable v_count : std_logic_vector(5 downto 0);
101
        begin
102
                v_count := "000000";
103
                for i in 0 to s_vector'length-1 loop
104
                        case s_vector(i) is
105
                                when '0' => v_count := v_count + "000001";
106
                                when others => exit;
107
                        end case;
108
                end loop;
109
                return v_count;
110
        end count_r_zeros;
111
 
112
 
113
 
114
end fpupack;

powered by: WebSVN 2.1.0

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