To compile FloPoCo you need CMake (http://www.cmake.org/) which is included in mainstream Linux/Unix distributions, and is available for other operating systems, including Windows.
FloPoCo also depends on the MPFR library, available from http://www.mpfr.org and probably available in your favourite Linux/Unix distribution.
Optionally, you may want to link FloPoCo against Sollya. This enables more operators (HOTBM, CRFPConstMult). For this purpose, you must download, compile and install Sollya. FloPoCo is demonstrated to work with version 1.1 of Sollya and should work with future releases.
Compilation is a two-step process:
cmake .
make
The adventurous may get FloPoCo from its subversion repository.
FloPoCo is a command-line tool. The general syntax is
flopoco <options> <operator specification
list>
FloPoCo will generate a single VHDL file (named by default
flopoco.vhdl) containing synthesisable descriptions of all the
operators listed in <operator specification list>, plus
possibly sub-operators instanciated by them. To use these operators in your
design, just add this generated file to your project.
FloPoCo will also issue a report with useful information about the generated operators, such as the pipeline depth or expected working frequency.
./flopoco IntConstMult 16 12345
produces a file flopoco.vhdl containing a single operator for
the integer multiplication of an input 16-bit number by the constant 12345.
The VHDL entity is named after the operator specification, here
IntConstMult_16_12345.
./flopoco IntConstMult 16 12345 IntConstMult 16 54321
produces a file flopoco.vhdl containing two VHDL entities and
their architectures, for the two given constant multipliers.
./flopoco FPConstMult 8 23 8 23 0 -50 1768559438007110
produces a file flopoco.vhdl containing two VHDL entities, one for the specified constant floating-point multiplier by 1768559438007110x2-50, and the other one for a needed sub-component (an integer multiplier for the significand multiplication).
Several transversal options are available and will typically change the
operators occuring after them in the list. For
instance -frequency=300 sets the target
frequency. The -name=UserProvidedName option replaces the
(ugly and parameter-dependent) name generated by FloPoCo for the next
operator with a user-provided one. This allows in particular to change
parameters while keeping the same entity name, so that these changes
are transparent to the rest of the project. Options related to pipelining are reviewed below.
The -target option selects the target FPGA family. We
try to optimize for the highest speed grade available for this
family (see below for pipelining options).
To obtain a concise list of the available operators and options, simply type
./flopoco
In addition this help may be more in sync with the code than this file, especially if you are using a svn snapshot.
The FloPoCo distributions also includes useful programs for converting the
binary string of a floating-point number to human-readable form
(bin2fp) and back (fp2bin). The
longacc2fp utility converts the fixed-point output of the
LongAcc operator (see below) to human-readable form.
The floating-point format used in FloPoCo is identical to the one used in FPLibrary. It is inspired from the IEEE-754 standard.
An FP number is a bit vector consisting of 4 fields. From left to right:
The format is therefore parameterized by to positive integers wE and wF which define the sizes of the exponent and fraction fields respectively.
The utilities fp2bin and bin2fp will allow
you to get familiar with the format and set up test benches.
There are two main differences between the format (wE=8, wF=23) and the IEEE-754 single precision format (the same holds for double).
Exceptional cases (zeroes, infinities and Not a Number or NaN) are encoded as separate bits in FloPoCo, instead of being encoded as special exponent values in IEEE-754. This saves quite a lot of decoding/encoding logic. The main drawback of this format is when results have to be stored in memory, where they consume two more bits. However, FPGA embedded memory can accomodate 36-bit data, so adding two bits to a 32-bit IEEE-754 format is harmless as long as data resides within the FPGA.
As a side effect, the exponent can take two more values in FloPoCo than in IEEE-754 (one for very large numbers, one for very small ones).
Note that anyway, FloPoCo provides conversion operators from and to IEEE-754 formats (simple and double precision).
Numbers in the Logarithm Number System used in FloPoCo have an encoding similar to the floating-point format, which is also the same as the one used in FPLibrary.
Its fields are:
An operator may be combinatorial, or pipelined. A combinatorial operator has pipeline depth 0. An operator of pipeline depth 1 is obtained by inserting one and only one register on any path from an input to an output. Hopefully, this divides the critical path delay by almost 2. An operator of pipeline depth 2 is obtained by inserting two register levels, etc.
It should be noted that, according to this definition, pipelined operators usually do not directly buffer neither their inputs nor their outputs. For instance, connecting the input of a 400MHz operator to the output of another 400MHz operator may well lead to a circuit working at 200MHz only. It is the responsibility of the user or calling program to insert one more level of registers between two FloPoCo operators. This convention may be felt as a burden to the user, but it is the most sensible choice. It makes it possible to assemble sub-component without inserting registers in many situations, thus reducing the latency of complex components. Besides, different application contexts may have different policies (registers on output, or registers on input).
Two command-line options control the pipelining of the FloPoCo operators that follow them.
-pipeline=[yes|no] (default yes)-frequency=[frequency in MHz] (default 300)-pipeline
option is set, then FloPoCo will try to pipeline the operator to
the given frequency. It will report a warning if it fails -- or if
frequency-directed pipelining is not yet implemented for this
operator.
no, the operator will be combinatorial. If yes, registers
may be inserted if needed to reach the target frequency.
The philosophy of FloPoCo's approach to pipelining is the following:
flopoco -frequency=200 FPAdder 11 52
-frequency=300 FPMultiplier 8 23-frequency option may save resources.-frequency accordingly.Note that not all operators support pipelining (utimately they all will). They are mentionned in the command-line help.
Here is the list of operators that can be generated by FloPoCo. This list may not be fully up-to date... the code is the reference.
LeftShifter wIn MaxShift RightShifter wIn MaxShift LZOC wIn wOutLZOCShifterSticky wIn wOut computeSticky countTypeIntAdder wInIntNAdder wIn NIntCompressorTree wIn NIntMultiplier wInX wInYIntSquarer wInX wInYIntKaratsuba wInFPMultiplier wE wFFPAdder wE wFFPDiv wE wFFPSqrt wE wF useDSP correctRoundingFPSquarer wE wFLongAcc wE_in wF_in MaxMSB_in LSB_acc MSB_accMaxMSB_in, LSB_acc
and MSB_acc parameters to a given application, it
allows one to bring rounding error to a provably arbitrarily small
level (and in some case to avoid any rounding), for a very small hardware cost compared to using a
floating-point adder for accumulation.
DotProduct wE_in wF_X wF_Y MaxMSB_in LSB_acc MSB_accLongAcc2FP MaxMSB_in LSB_acc MSB_acc wE_out wF_outThis family of operators is described in all the gory details in this article.
IntConstMult w cFPConstMult wE_in wF_in wE_out wF_out cst_sgn cst_exp
cst_int_sigFPExp wE wFwE bits exponent and
wF bits significand. This operator implements the exponential function as described in
this article.
FPLog wE wF TableInsizewE bits exponent and
wF bits significand. The third allows for performance tuning. In doubt, set it to 0, which will default to something sensible. Otherwise, it defines the input size of the tables used by the operator, and should be between 6 and 15. See
this article (improved version in preparation).
Fix2FP LSB MSB wE wFFix2FP 0 31 8 23 converts an input integer into a single-precision number.
InputIEEE wEI wFI wEO wFOInputIEEE 8 23 wEO
wFO to convert from single-precision (or binary32) format,
or InputIEEE 11 52 wEO wFO to convert from
double-precision (or binary64) format. You may convert to a larger internal format or to a narrower one. Conversions are always correctly rounded.
OurputIEEE wEI wFI wEO wFOFP2FP wEI wFI wEO wFOCollision wE wFThis operator implements an arbitrary function using High-Order Table-Based Method, best described in this article.
HOTBM func wI wO degreeHOTBMFX func wE_in wF_in wE_out wF_out degreeHOTBMRange func wI wO degree xmin xmax scalefunc is a
sollya-like expression of the function, wI is the
input width, wO is the output width and degree
is the degree of the Remez polynomial.
wE_in, wF_in, wE_out, wF_out
are the width of the integral and fractional parts of the input and the output,
respectively.
[xmin, xmax] is the input domain of the
function, and scale is a scaling factor to be applied to
the output.
For HOTBM the input operand is interpreted as a positive fixed-point number,
with the point before the leftmost bit. The function to be implemented
is assumed to be well defined in [0;1[. The output is a fixed-point
number, where the first bit is the sign and the point is placed right
after it. Note that the output is in fact wO+1 bits
wide.
Due to the fact that the expression of the function might contain characters which are treated specially by the shell, you should enclose it within quotes.
Example:
flopoco HOTBM "sin(x*Pi/2)" 16 16 3
The HOTBMFX version allows to select arbitrary fixed-point representations for the input and output. Negative values are allowed.
Example:
flopoco HOTBMFX "log2(1+2^(-x))" 2 8 -1 8 1
HOTBMRange uses HOTBM after mapping [xmin,xmax[ to [0,1[, then multiplies the output by the scaling factor scale.
Note that this launches an exploration process that typically takes a few minutes for 16 bits, and may take hours for 24 bits.
HOTBM uses a polynomial approximation. It works well for functions which are regular enough (in mathematical terms, they should be defined and n-times continuously differentiable on the domain).
These operators compute in the Logarithmic Number System. They are mostly useful for low-precisions systems performing few additions and many multiplications, divisions or square roots.
LNSAddSub wE wFwE integral bits and wF fractional
bits in their exponents.
LNSMul wE wFwE integral bits and wF fractional
bits in their exponents.
LNSDiv wE wFwE integral bits and wF fractional
bits in their exponents.
LNSSqrt wE wFwE integral bits and wF fractional
bits in their exponents.
TestBench operator will generate a test bench for
the operator which precedes it in the command line (also called
unit under test, UUT).
Test cases are highly UUT specific. They include both standard tests
and random tests. The single parameter of the TestBench
specifies the number of random tests to generate. Random tests
use a pseudo-random number generator
initialised with the same seed, so that the test bench will be
deterministic.
Example:
flopoco HOTBM "sin(x*Pi/2)" 16 16 3 TestBench 1000
Wrapper