PandA-2024.02
Public Member Functions | Private Attributes | Friends
HLS_constraints Class Reference

Data structure used to store all the HLS constraints. More...

#include <hls_constraints.hpp>

Collaboration diagram for HLS_constraints:
Collaboration graph
[legend]

Public Member Functions

 HLS_constraints (const ParameterConstRef &Param, std::string _fun_name)
 Constructor. More...
 
std::string get_function_name () const
 Gets the name of the function which the constraints are associated with. More...
 
void add_builtin_constraints ()
 Adds the builtin constraints. More...
 
void read_HLS_constraints_File (const std::string &f)
 Reads an XML file describing the structural data structures. More...
 
void write_HLS_constraints_File (const std::string &f)
 Writes an XML file describing the high level synthesis constraints data structure. More...
 
void set_number_fu (const std::string &name, const std::string &library, unsigned int n_resources=std::numeric_limits< unsigned int >::max())
 Sets the maximum number of resources available in the design. More...
 
unsigned int get_number_fu (const std::string &name, const std::string &library) const
 This method returns the maximum number of functional units available for the design. More...
 
unsigned int get_number_fu (const std::string &combined) const
 This method returns the maximum number of functional units available for the design. More...
 
void bind_vertex_to_fu (const std::string &vertex_name, const std::string &fu_name, const std::string &fu_library, const unsigned int fu_index)
 Binds a vertex to a functional unit. More...
 
bool has_binding_to_fu (const std::string &vertex_name) const
 Binds a vertex to a functional unit. More...
 
void set_scheduling_priority (const std::string &vertex_name, int Priority)
 Stores the priority value for an operation vertex. More...
 
CustomMap< std::string, int > get_scheduling_priority () const
 Returns the data structure containing scheduling priority constraints. More...
 
void set_clock_period (double period)
 Sets the clock period. More...
 
double get_clock_period () const
 Gets the clock period. More...
 
double get_clock_period_resource_fraction () const
 Gets the resource fraction of the clock period. More...
 
void set_max_registers (unsigned int n_resources)
 Sets the number of registers present in the function. More...
 
unsigned int get_max_registers () const
 Returns the number of registers available. More...
 
void xload (const xml_element *Enode)
 Loads a set of HLS constraints starting from an XML node. More...
 
void xwrite (xml_element *rootnode)
 Writes the HLS constraints into an XML tree. More...
 
void xwriteHLSConstraints (xml_element *Enode, bool forDump=false)
 Writes the generic synthesis constraints. More...
 
void xwriteFUConstraints (xml_element *Enode, const std::string &fu_name, const std::string &fu_library, unsigned int number_fu, bool forDump=false)
 Writes the constraints on the functional units. More...
 
void xwriteBindingConstraints (xml_element *Enode, const std::string &vertex_name, const std::string &fu_name, const std::string &fu_library, unsigned int fu_index)
 Writes the binding constraints (i.e., functional unit, instance and library) associated with an operation. More...
 
void xwriteSchedulingConstraints (xml_element *Enode, const std::string &vertex_name, int priority)
 Writes the scheduling constraints (i.e., priority value) associated with an operation. More...
 
void print (std::ostream &os) const
 Function that prints the class HLS_constraints. More...
 
std::string get_kind_text () const
 definition of the get_kind_text method More...
 

Private Attributes

CustomMap< std::string, unsigned int > tech_constraints
 For each functional unit tech_constraints stores the number of resources. More...
 
CustomMap< std::string, std::pair< std::string, std::pair< std::string, unsigned int > > > binding_constraints
 put into relation the vertex name with the functional unit, its library and the functional unit index this map can be used to define a binding for a vertex. More...
 
CustomMap< std::string, int > scheduling_constraints
 map between an operation vertex and its given scheduling priority value More...
 
double clock_period
 Clock period in ns. More...
 
double clock_period_resource_fraction
 current value of the resource fraction More...
 
unsigned int registers
 Variable storing the number of registers. More...
 
std::string fun_name
 name of the function which the constraints are associated with; emtpy string means that they are global constraints More...
 
const ParameterConstRef parameters
 The set of input parameters. More...
 

Friends

class allocation
 class that can directly access More...
 
std::ostream & operator<< (std::ostream &os, const HLS_constraints &s)
 Friend definition of the << operator. More...
 

Detailed Description

Data structure used to store all the HLS constraints.

Definition at line 72 of file hls_constraints.hpp.

Constructor & Destructor Documentation

◆ HLS_constraints()

HLS_constraints::HLS_constraints ( const ParameterConstRef Param,
std::string  _fun_name 
)

