PandA-2024.02
Public Member Functions | Static Public Member Functions | Static Public Attributes | Private Types | Private Member Functions | Private Attributes
flopoco_wrapper Class Reference

Main class for wrapping the FloPoCo code generator. More...

#include <flopoco_wrapper.hpp>

Collaboration diagram for flopoco_wrapper:
Collaboration graph
[legend]

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
 

Detailed Description

Main class for wrapping the FloPoCo code generator.

Definition at line 93 of file flopoco_wrapper.hpp.

Member Typedef Documentation

◆ component_type

using flopoco_wrapper::component_type = enum { top, wrapped, in_wrap, out_wrap }
private

Component types.

Definition at line 111 of file flopoco_wrapper.hpp.

◆ port_type

using flopoco_wrapper::port_type = enum { port_in, port_out, clk, rst }
private

Port types.

Definition at line 109 of file flopoco_wrapper.hpp.

◆ unit_type

using flopoco_wrapper::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 }
private

unit type

Definition at line 130 of file flopoco_wrapper.hpp.

Constructor & Destructor Documentation

◆ flopoco_wrapper() [1/2]

flopoco_wrapper::flopoco_wrapper ( int  _debug_level,
const std::string &  FU_target 
)

Constructor.

Parameters
debugis 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::~flopoco_wrapper ( )

Destructor.

Definition at line 266 of file flopoco_wrapper.cpp.

◆ flopoco_wrapper() [2/2]

flopoco_wrapper::flopoco_wrapper ( const flopoco_wrapper inst)
delete

Member Function Documentation

◆ add_FU()

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.

Parameters
FU_typeis a string representing the FU type
FU_prec_inis a number representing the FU input precision
FU_prec_outis a number representing the FU output precision
FU_nameis a string representing the FU name
pipe_parameteris 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.

Here is the call graph for this function:

◆ DECODE_BITS()

void flopoco_wrapper::DECODE_BITS ( unsigned int  FU_prec,
unsigned int &  n_mant,
unsigned int &  n_exp 
)
static

Retrieve mantissa and exponent for a given precision.

Parameters
FU_precis a number representing the FU precision
n_mantis the number of bits for the mantissa
n_expis 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().

Here is the caller graph for this function:

◆ get_files_written()

const CustomUnorderedSet<std::string>& flopoco_wrapper::get_files_written ( )
inline

Returns the Functional Units that have been written to a VHDL file.

Definition at line 247 of file flopoco_wrapper.hpp.

◆ get_FU()

flopoco::Operator * flopoco_wrapper::get_FU ( std::string  FU_name_stored) const
private

Returns one of the generated Functional Units.

Parameters
FU_name_storedis 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().

Here is the caller graph for this function:

◆ get_FUPipelineDepth()

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.

Parameters
FU_nameis the Functional Unit whose Pipeline Depth is returned
FU_prec_inis a number representing the FU input precision
FU_prec_outis 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.

Here is the call graph for this function:

◆ get_in_ports()

const std::vector<std::string> flopoco_wrapper::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
inline

Return the names of input and output ports (multiple names, thus a vector of strings)

Parameters
FU_nameis a string representing the FU name
expected_portsis the number of expected ports to be returned

Definition at line 268 of file flopoco_wrapper.hpp.

References ENCODE_NAME, and WRAPPED_PREFIX.

◆ get_out_ports()

const std::vector<std::string> flopoco_wrapper::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
inline

Definition at line 275 of file flopoco_wrapper.hpp.

References ENCODE_NAME, and WRAPPED_PREFIX.

◆ get_port()

const std::string flopoco_wrapper::get_port ( port_type  type) const
private

Returns the name of a port, according to the needed port type (clock or reset)

Parameters
typeis the type of the required port

Definition at line 1140 of file flopoco_wrapper.cpp.

References THROW_UNREACHABLE.

Referenced by outputPortDeclaration(), and outputPortMap().

Here is the caller graph for this function:

◆ get_ports()

const std::vector< std::string > flopoco_wrapper::get_ports ( const std::string &  FU_name_stored,
unsigned int  expected_ports,
port_type  type,
bool  check_ports = true 
) const
private

Returns the names of ports, according to the needed port type (port_in or port_out)

Parameters
FU_name_storedis a string representing the stored FU name
FU_precis a number representing the FU precision
expected_portsis the number of expected ports to be returned
typeis 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().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ InternalWriteVHDL()

int flopoco_wrapper::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 
)
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.

