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

Subversion Repositories fpu_double

[/] [fpu_double/] [trunk/] [fpupack.vhd] - Blame information for rev 5

Details | Compare with Previous | View Log

Line No. Rev Author Line
1 2 davidklun
---------------------------------------------------------------------
2
----                                                             ----
3
----  FPU                                                        ----
4
----  Floating Point Unit (Double precision)                     ----
5
----                                                             ----
6
----  Author: David Lundgren                                     ----
7
----          davidklun@gmail.com                                ----
8
----                                                             ----
9
---------------------------------------------------------------------
10
----                                                             ----
11
---- Copyright (C) 2009 David Lundgren                           ----
12
----                  davidklun@gmail.com                        ----
13
----                                                             ----
14
---- This source file may be used and distributed without        ----
15
---- restriction provided that this copyright statement is not   ----
16
---- removed from the file and that any derivative work contains ----
17
---- the original copyright notice and the associated disclaimer.----
18
----                                                             ----
19
----     THIS SOFTWARE IS PROVIDED ``AS IS'' AND WITHOUT ANY     ----
20
---- EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED   ----
21
---- TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS   ----
22
---- FOR A PARTICULAR PURPOSE. IN NO EVENT SHALL THE AUTHOR      ----
23
---- OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,         ----
24
---- INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES    ----
25
---- (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE   ----
26
---- GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR        ----
27
---- BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF  ----
28
---- LIABILITY, WHETHER IN  CONTRACT, STRICT LIABILITY, OR TORT  ----
29
---- (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT  ----
30
---- OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE         ----
31
---- POSSIBILITY OF SUCH DAMAGE.                                 ----
32
----                                                             ----
33
---------------------------------------------------------------------
34
 
35
library  ieee;
36
use ieee.std_logic_1164.all;
37
use ieee.std_logic_unsigned.all;
38
 
39
package fpupack is
40
 
41
    -- count the number of zeros starting from the left
42
    function count_l_zeros (signal s_vector: std_logic_vector) return std_logic_vector;
43
    function count_zeros_mul (signal s_vector: std_logic_vector) return std_logic_vector;
44
 
45
end fpupack;
46
 
47
package body fpupack is
48
 
49
        function count_l_zeros (signal s_vector: std_logic_vector) return std_logic_vector is
50
                variable v_count : std_logic_vector(5 downto 0);
51
        begin
52
                v_count := "000000";
53
                for i in s_vector'range loop
54
                        case s_vector(i) is
55
                                when '0' => v_count := v_count + "000001";
56
                                when others => exit;
57
                        end case;
58
                end loop;
59
                return v_count;
60
        end count_l_zeros;
61
 
62
        -- count the zeros from the left for multiply
63
        function count_zeros_mul (signal s_vector: std_logic_vector) return std_logic_vector is
64
                variable v_count : std_logic_vector(5 downto 0);
65
        begin
66
                v_count := "000000";
67
                for i in 105 downto 52 loop
68
                        case s_vector(i) is
69
                                when '0' => v_count := v_count + "000001";
70
                                when others => exit;
71
                        end case;
72
                end loop;
73
                return v_count;
74
        end count_zeros_mul;
75
end fpupack;

powered by: WebSVN 2.1.0

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