Constructor.

add the general builtin constraints

add user defined constraints

the command-line values overwrite the ones written into the XML file

Definition at line 74 of file hls_constraints.cpp.

References add_builtin_constraints(), CE_XVM, clock_period, clock_period_resource_fraction, DEBUG_LEVEL_MINIMUM, DEBUG_LEVEL_PEDANTIC, DEBUG_LEVEL_VERBOSE, XMLDomParser::Exec(), fun_name, xml_child::get_children(), GET_CLASS_NAME, XMLDomParser::get_document(), GetPath(), LOAD_XVM, parameters, test_panda::parser, PRINT_DBG_MEX, read_HLS_constraints_File(), THROW_ERROR, write_HLS_constraints_File(), and xload().

Here is the call graph for this function:

Member Function Documentation

◆ add_builtin_constraints()

void HLS_constraints::add_builtin_constraints ( )

Adds the builtin constraints.

Load default constraints on default resources

Definition at line 456 of file hls_constraints.cpp.

References XMLDomParser::Exec(), xml_child::get_children(), GET_CLASS_NAME, XMLDomParser::get_document(), parameters, test_panda::parser, THROW_ERROR, and xload().

Referenced by HLS_constraints().

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

◆ bind_vertex_to_fu()

void HLS_constraints::bind_vertex_to_fu ( const std::string &  vertex_name,
const std::string &  fu_name,
const std::string &  fu_library,
const unsigned int  fu_index 
)

Binds a vertex to a functional unit.

Parameters
vertex_nameis the name of the vertex.
fu_nameis the name of the functional unit.
fu_libraryis the name of the library where the functional unit fu_name is contained.
fu_indexis the ith functional unit instance.

Definition at line 212 of file hls_constraints.cpp.

References binding_constraints.

◆ get_clock_period()

double HLS_constraints::get_clock_period ( ) const
inline

Gets the clock period.

Returns
the clock period (in ns)

Definition at line 194 of file hls_constraints.hpp.

References clock_period.

◆ get_clock_period_resource_fraction()

double HLS_constraints::get_clock_period_resource_fraction ( ) const
inline

Gets the resource fraction of the clock period.

Returns
the value of the resource fraction

Definition at line 203 of file hls_constraints.hpp.

References clock_period_resource_fraction, and set_max_registers().

Here is the call graph for this function:

◆ get_function_name()

std::string HLS_constraints::get_function_name ( ) const

Gets the name of the function which the constraints are associated with.

Definition at line 185 of file hls_constraints.cpp.

References fun_name.

◆ get_kind_text()

std::string HLS_constraints::get_kind_text ( ) const
inline

definition of the get_kind_text method

Definition at line 286 of file hls_constraints.hpp.

Referenced by xwrite().

Here is the caller graph for this function:

◆ get_max_registers()

unsigned int HLS_constraints::get_max_registers ( ) const
inline

Returns the number of registers available.

Returns
the maximum number of registers

Definition at line 218 of file hls_constraints.hpp.

References print(), registers, xload(), xwrite(), xwriteBindingConstraints(), xwriteFUConstraints(), xwriteHLSConstraints(), and xwriteSchedulingConstraints().

Here is the call graph for this function:

◆ get_number_fu() [1/2]

unsigned int HLS_constraints::get_number_fu ( const std::string &  name,
const std::string &  library 
) const

This method returns the maximum number of functional units available for the design.

Parameters
nameis the name of the functional unit.
libraryis the library of name.
Returns
the maximum number of functional units available.

Definition at line 195 of file hls_constraints.cpp.

References ENCODE_FU_LIB.

◆ get_number_fu() [2/2]

unsigned int HLS_constraints::get_number_fu ( const std::string &  combined) const

This method returns the maximum number of functional units available for the design.

Parameters
combinedis the name of the functional unit in the form <unit_name>:<library_name>
Returns
the maximum number of functional units available.

Definition at line 200 of file hls_constraints.cpp.

References INFINITE_UINT, and tech_constraints.

◆ get_scheduling_priority()

CustomMap< std::string, int > HLS_constraints::get_scheduling_priority ( ) const

Returns the data structure containing scheduling priority constraints.

Returns
a map between the operation vertex and its priority value

Definition at line 451 of file hls_constraints.cpp.

References scheduling_constraints.

◆ has_binding_to_fu()

bool HLS_constraints::has_binding_to_fu ( const std::string &  vertex_name) const

Binds a vertex to a functional unit.

Parameters
vertex_nameis the name of the operation vertex

Definition at line 218 of file hls_constraints.cpp.