Parameters
FU_nameis the Functional Unit whose code must be output
FU_prec_in_inis a number representing the FU input precision
FU_prec_outis a number representing the FU output precision
FU_fileis the name of the file, without extension, where the VHDL code should be put (i.e. "FPAdder", not "FPAdder.vhdl")
pipe_parameteris 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().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ is_unit_written()

bool flopoco_wrapper::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
inline

Checks if a Functional Unit have been written to a VHDL file.

Parameters
FU_nameis the Functional Unit whose existence must be checked

Definition at line 256 of file flopoco_wrapper.hpp.

References ENCODE_NAME, and FILE_EXT.

◆ outputHeaderVHDL()

void flopoco_wrapper::outputHeaderVHDL ( const std::string &  FU_name_stored,
std::ostream &  os 
) const
private

Helper methods for automatic VHDL code generation:

Parameters
FU_prefixis a string representing the prefix to prepend to FU_name, when needed
FU_name_storedis a string representing the stored FU name
osis the stream where the VHDL code should be put
typeis the type of component under examination

Definition at line 1029 of file flopoco_wrapper.cpp.

Referenced by outputWrapVHDL().

Here is the caller graph for this function:

◆ outputPortDeclaration()

void flopoco_wrapper::outputPortDeclaration ( const std::string &  FU_prefix,
const std::string &  FU_name_stored,
std::ostream &  os,
component_type  type,
const std::string &  pipe_parameter 
)
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().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ outputPortMap()

void flopoco_wrapper::outputPortMap ( const std::string &  FU_name_stored,
std::ostream &  os,
const std::string &  pipe_parameter 
)
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().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ outputSignals()

void flopoco_wrapper::outputSignals ( const std::string &  FU_name_stored,
std::ostream &  os 
)
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().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ outputWrapVHDL()

void flopoco_wrapper::outputWrapVHDL ( const std::string &  FU_name_stored,
std::ostream &  os,
const std::string &  pipe_parameter 
)
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().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ writeVHDL()

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.

Parameters
FU_nameis the Functional Unit whose code must be output
FU_prec_in_inis a number representing the FU input precision
FU_prec_outis a number representing the FU output precision
pipe_parameteris a string defining the design frequency, in case is not empty
filenameis 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().

Here is the call graph for this function:

◆ writeVHDLcommon()

std::string flopoco_wrapper::writeVHDLcommon ( )

write the common components

Returns
the name of the generated

Definition at line 1086 of file flopoco_wrapper.cpp.

References lenet_tvm::file, FILE_EXT, flopoco::filename, GetPath(), target, and THROW_UNREACHABLE.

Here is the call graph for this function:

Field Documentation

◆ debug_level

int flopoco_wrapper::debug_level
private

Current debug level.

Definition at line 98 of file flopoco_wrapper.hpp.

Referenced by add_FU(), and InternalWriteVHDL().

◆ DEFAULT_TARGET_FREQUENCY

constexpr double flopoco_wrapper::DEFAULT_TARGET_FREQUENCY = 100.0
static

Definition at line 291 of file flopoco_wrapper.hpp.

Referenced by add_FU().

◆ FU_files

CustomUnorderedSet<std::string> flopoco_wrapper::FU_files
private

Set of Functional Units written to a .vhdl file.

Definition at line 103 of file flopoco_wrapper.hpp.

Referenced by InternalWriteVHDL().

◆ FU_to_prec

CustomUnorderedMap<std::string, std::pair<unsigned int, unsigned int> > flopoco_wrapper::FU_to_prec
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().

◆ FUs

CustomUnorderedMap<std::string, flopoco::Operator*> flopoco_wrapper::FUs
private

Generated Functional Units.

Definition at line 101 of file flopoco_wrapper.hpp.

Referenced by add_FU(), and get_FU().

◆ oplist

std::vector<flopoco::Operator*> flopoco_wrapper::oplist
private

Definition at line 136 of file flopoco_wrapper.hpp.

◆ PP

simple_indent flopoco_wrapper::PP
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().

◆ signed_p

bool flopoco_wrapper::signed_p
private

Definition at line 134 of file flopoco_wrapper.hpp.

Referenced by add_FU().

◆ target

flopoco::Target* flopoco_wrapper::target
private

Definition at line 138 of file flopoco_wrapper.hpp.

Referenced by add_FU(), flopoco_wrapper(), and writeVHDLcommon().

◆ type

unit_type flopoco_wrapper::type
private

The documentation for this class was generated from the following files:

Generated on Mon Feb 12 2024 13:03:51 for PandA-2024.02 by doxygen 1.8.13