PandA-2024.02
|
Main class for wrapping the FloPoCo code generator. More...
#include <flopoco_wrapper.hpp>
Public Member Functions | |
flopoco_wrapper (int _debug_level, const std::string &FU_target) | |
Constructor. More... | |
~flopoco_wrapper () | |
Destructor. More... | |
flopoco_wrapper (const flopoco_wrapper &inst)=delete | |
void | add_FU (const std::string &FU_type, unsigned int FU_prec_in, unsigned int FU_prec_out, const std::string &FU_name, const std::string &pipe_parameter) |
Adds a Functional Unit to the wrapper. More... | |
unsigned int | get_FUPipelineDepth (const std::string &FU_name, const unsigned int FU_prec_in, const unsigned int FU_prec_out, const std::string &pipe_parameter) const |
Returns the Functional Unit's Pipeline Depth. More... | |
int | writeVHDL (const std::string &FU_name, const unsigned int FU_prec_in, const unsigned int FU_prec_out, std::string pipe_parameter, std::string &filename) |
Writes the VHDL for a Functional Unit to the default file name, which is "FU_name.vhdl" Returns -1 if some problem occurred, 0 if the file was successfully written, 1 if the FU was already written to a file. More... | |
std::string | writeVHDLcommon () |
write the common components More... | |
const CustomUnorderedSet< std::string > & | get_files_written () |
Returns the Functional Units that have been written to a VHDL file. More... | |
bool | is_unit_written (const std::string &FU_name, const unsigned int FU_prec_in, const unsigned int FU_prec_out, const std::string &pipe_parameter) const |
Checks if a Functional Unit have been written to a VHDL file. More... | |
const std::vector< std::string > | get_in_ports (const std::string &FU_name, const unsigned int FU_prec_in, const unsigned int FU_prec_out, const unsigned int expected_ports, const std::string &pipe_parameter) const |
Return the names of input and output ports (multiple names, thus a vector of strings) More... | |
const std::vector< std::string > | get_out_ports (const std::string &FU_name, const unsigned int FU_prec_in, const unsigned int FU_prec_out, const unsigned int expected_ports, const std::string &pipe_parameter) const |
Static Public Member Functions | |
static void | DECODE_BITS (unsigned int FU_prec, unsigned int &n_mant, unsigned int &n_exp) |
Retrieve mantissa and exponent for a given precision. More... | |
Static Public Attributes | |
static constexpr double | DEFAULT_TARGET_FREQUENCY = 100.0 |
Private Types | |
using | port_type = enum { port_in, port_out, clk, rst } |
Port types. More... | |
using | component_type = enum { top, wrapped, in_wrap, out_wrap } |
Component types. More... | |
using | unit_type = enum { UT_ADD, UT_SUB, UT_MULT, UT_DIV, UT_FF_CONV, UT_ADDSUB, UT_UFIX2FP, UT_IFIX2FP, UT_FP2UFIX, UT_FP2IFIX, UT_EXP, UT_SQRT, UT_compare_expr, UT_LOG, UT_POW, UT_UNKNOWN } |
unit type More... | |
Private Member Functions | |
flopoco::Operator * | get_FU (std::string FU_name_stored) const |
Returns one of the generated Functional Units. More... | |
const std::vector< std::string > | get_ports (const std::string &FU_name_stored, unsigned int expected_ports, port_type type, bool check_ports=true) const |
Returns the names of ports, according to the needed port type (port_in or port_out) More... | |
const std::string | get_port (port_type type) const |
Returns the name of a port, according to the needed port type (clock or reset) More... | |
int | InternalWriteVHDL (const std::string &FU_name, const unsigned int FU_prec_in, const unsigned int FU_prec_out, const std::string &filename, const std::string &pipe_parameter) |
Writes the VHDL for a Functional Unit to the desired file name Returns -1 if some problem occurred, 0 if the file was successfully written, 1 if the FU was already written to a file. More... | |
void | outputHeaderVHDL (const std::string &FU_name_stored, std::ostream &os) const |
Helper methods for automatic VHDL code generation: More... | |
void | outputWrapVHDL (const std::string &FU_name_stored, std::ostream &os, const std::string &pipe_parameter) |
void | outputPortDeclaration (const std::string &FU_prefix, const std::string &FU_name_stored, std::ostream &os, component_type type, const std::string &pipe_parameter) |
void | outputSignals (const std::string &FU_name_stored, std::ostream &os) |
void | outputPortMap (const std::string &FU_name_stored, std::ostream &os, const std::string &pipe_parameter) |
Private Attributes | |
int | debug_level |
Current debug level. More... | |
CustomUnorderedMap< std::string, flopoco::Operator * > | FUs |
Generated Functional Units. More... | |
CustomUnorderedSet< std::string > | FU_files |
Set of Functional Units written to a .vhdl file. More... | |
CustomUnorderedMap< std::string, std::pair< unsigned int, unsigned int > > | FU_to_prec |
Maps a Functional Unit to its precision. More... | |
simple_indent | PP |
Pretty print functor object used to indent the generated code. More... | |
unit_type | type |
bool | signed_p |
std::vector< flopoco::Operator * > | oplist |
flopoco::Target * | target |
Main class for wrapping the FloPoCo code generator.
Definition at line 93 of file flopoco_wrapper.hpp.
|
private |
Component types.
Definition at line 111 of file flopoco_wrapper.hpp.
|
private |
Port types.
Definition at line 109 of file flopoco_wrapper.hpp.
|
private |
unit type
Definition at line 130 of file flopoco_wrapper.hpp.
flopoco_wrapper::flopoco_wrapper | ( | int | _debug_level, |
const std::string & | FU_target | ||
) |
Constructor.
debug | is the current debug level |
does not exist so we use Virtex 6 target
does not exist so we use Virtex 6 target
does not exist so we use Virtex 6 target
does not exist so we use Virtex 6 target
sollya initialization
Definition at line 152 of file flopoco_wrapper.cpp.
References target, THROW_ERROR, and THROW_UNREACHABLE.
flopoco_wrapper::~flopoco_wrapper | ( | ) |
Destructor.
Definition at line 266 of file flopoco_wrapper.cpp.
|
delete |
void flopoco_wrapper::add_FU | ( | const std::string & | FU_type, |
unsigned int | FU_prec_in, | ||
unsigned int | FU_prec_out, | ||
const std::string & | FU_name, | ||
const std::string & | pipe_parameter | ||
) |
Adds a Functional Unit to the wrapper.
FU_type | is a string representing the FU type |
FU_prec_in | is a number representing the FU input precision |
FU_prec_out | is a number representing the FU output precision |
FU_name | is a string representing the FU name |
pipe_parameter | is a string defining the design frequency, in case is not empty |
set the target frequency
Definition at line 271 of file flopoco_wrapper.cpp.
References debug_level, DEBUG_LEVEL_PEDANTIC, DECODE_BITS(), DEFAULT_TARGET_FREQUENCY, ENCODE_NAME, FU_to_prec, FUs, IN_WRAP_PREFIX, OPLIST, OUT_WRAP_PREFIX, PRINT_DBG_MEX, signed_p, STR, target, THROW_ASSERT, THROW_UNREACHABLE, type, and WRAPPED_PREFIX.
|
static |
Retrieve mantissa and exponent for a given precision.
FU_prec | is a number representing the FU precision |
n_mant | is the number of bits for the mantissa |
n_exp | is the number of bits for the exponent |
Intel 80 bit extended precision padded with 16bits
Definition at line 1154 of file flopoco_wrapper.cpp.
References THROW_ERROR.
Referenced by add_FU().
|
inline |
Returns the Functional Units that have been written to a VHDL file.
Definition at line 247 of file flopoco_wrapper.hpp.
|
private |
Returns one of the generated Functional Units.
FU_name_stored | is a string representing the stored FU name |
Definition at line 580 of file flopoco_wrapper.cpp.
References FUs, and THROW_ASSERT.
Referenced by get_FUPipelineDepth(), and get_ports().
unsigned int flopoco_wrapper::get_FUPipelineDepth | ( | const std::string & | FU_name, |
const unsigned int | FU_prec_in, | ||
const unsigned int | FU_prec_out, | ||
const std::string & | pipe_parameter | ||
) | const |
Returns the Functional Unit's Pipeline Depth.
FU_name | is the Functional Unit whose Pipeline Depth is returned |
FU_prec_in | is a number representing the FU input precision |
FU_prec_out | is a number representing the FU output precision |
Definition at line 562 of file flopoco_wrapper.cpp.
References ENCODE_NAME, get_FU(), IN_WRAP_PREFIX, OUT_WRAP_PREFIX, type, and WRAPPED_PREFIX.
|
inline |
Return the names of input and output ports (multiple names, thus a vector of strings)
FU_name | is a string representing the FU name |
expected_ports | is the number of expected ports to be returned |
Definition at line 268 of file flopoco_wrapper.hpp.
References ENCODE_NAME, and WRAPPED_PREFIX.
|
inline |
Definition at line 275 of file flopoco_wrapper.hpp.
References ENCODE_NAME, and WRAPPED_PREFIX.
|
private |
Returns the name of a port, according to the needed port type (clock or reset)
type | is the type of the required port |
Definition at line 1140 of file flopoco_wrapper.cpp.
References THROW_UNREACHABLE.
Referenced by outputPortDeclaration(), and outputPortMap().
|
private |
Returns the names of ports, according to the needed port type (port_in or port_out)
FU_name_stored | is a string representing the stored FU name |
FU_prec | is a number representing the FU precision |
expected_ports | is the number of expected ports to be returned |
type | is the type of the required ports |
Definition at line 1115 of file flopoco_wrapper.cpp.
References get_FU(), and THROW_ASSERT.
Referenced by outputPortDeclaration(), outputPortMap(), outputSignals(), and outputWrapVHDL().
|
private |
Writes the VHDL for a Functional Unit to the desired file name Returns -1 if some problem occurred, 0 if the file was successfully written, 1 if the FU was already written to a file.
FU_name | is the Functional Unit whose code must be output |
FU_prec_in_in | is a number representing the FU input precision |
FU_prec_out | is a number representing the FU output precision |
FU_file | is the name of the file, without extension, where the VHDL code should be put (i.e. "FPAdder", not "FPAdder.vhdl") |
pipe_parameter | is a string defining the design frequency, in case is not empty |
Definition at line 1039 of file flopoco_wrapper.cpp.
References debug_level, DEBUG_LEVEL_PEDANTIC, ENCODE_NAME, lenet_tvm::file, FU_files, OPLIST, outputWrapVHDL(), and PRINT_DBG_MEX.
Referenced by writeVHDL().
|
inline |
Checks if a Functional Unit have been written to a VHDL file.
FU_name | is the Functional Unit whose existence must be checked |
Definition at line 256 of file flopoco_wrapper.hpp.
References ENCODE_NAME, and FILE_EXT.
|
private |
Helper methods for automatic VHDL code generation:
FU_prefix | is a string representing the prefix to prepend to FU_name, when needed |
FU_name_stored | is a string representing the stored FU name |
os | is the stream where the VHDL code should be put |
type | is the type of component under examination |
Definition at line 1029 of file flopoco_wrapper.cpp.
Referenced by outputWrapVHDL().
|
private |
Definition at line 884 of file flopoco_wrapper.cpp.
References CLOCK_PORT_NAME, DONE_PORT_NAME, FLOPOCO_ADDITIONAL_BITS, FU_to_prec, get_port(), get_ports(), PP, RESET_PORT_NAME, START_PORT_NAME, STR, top(), and type.
Referenced by outputWrapVHDL().
|
private |
Definition at line 691 of file flopoco_wrapper.cpp.
References CLOCK_PORT_NAME, DONE_PORT_NAME, FU_to_prec, get_port(), get_ports(), IN_WRAP_PREFIX, OUT_WRAP_PREFIX, PP, RESET_PORT_NAME, STR, type, and WRAPPED_PREFIX.
Referenced by outputWrapVHDL().
|
private |
Definition at line 821 of file flopoco_wrapper.cpp.
References FU_to_prec, get_ports(), max, PP, STR, type, and WRAPPED_PREFIX.
Referenced by outputWrapVHDL().
|
private |
Definition at line 587 of file flopoco_wrapper.cpp.
References simple_indent::deindent(), FU_to_prec, get_ports(), IN_WRAP_PREFIX, simple_indent::indent(), OUT_WRAP_PREFIX, outputHeaderVHDL(), outputPortDeclaration(), outputPortMap(), outputSignals(), PP, STR, THROW_UNREACHABLE, top(), type, and WRAPPED_PREFIX.
Referenced by InternalWriteVHDL().
int flopoco_wrapper::writeVHDL | ( | const std::string & | FU_name, |
const unsigned int | FU_prec_in, | ||
const unsigned int | FU_prec_out, | ||
std::string | pipe_parameter, | ||
std::string & | filename | ||
) |
Writes the VHDL for a Functional Unit to the default file name, which is "FU_name.vhdl" Returns -1 if some problem occurred, 0 if the file was successfully written, 1 if the FU was already written to a file.
FU_name | is the Functional Unit whose code must be output |
FU_prec_in_in | is a number representing the FU input precision |
FU_prec_out | is a number representing the FU output precision |
pipe_parameter | is a string defining the design frequency, in case is not empty |
filename | is where the name of the produced file will be stored |
Definition at line 1079 of file flopoco_wrapper.cpp.
References ENCODE_NAME, FILE_EXT, GetPath(), and InternalWriteVHDL().
std::string flopoco_wrapper::writeVHDLcommon | ( | ) |
write the common components
Definition at line 1086 of file flopoco_wrapper.cpp.
References lenet_tvm::file, FILE_EXT, flopoco::filename, GetPath(), target, and THROW_UNREACHABLE.
|
private |
Current debug level.
Definition at line 98 of file flopoco_wrapper.hpp.
Referenced by add_FU(), and InternalWriteVHDL().
|
static |
Definition at line 291 of file flopoco_wrapper.hpp.
Referenced by add_FU().
|
private |
Set of Functional Units written to a .vhdl file.
Definition at line 103 of file flopoco_wrapper.hpp.
Referenced by InternalWriteVHDL().
|
private |
Maps a Functional Unit to its precision.
Definition at line 105 of file flopoco_wrapper.hpp.
Referenced by add_FU(), outputPortDeclaration(), outputPortMap(), outputSignals(), and outputWrapVHDL().
|
private |
Generated Functional Units.
Definition at line 101 of file flopoco_wrapper.hpp.
|
private |
Definition at line 136 of file flopoco_wrapper.hpp.
|
private |
Pretty print functor object used to indent the generated code.
Definition at line 107 of file flopoco_wrapper.hpp.
Referenced by outputPortDeclaration(), outputPortMap(), outputSignals(), and outputWrapVHDL().
|
private |
Definition at line 134 of file flopoco_wrapper.hpp.
Referenced by add_FU().
|
private |
Definition at line 138 of file flopoco_wrapper.hpp.
Referenced by add_FU(), flopoco_wrapper(), and writeVHDLcommon().
|
private |
Definition at line 132 of file flopoco_wrapper.hpp.
Referenced by add_FU(), get_FUPipelineDepth(), outputPortDeclaration(), outputPortMap(), outputSignals(), and outputWrapVHDL().