Don't print random debug information
[ipdf/vfpu.git] / src / fpupack.vhd
1
2 -- Description: FPU package wich contains constants and functions needed in the FPU core
3 -- See Copyright.jop
4
5
6 library  ieee;
7 use ieee.std_logic_1164.all;
8 use ieee.std_logic_unsigned.all;
9
10 package fpupack is
11
12
13         -- Data width of floating-point number. Deafult: 32
14         constant FP_WIDTH : integer := 32;
15         
16         -- Data width of fraction. Deafult: 23
17         constant FRAC_WIDTH : integer := 23;
18         
19         -- Data width of exponent. Deafult: 8
20         constant EXP_WIDTH : integer := 8;
21
22         --Zero vector
23         constant ZERO_VECTOR: std_logic_vector(FP_WIDTH-2 downto 0) := (others => '0');
24         
25         -- Infinty FP format
26         constant INF  : std_logic_vector(FP_WIDTH-2 downto 0) := (FP_WIDTH-2 downto FP_WIDTH-2-EXP_WIDTH+1 => '1', others => '0');
27         
28         -- QNaN (Quit Not a Number) FP format (without sign bit)
29     constant QNAN : std_logic_vector(FP_WIDTH-2 downto 0) := (FP_WIDTH-2 downto FP_WIDTH-2-EXP_WIDTH => '1', others => '0');
30     
31     -- SNaN (Signaling Not a Number) FP format (without sign bit)
32     constant SNAN : std_logic_vector(FP_WIDTH-2 downto 0) := (FP_WIDTH-2 downto FP_WIDTH-2-EXP_WIDTH+1 => '1', 0 => '1', others => '0');
33     
34     -- count the  zeros starting from left
35     function count_l_zeros (signal s_vector: std_logic_vector) return std_logic_vector;
36     
37     -- count the zeros starting from right
38         function count_r_zeros (signal s_vector: std_logic_vector) return std_logic_vector;
39     
40 end fpupack;
41
42 package body fpupack is
43     
44     -- count the  zeros starting from left
45         function count_l_zeros (signal s_vector: std_logic_vector) return std_logic_vector is
46                 variable v_count : std_logic_vector(5 downto 0);        
47         begin
48                 v_count := "000000";
49                 for i in s_vector'range loop
50                         case s_vector(i) is
51                                 when '0' => v_count := v_count + "000001";
52                                 when others => exit;
53                         end case;
54                 end loop;
55                 return v_count; 
56         end count_l_zeros;
57
58
59         -- count the zeros starting from right
60         function count_r_zeros (signal s_vector: std_logic_vector) return std_logic_vector is
61                 variable v_count : std_logic_vector(5 downto 0);        
62         begin
63                 v_count := "000000";
64                 for i in 0 to s_vector'length-1 loop
65                         case s_vector(i) is
66                                 when '0' => v_count := v_count + "000001";
67                                 when others => exit;
68                         end case;
69                 end loop;
70                 return v_count; 
71         end count_r_zeros;
72
73
74                 
75 end fpupack;

UCC git Repository :: git.ucc.asn.au