1 |
5 |
kavi |
=====================
|
2 |
|
|
ratpack user manual
|
3 |
|
|
=====================
|
4 |
|
|
|
5 |
|
|
+-------------------+----------------------------------------------------------+
|
6 |
|
|
| **Title** | ratpack (VHDL rational arithmetic package). |
|
7 |
|
|
+-------------------+----------------------------------------------------------+
|
8 |
|
|
| **Author** | Nikolaos Kavvadias 2009, 2010, 2011, 2012, 2013, 2014 |
|
9 |
|
|
+-------------------+----------------------------------------------------------+
|
10 |
|
|
| **Contact** | nikos@nkavvadias.com |
|
11 |
|
|
+-------------------+----------------------------------------------------------+
|
12 |
|
|
| **Website** | http://www.nkavvadias.com |
|
13 |
|
|
+-------------------+----------------------------------------------------------+
|
14 |
|
|
| **Release Date** | 21 February 2014 |
|
15 |
|
|
+-------------------+----------------------------------------------------------+
|
16 |
|
|
| **Version** | 0.2.0 |
|
17 |
|
|
+-------------------+----------------------------------------------------------+
|
18 |
|
|
| **Rev. history** | |
|
19 |
|
|
+-------------------+----------------------------------------------------------+
|
20 |
|
|
| **v0.2.0** | 2014-02-21 |
|
21 |
|
|
| | |
|
22 |
|
|
| | Changed documentation format to RestructuredText. |
|
23 |
|
|
| | Code has been reorganized into new directory structure. |
|
24 |
|
|
+-------------------+----------------------------------------------------------+
|
25 |
|
|
| **v0.1.3** | 2010-11-17 |
|
26 |
|
|
| | |
|
27 |
|
|
| | Added max, min. |
|
28 |
|
|
+-------------------+----------------------------------------------------------+
|
29 |
|
|
| **v0.1.2** | 2010-11-17 |
|
30 |
|
|
| | |
|
31 |
|
|
| | Added gcditer (iterative GCD using rational numbers). |
|
32 |
|
|
+-------------------+----------------------------------------------------------+
|
33 |
|
|
| **v0.1.1** | 2010-06-07 |
|
34 |
|
|
| | |
|
35 |
|
|
| | Minor update in documentation (README). |
|
36 |
|
|
+-------------------+----------------------------------------------------------+
|
37 |
|
|
| **v0.1.0** | 2010-05-14 |
|
38 |
|
|
| | |
|
39 |
|
|
| | First public release. |
|
40 |
|
|
+-------------------+----------------------------------------------------------+
|
41 |
|
|
|
42 |
|
|
|
43 |
|
|
1. Introduction
|
44 |
|
|
===============
|
45 |
|
|
|
46 |
|
|
``ratpack`` is a rational arithmetic package written in VHDL.
|
47 |
|
|
|
48 |
|
|
Currently, the ``ratpack`` package implements the following:
|
49 |
|
|
|
50 |
|
|
- the RATIONAL data type.
|
51 |
|
|
|
52 |
|
|
- to_rational:
|
53 |
|
|
construction function of a rational given two integers
|
54 |
|
|
(numerator and denominator).
|
55 |
|
|
|
56 |
|
|
- int2rat:
|
57 |
|
|
conversion function of an integer to its rational representation.
|
58 |
|
|
|
59 |
|
|
- numerator:
|
60 |
|
|
extracts the numerator of a rational number.
|
61 |
|
|
|
62 |
|
|
- denominator:
|
63 |
|
|
extracts the denominator of a rational number.
|
64 |
|
|
|
65 |
|
|
- ``"+"``, ``"-"``, ``"*"``, ``"/"``:
|
66 |
|
|
implementation of the basic arithmetic operations for rationals.
|
67 |
|
|
|
68 |
|
|
- abs:
|
69 |
|
|
extracts the absolute value of a given rational number.
|
70 |
|
|
|
71 |
|
|
- max:
|
72 |
|
|
extracts the maximum of two rationals.
|
73 |
|
|
|
74 |
|
|
- min:
|
75 |
|
|
extracts the minimum of two rationals.
|
76 |
|
|
|
77 |
|
|
- ``">"``, ``"<"``, ``">="``, ``"<="``, ``"="``, ``"/="``:
|
78 |
|
|
overload comparison operators for rationals.
|
79 |
|
|
|
80 |
|
|
- gcd:
|
81 |
|
|
computes the greatest common divisor of two integers (positive,
|
82 |
|
|
covers the pathological case of division by zero).
|
83 |
|
|
|
84 |
|
|
- mediant:
|
85 |
|
|
computes the mediant rational of two given rationals.
|
86 |
|
|
|
87 |
|
|
``ratpack`` is distributed along with two VHDL testbenches: a simple one
|
88 |
|
|
(``ratpack_tb1.vhd``) and a testbench generating the Farey series of orders
|
89 |
|
|
1 to 12 (``ratpack_tb2.vhd``). An exemplary rational arithmetic ALU has also
|
90 |
|
|
been included but it is currently left untested (not testbench for it).
|
91 |
|
|
|
92 |
|
|
The ``ratpack`` project can be download from the following OpenCores website:
|
93 |
|
|
http://opencores.org/project,ratpack
|
94 |
|
|
|
95 |
|
|
|
96 |
|
|
2. File listing
|
97 |
|
|
===============
|
98 |
|
|
|
99 |
|
|
The ``ratpack`` distribution includes the following files:
|
100 |
|
|
|
101 |
|
|
+-----------------------+------------------------------------------------------+
|
102 |
|
|
| /ratpack | Top-level directory |
|
103 |
|
|
+-----------------------+------------------------------------------------------+
|
104 |
|
|
| /bench/vhdl | Benchmarks VHDL directory |
|
105 |
|
|
+-----------------------+------------------------------------------------------+
|
106 |
|
|
| ratpack_tb1.vhd | A simple testbench. |
|
107 |
|
|
+-----------------------+------------------------------------------------------+
|
108 |
|
|
| ratpack_tb2.vhd | Testbench generating the Farey series (orders 1-12). |
|
109 |
|
|
+-----------------------+------------------------------------------------------+
|
110 |
|
|
| /doc | Documentation directory |
|
111 |
|
|
+-----------------------+------------------------------------------------------+
|
112 |
|
|
| AUTHORS | List of ``ratpack`` authors. |
|
113 |
|
|
+-----------------------+------------------------------------------------------+
|
114 |
|
|
| BUGS | Bug list. |
|
115 |
|
|
+-----------------------+------------------------------------------------------+
|
116 |
|
|
| ChangeLog | A log for code changes. |
|
117 |
|
|
+-----------------------+------------------------------------------------------+
|
118 |
|
|
| COPYING | The LGPL, version 3, governs ``ratpack``. |
|
119 |
|
|
+-----------------------+------------------------------------------------------+
|
120 |
|
|
| README | This file. |
|
121 |
|
|
+-----------------------+------------------------------------------------------+
|
122 |
|
|
| README.html | HTML version of README. |
|
123 |
|
|
+-----------------------+------------------------------------------------------+
|
124 |
|
|
| README.pdf | PDF version of README. |
|
125 |
|
|
+-----------------------+------------------------------------------------------+
|
126 |
|
|
| rst2docs.sh | Bash script for generating the HTML and PDF versions.|
|
127 |
|
|
+-----------------------+------------------------------------------------------+
|
128 |
|
|
| THANKS | Acknowledgements. |
|
129 |
|
|
+-----------------------+------------------------------------------------------+
|
130 |
|
|
| TODO | A list of future enhancements. |
|
131 |
|
|
+-----------------------+------------------------------------------------------+
|
132 |
|
|
| VERSION | Current version of the project sources. |
|
133 |
|
|
+-----------------------+------------------------------------------------------+
|
134 |
|
|
| /rtl/vhdl | RTL source code directory for the package |
|
135 |
|
|
+-----------------------+------------------------------------------------------+
|
136 |
|
|
| ratalu.vhd | Implementation of a rational arithmetic ALU. |
|
137 |
|
|
+-----------------------+------------------------------------------------------+
|
138 |
|
|
| ratpack.vhd | The rational arithmetic package. |
|
139 |
|
|
+-----------------------+------------------------------------------------------+
|
140 |
|
|
| /sim/rtl_sim | RTL simulation files directory |
|
141 |
|
|
+-----------------------+------------------------------------------------------+
|
142 |
|
|
| /sim/rtl_sim/out | RTL simulation output files directory |
|
143 |
|
|
+-----------------------+------------------------------------------------------+
|
144 |
|
|
| ratpack_results1.txt | Output generated by the ``ratpack_tb1.vhd`` tests. |
|
145 |
|
|
+-----------------------+------------------------------------------------------+
|
146 |
|
|
| ratpack_results2.txt | Output generated by the ``ratpack_tb2.vhd`` tests. |
|
147 |
|
|
+-----------------------+------------------------------------------------------+
|
148 |
|
|
| /sim/rtl_sim/run | RTL simulation run scripts directory |
|
149 |
|
|
+-----------------------+------------------------------------------------------+
|
150 |
|
|
| ratpack.mk | GNU Makefile for running GHDL simulations. |
|
151 |
|
|
+-----------------------+------------------------------------------------------+
|
152 |
|
|
| run.sh | A bash script for running the GNU Makefile for GHDL. |
|
153 |
|
|
+-----------------------+------------------------------------------------------+
|
154 |
|
|
|
155 |
|
|
|
156 |
|
|
3. ``ratpack`` usage
|
157 |
|
|
====================
|
158 |
|
|
|
159 |
|
|
The ``ratpack`` package test script can be used as follows:
|
160 |
|
|
|
161 |
|
|
| ``$./run.sh ``
|
162 |
|
|
|
163 |
|
|
After this process, the ``ratpack_results.txt`` file is generated containing
|
164 |
|
|
simulation results.
|
165 |
|
|
|
166 |
|
|
Here follow some simple usage examples of this bash script.
|
167 |
|
|
|
168 |
|
|
1. Compile the ``ratpack`` package and do a simple test.
|
169 |
|
|
|
170 |
|
|
| ``$ ./run.sh ratpack 1``
|
171 |
|
|
|
172 |
|
|
2. Compile the ``ratpack`` package and generate the Farey series.
|
173 |
|
|
|
174 |
|
|
| ``$ ./run.sh ratpack 2``
|
175 |
|
|
|
176 |
|
|
|
177 |
|
|
4. Prerequisities
|
178 |
|
|
=================
|
179 |
|
|
|
180 |
|
|
- Standard UNIX-based tools (tested on cygwin/x86)
|
181 |
|
|
|
182 |
|
|
* make
|
183 |
|
|
* bash
|
184 |
|
|
|
185 |
|
|
- GHDL simulator (http://ghdl.free.fr)
|
186 |
|
|
|
187 |
|
|
Provides the "ghdl" executable and corresponding simulation environment.
|