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

Subversion Repositories fpu100

[/] [fpu100/] [branches/] [avendor/] [fpupack.vhd] - Blame information for rev 2

Go to most recent revision | 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
 
61
 
62
        -- Infinty FP format
63
        constant INF  : std_logic_vector(30 downto 0) := "1111111100000000000000000000000";
64
 
65
        -- QNaN (Quit Not a Number) FP format (without sign bit)
66
    constant QNAN : std_logic_vector(30 downto 0) := "1111111110000000000000000000001";
67
 
68
    -- SNaN (Signaling Not a Number) FP format (without sign bit)
69
    constant SNAN : std_logic_vector(30 downto 0) := "1111111100000000000000000000001";
70
 
71
    -- count the  zeros starting from left
72
    function count_l_zeros (signal s_vector: std_logic_vector) return std_logic_vector;
73
 
74
    -- count the zeros starting from right
75
        function count_r_zeros (signal s_vector: std_logic_vector) return std_logic_vector;
76
 
77
end fpupack;
78
 
79
package body fpupack is
80
 
81
    -- count the  zeros starting from left
82
        function count_l_zeros (signal s_vector: std_logic_vector) return std_logic_vector is
83
                variable v_count : std_logic_vector(5 downto 0);
84
        begin
85
                v_count := "000000";
86
                for i in s_vector'range loop
87
                        case s_vector(i) is
88
                                when '0' => v_count := v_count + "000001";
89
                                when others => exit;
90
                        end case;
91
                end loop;
92
                return v_count;
93
        end count_l_zeros;
94
 
95
 
96
        -- count the zeros starting from right
97
        function count_r_zeros (signal s_vector: std_logic_vector) return std_logic_vector is
98
                variable v_count : std_logic_vector(5 downto 0);
99
        begin
100
                v_count := "000000";
101
                for i in 0 to s_vector'length-1 loop
102
                        case s_vector(i) is
103
                                when '0' => v_count := v_count + "000001";
104
                                when others => exit;
105
                        end case;
106
                end loop;
107
                return v_count;
108
        end count_r_zeros;
109
 
110
 
111
 
112
end fpupack;

powered by: WebSVN 2.1.0

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