References binding_constraints.

◆ print()

void HLS_constraints::print ( std::ostream &  os) const

Function that prints the class HLS_constraints.

Parameters
osis the output stream.

Definition at line 265 of file hls_constraints.cpp.

References binding_constraints, clock_period, INFINITE_UINT, registers, scheduling_constraints, and tech_constraints.

Referenced by get_max_registers().

Here is the caller graph for this function:

◆ read_HLS_constraints_File()

void HLS_constraints::read_HLS_constraints_File ( const std::string &  f)

Reads an XML file describing the structural data structures.

Parameters
fthe input file name

Definition at line 512 of file hls_constraints.cpp.

References XMLDomParser::Exec(), xml_child::get_children(), GET_CLASS_NAME, XMLDomParser::get_document(), test_panda::parser, and xload().

Referenced by HLS_constraints().

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

◆ set_clock_period()

void HLS_constraints::set_clock_period ( double  period)

Sets the clock period.

Parameters
periodis the clock period (in ns)

Definition at line 223 of file hls_constraints.cpp.

References clock_period.

◆ set_max_registers()

void HLS_constraints::set_max_registers ( unsigned int  n_resources)

Sets the number of registers present in the function.

Parameters
n_resourcesis the maximum number of registers available

Definition at line 228 of file hls_constraints.cpp.

References max, min, registers, and THROW_ERROR.

Referenced by get_clock_period_resource_fraction().

Here is the caller graph for this function:

◆ set_number_fu()

void HLS_constraints::set_number_fu ( const std::string &  name,
const std::string &  library,
unsigned int  n_resources = std::numeric_limits<unsigned int>::max() 
)

Sets the maximum number of resources available in the design.

Parameters
nameis the name of the functional unit.
libraryis the library of name.
n_resourcesis the maximum number of fu available (default is infinite).

Definition at line 190 of file hls_constraints.cpp.

References ENCODE_FU_LIB, and tech_constraints.

Referenced by xload().

Here is the caller graph for this function:

◆ set_scheduling_priority()

void HLS_constraints::set_scheduling_priority ( const std::string &  vertex_name,
int  Priority 
)

Stores the priority value for an operation vertex.

Parameters
vertex_nameis the operation name
Priorityis the priority value related to the operation vertex

Definition at line 446 of file hls_constraints.cpp.

References scheduling_constraints.

◆ write_HLS_constraints_File()

void HLS_constraints::write_HLS_constraints_File ( const std::string &  f)

Writes an XML file describing the high level synthesis constraints data structure.

Parameters
fthe output file name

Definition at line 554 of file hls_constraints.cpp.

References xml_document::create_root_node(), GET_CLASS_NAME, xml_document::write_to_file_formatted(), and xwrite().

Referenced by HLS_constraints().

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

◆ xload()

void HLS_constraints::xload ( const xml_element Enode)

Loads a set of HLS constraints starting from an XML node.

Parameters
Enodeis a node of the XML tree where the constraints are stored.

Definition at line 305 of file hls_constraints.cpp.

References binding_constraints, CE_XVM, clock_period, xml_child::get_children(), LIBRARY_STD, LOAD_XVM, registers, scheduling_constraints, set_number_fu(), and THROW_ASSERT.

Referenced by add_builtin_constraints(), get_max_registers(), HLS_constraints(), and read_HLS_constraints_File().

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

◆ xwrite()

void HLS_constraints::xwrite ( xml_element rootnode)

Writes the HLS constraints into an XML tree.

Parameters
Enodeis the root node which the XML representation of the constraints is attached.

Definition at line 413 of file hls_constraints.cpp.

References xml_child::add_child_element(), binding_constraints, DECODE_FU_LIB(), get_kind_text(), scheduling_constraints, tech_constraints, xwriteBindingConstraints(), xwriteFUConstraints(), xwriteHLSConstraints(), and xwriteSchedulingConstraints().

Referenced by get_max_registers(), and write_HLS_constraints_File().

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

◆ xwriteBindingConstraints()

void HLS_constraints::xwriteBindingConstraints ( xml_element Enode,
const std::string &  vertex_name,
const std::string &  fu_name,
const std::string &  fu_library,
unsigned int  fu_index 
)

Writes the binding constraints (i.e., functional unit, instance and library) associated with an operation.

Parameters
Enodeis the node of the XML tree where the constraint will be stored.
vertex_nameis the operation name
fu_nameis the name of the functional unit
fu_libraryis the name of the library where the functional unit fu_name is contained.

Definition at line 392 of file hls_constraints.cpp.

