1 |
11 |
bro |
OpenFPU64
|
2 |
|
|
============================
|
3 |
|
|
Peter Hüwe
|
4 |
|
|
V.0.1, Januar 2009, License: CC-by-sa
|
5 |
|
|
:author initials: PH
|
6 |
12 |
bro |
:email: peterhuewe@gmx.de
|
7 |
11 |
bro |
:license: CC-by-sa
|
8 |
2 |
bro |
|
9 |
11 |
bro |
About OpenFPU64
|
10 |
|
|
---------------
|
11 |
|
|
OpenFPU64 is a free and open source implementation of a double precision floating point unit.
|
12 |
|
|
|
13 |
|
|
The openFPU64 currently features:
|
14 |
|
|
* double precision
|
15 |
|
|
* Addition/Subtraction
|
16 |
|
|
* Multiplication
|
17 |
|
|
* rounding (to nearest even)
|
18 |
|
|
* subnormals/denormals
|
19 |
|
|
* validated against IEEE754 using TestFloat (http://www.jhauser.us/arithmetic/TestFloat.html)
|
20 |
|
|
* Compatible with Avalon Bus
|
21 |
|
|
* Wishbone interface will be provided soon
|
22 |
|
|
|
23 |
12 |
bro |
The openFPU64 is tested with a Cyclone II and a CycloneIII fpga.
|
24 |
11 |
bro |
|
25 |
12 |
bro |
|
26 |
|
|
Overview
|
27 |
|
|
--------
|
28 |
|
|
The openFPU64 consists of several parts:
|
29 |
|
|
* openfpu64.vhd - contains the bus logic for the avalon bus, instantiate your own algorithms here
|
30 |
|
|
* fpu_package.vhd - global constants and defines
|
31 |
|
|
* fpu_add.vhd - Add/Sub algorithms
|
32 |
|
|
* fpu_mul.vhd - Multiplication Algorithm with several embedded Multipliers
|
33 |
|
|
* fpu_mul_single.vhd - Multiplication Algorithm with only one embedded Multiplier (currently in development, has some bugs)
|
34 |
|
|
|
35 |
|
|
To use it in the NiosII environment you have to use the driver/library in
|
36 |
|
|
* nios-driver
|
37 |
|
|
|
38 |
|
|
The testbench needs also
|
39 |
|
|
* openfpu64_tb.vhd - Testframework, consists of openfpu64_tb.head.vhd, openfpu64_tb.tail.vhd and the actual testcases which reside in tests/ (untar tests.tar.bz2)
|
40 |
|
|
* eis_helpers.vhd - some nice conversion functions for std_logic_vectors, provided by Prof. Dr. Gundolf Kiefer.
|
41 |
|
|
|
42 |
|
|
|
43 |
11 |
bro |
Usage in QuartusII SOPC (tm)
|
44 |
|
|
----------------------------
|
45 |
|
|
In order to use openFPU64 copy all VHDL files (*.vhd) and the TCL file (openfpu64_hw.tcl) to the root directory of your QuartusII Project.
|
46 |
|
|
(alternative: 'make quartus_distribution' and copy everything in openfpu64_quartus/ to the root directory of your Quartus II project)
|
47 |
|
|
|
48 |
|
|
Then open the QuartusII and from Quartus launch the SOPC Builder.
|
49 |
|
|
|
50 |
|
|
In SOPC Builder click new component in the left pane and select
|
51 |
|
|
File -> open and open the openfpu64_hw.tcl file.
|
52 |
|
|
|
53 |
|
|
By clicking on finish, the openFPU64 is added to your library.
|
54 |
|
|
|
55 |
|
|
Now add openFPU64 to your SOPC-design by double clicking on it, click Generate as usual.
|
56 |
|
|
In some rare cases your have to assign new Base and End Adresses,
|
57 |
|
|
clicking "System->Auto-Assign Base Adresses" does resolve this.
|
58 |
|
|
|
59 |
|
|
Now click Generate as usual, close SOPC Builder afterwards and compile your design as usual using Quartus.
|
60 |
|
|
|
61 |
|
|
|
62 |
|
|
|
63 |
|
|
Driver/Libary in NiosII:
|
64 |
|
|
------------------------
|
65 |
|
|
add the openfpu64.c and openfpu64.h files (in nios-driver)to your NiosII Project.
|
66 |
|
|
To use this library/driver, add the fpu.[ch] files to your application
|
67 |
|
|
and add these linker flags.
|
68 |
|
|
Click right on your application, choose properties, C/C++ Build
|
69 |
|
|
-> Linker -> General and type
|
70 |
|
|
"-Wl,--wrap,__adddf3,--wrap,__subdf3,--wrap,__muldf3"
|
71 |
|
|
For each implemented function, add another --wrap,__functioname
|
72 |
|
|
|
73 |
|
|
|
74 |
|
|
|
75 |
|
|
Development:
|
76 |
|
|
------------
|
77 |
|
|
If you'd like to do some development on openFPU64, you can use the Makefile together with GHDL (http://ghdl.free.fr/)
|
78 |
|
|
|
79 |
|
|
You can create several different testbenches by issuing one of these commands:
|
80 |
|
|
* empty_testsuite
|
81 |
|
|
* addsub_testsuite
|
82 |
|
|
* custom_testsuite
|
83 |
|
|
* add_testsuite
|
84 |
|
|
* sub_testsuite
|
85 |
|
|
* mul_testsuite
|
86 |
|
|
|
87 |
|
|
The custom_testsuite contains several hand crafted testsuites for ADD/SUB/MUL, the others are quite big (45k,95k testcases) and generated using TestFloat.
|
88 |
|
|
|
89 |
|
|
The testbench is made up of openfpu64_tb.head.vhd, openfpu64_tb.tail.vhd and the testscases in tests/.
|
90 |
|
|
|
91 |
|
|
If you want to change the testbench structure please DO NOT change openfpu64_tb.vhd but rather openfpu64_tb.head.vhd, otherwise your changes will be overwritten by make *_testsuite.
|
92 |
|
|
|
93 |
|
|
The empty testsuite is for 'resetting' the openfpu64_tb to be committed to svn.
|
94 |
|
|
Please use make empty_testsuite before checking your sources in.
|
95 |
|
|
|
96 |
|
|
|
97 |
|
|
|
98 |
|
|
Note:
|
99 |
|
|
-----
|
100 |
|
|
QuartusII, Nios, Cyclone, QuartusII SOPC Builders are registered Trademarks of Altera Corporation, 101 Innovation Drive, San Jose, California 95134, USA. All rights reserved.
|
101 |
|
|
|
102 |
12 |
bro |
|
103 |
|
|
|
104 |
|
|
Todo:
|
105 |
|
|
-----
|
106 |
|
|
Of course there is still a lot to do, e.g. adding more documentation.
|
107 |
2 |
bro |
Meanwhile, for questions contact me at peterhuewe@gmx.de and I'm glad to help you out
|