FloPoCo depends on the MPFR library, available from http://www.mpfr.org and probably available in your favourite Linux/Unix distribution. To compile it you need CMake (http://www.cmake.org/) which also comes prepackaged for mainstream Linux/Unix distributions.
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.
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 snpashot.
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, from which it differs only for exceptional cases (zeroes, infinities and Not a Number or NaN).
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.
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:
-pipeline=[yes|no] (default yes)yes, at least one register
will be inserted (at the output of the operator), and maybe more
inside the operator. If no, the operator will be combinatorial.
-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.
The philosophy of FloPoCo's approach to pipelining is the following:
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 wInIntMultiplier wInX wInYFPMultiplier wEX wFX wEY wFY wER wFRFPAdder wEX wFX wEY wFY wER wFRLongAcc 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 wFwE bits exponent and
wF bits significand. This operator implements the natural logarithm function as described in
this article.
This 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
are generating using a pseudo-random number generator, being
initialised with the same seed, so that the test bench will be
deterministic.
Currently, only the following operators are able to generate test cases
required for test bench generation: HOTBM,
IntMultiplier, FPAdder, FPMultipier, IntConstMult,
FPConstMult, FPExp, FPLog.
Example:
flopoco HOTBM "sin(x*Pi/2)" 16 16 3 TestBench 1000
BigTestBench is similar to TestBench but is
optimized for large tests (up to 1 million). It generates a very short VHDL code, which
reads test vectors from a predetermined file (the filename is
operator_unique_name.test). However, BigTestBench has the
disadvantage that the test file looks like a big blob and it is very hard to debug
problems, especially for pipelined designs. Therefore, it is recommended to use this
operator only when TestBench is successful, and one wants to be really
sure that the UUT is working perfectly.
Example:
flopoco FPExp 8 16 BigTestBench 200000
Wrapper