References xml_child::add_child_element(), LIBRARY_STD, and WRITE_XVM.

Referenced by get_max_registers(), and xwrite().

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

◆ xwriteFUConstraints()

void HLS_constraints::xwriteFUConstraints ( xml_element Enode,
const std::string &  fu_name,
const std::string &  fu_library,
unsigned int  number_fu,
bool  forDump = false 
)

Writes the constraints on the functional units.

Parameters
Enodeis the node of the XML tree where the constraint will be stored.
fu_nameis the name of the functional unit
number_fuis the number of the functional unit instances
fu_libraryis the name of the library where the functional unit fu_name is contained.
fu_indexis the ith functional unit instance.

Definition at line 367 of file hls_constraints.cpp.

References xml_child::add_child_element(), INFINITE_UINT, LIBRARY_STD, and WRITE_XVM.

Referenced by get_max_registers(), and xwrite().

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

◆ xwriteHLSConstraints()

void HLS_constraints::xwriteHLSConstraints ( xml_element Enode,
bool  forDump = false 
)

Writes the generic synthesis constraints.

Parameters
Enodeis the node of the XML tree where the constraints will be stored.

Definition at line 383 of file hls_constraints.cpp.

References clock_period, INFINITE_UINT, registers, and WRITE_XVM.

Referenced by get_max_registers(), and xwrite().

Here is the caller graph for this function:

◆ xwriteSchedulingConstraints()

void HLS_constraints::xwriteSchedulingConstraints ( xml_element Enode,
const std::string &  vertex_name,
int  priority 
)

Writes the scheduling constraints (i.e., priority value) associated with an operation.

Parameters
Enodeis the node of the XML tree where the constraint will be stored.
vertex_nameis the operation name
priorityis the priority value for the scheduling

Definition at line 406 of file hls_constraints.cpp.

References xml_child::add_child_element(), and WRITE_XVM.

Referenced by get_max_registers(), and xwrite().

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

Friends And Related Function Documentation

◆ allocation

friend class allocation
friend

class that can directly access

Definition at line 102 of file hls_constraints.hpp.

◆ operator<<

std::ostream& operator<< ( std::ostream &  os,
const HLS_constraints s 
)
friend

Friend definition of the << operator.

Definition at line 279 of file hls_constraints.hpp.

Field Documentation

◆ binding_constraints

CustomMap<std::string, std::pair<std::string, std::pair<std::string, unsigned int> > > HLS_constraints::binding_constraints
private

put into relation the vertex name with the functional unit, its library and the functional unit index this map can be used to define a binding for a vertex.

Definition at line 79 of file hls_constraints.hpp.

Referenced by bind_vertex_to_fu(), has_binding_to_fu(), print(), xload(), and xwrite().

◆ clock_period

double HLS_constraints::clock_period
private

Clock period in ns.

Definition at line 85 of file hls_constraints.hpp.

Referenced by get_clock_period(), HLS_constraints(), print(), set_clock_period(), xload(), and xwriteHLSConstraints().

◆ clock_period_resource_fraction

double HLS_constraints::clock_period_resource_fraction
private

current value of the resource fraction

Definition at line 88 of file hls_constraints.hpp.

Referenced by get_clock_period_resource_fraction(), and HLS_constraints().

◆ fun_name

std::string HLS_constraints::fun_name
private

name of the function which the constraints are associated with; emtpy string means that they are global constraints

Definition at line 95 of file hls_constraints.hpp.

Referenced by get_function_name(), and HLS_constraints().

◆ parameters

const ParameterConstRef HLS_constraints::parameters
private

The set of input parameters.

Definition at line 98 of file hls_constraints.hpp.

Referenced by add_builtin_constraints(), and HLS_constraints().

◆ registers

unsigned int HLS_constraints::registers
private

Variable storing the number of registers.

Definition at line 91 of file hls_constraints.hpp.

Referenced by get_max_registers(), print(), set_max_registers(), xload(), and xwriteHLSConstraints().

◆ scheduling_constraints

CustomMap<std::string, int> HLS_constraints::scheduling_constraints
private

map between an operation vertex and its given scheduling priority value

Definition at line 82 of file hls_constraints.hpp.

Referenced by get_scheduling_priority(), print(), set_scheduling_priority(), xload(), and xwrite().

◆ tech_constraints

CustomMap<std::string, unsigned int> HLS_constraints::tech_constraints
private

For each functional unit tech_constraints stores the number of resources.

Definition at line 75 of file hls_constraints.hpp.

Referenced by get_number_fu(), print(), set_number_fu(), and xwrite().


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

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