| 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 |
|
|
library work;
|
| 40 |
|
|
use work.fpupack.all;
|
| 41 |
|
|
|
| 42 |
|
|
package comppack is
|
| 43 |
|
|
|
| 44 |
|
|
|
| 45 |
|
|
--- Component Declarations ---
|
| 46 |
|
|
|
| 47 |
|
|
component fpu_add is
|
| 48 |
|
|
PORT(
|
| 49 |
|
|
clk : IN std_logic;
|
| 50 |
|
|
rst : IN std_logic;
|
| 51 |
|
|
enable : IN std_logic;
|
| 52 |
|
|
opa : IN std_logic_vector (63 DOWNTO 0);
|
| 53 |
|
|
opb : IN std_logic_vector (63 DOWNTO 0);
|
| 54 |
|
|
sign : OUT std_logic;
|
| 55 |
|
|
sum_3 : OUT std_logic_vector (55 DOWNTO 0);
|
| 56 |
|
|
exponent_2 : OUT std_logic_vector (10 DOWNTO 0)
|
| 57 |
|
|
);
|
| 58 |
|
|
end component;
|
| 59 |
|
|
|
| 60 |
|
|
component fpu_sub is
|
| 61 |
|
|
PORT(
|
| 62 |
|
|
clk : IN std_logic;
|
| 63 |
|
|
rst : IN std_logic;
|
| 64 |
|
|
enable : IN std_logic;
|
| 65 |
|
|
opa : IN std_logic_vector (63 DOWNTO 0);
|
| 66 |
|
|
opb : IN std_logic_vector (63 DOWNTO 0);
|
| 67 |
|
|
fpu_op : IN std_logic_vector (2 DOWNTO 0);
|
| 68 |
|
|
sign : OUT std_logic;
|
| 69 |
|
|
diff_2 : OUT std_logic_vector (55 DOWNTO 0);
|
| 70 |
|
|
exponent_2 : OUT std_logic_vector (10 DOWNTO 0)
|
| 71 |
|
|
);
|
| 72 |
|
|
end component;
|
| 73 |
|
|
|
| 74 |
|
|
component fpu_mul is
|
| 75 |
|
|
port(
|
| 76 |
|
|
clk : IN std_logic;
|
| 77 |
|
|
rst : IN std_logic;
|
| 78 |
|
|
enable : IN std_logic;
|
| 79 |
|
|
opa : IN std_logic_vector (63 DOWNTO 0);
|
| 80 |
|
|
opb : IN std_logic_vector (63 DOWNTO 0);
|
| 81 |
|
|
sign : OUT std_logic;
|
| 82 |
|
|
product_7 : OUT std_logic_vector (55 DOWNTO 0);
|
| 83 |
|
|
exponent_5 : OUT std_logic_vector (11 DOWNTO 0)
|
| 84 |
|
|
);
|
| 85 |
|
|
end component;
|
| 86 |
|
|
|
| 87 |
|
|
component fpu_div is
|
| 88 |
|
|
port(
|
| 89 |
|
|
clk, rst, enable : IN std_logic;
|
| 90 |
|
|
opa, opb : IN std_logic_vector (63 DOWNTO 0);
|
| 91 |
|
|
sign : OUT std_logic;
|
| 92 |
|
|
mantissa_7 : OUT std_logic_vector (55 DOWNTO 0);
|
| 93 |
|
|
exponent_out : OUT std_logic_vector (11 DOWNTO 0)
|
| 94 |
|
|
);
|
| 95 |
|
|
end component;
|
| 96 |
|
|
|
| 97 |
|
|
component fpu_round is
|
| 98 |
|
|
port(
|
| 99 |
|
|
clk, rst, enable : IN std_logic;
|
| 100 |
|
|
round_mode : IN std_logic_vector (1 DOWNTO 0);
|
| 101 |
|
|
sign_term : IN std_logic;
|
| 102 |
|
|
mantissa_term : IN std_logic_vector (55 DOWNTO 0);
|
| 103 |
|
|
exponent_term : IN std_logic_vector (11 DOWNTO 0);
|
| 104 |
|
|
round_out : OUT std_logic_vector (63 DOWNTO 0);
|
| 105 |
|
|
exponent_final : OUT std_logic_vector (11 DOWNTO 0)
|
| 106 |
|
|
);
|
| 107 |
|
|
end component;
|
| 108 |
|
|
|
| 109 |
|
|
component fpu_exceptions is
|
| 110 |
|
|
port(
|
| 111 |
|
|
clk, rst, enable : IN std_logic;
|
| 112 |
|
|
rmode : IN std_logic_vector (1 DOWNTO 0);
|
| 113 |
|
|
opa, opb, in_except : IN std_logic_vector (63 DOWNTO 0);
|
| 114 |
|
|
exponent_in : IN std_logic_vector (11 DOWNTO 0);
|
| 115 |
|
|
mantissa_in : IN std_logic_vector (1 DOWNTO 0);
|
| 116 |
|
|
fpu_op : IN std_logic_vector (2 DOWNTO 0);
|
| 117 |
|
|
out_fp : OUT std_logic_vector (63 DOWNTO 0);
|
| 118 |
|
|
ex_enable, underflow, overflow, inexact : OUT std_logic;
|
| 119 |
|
|
exception, invalid : OUT std_logic
|
| 120 |
|
|
);
|
| 121 |
|
|
end component;
|
| 122 |
|
|
|
| 123 |
|
|
|
| 124 |
|
|
|
| 125 |
|
|
end comppack;
|