70 : debug(HLS_->debug_level),
74 all_regs_without_enable(
false),
75 FB(HLSMgr->CGetFunctionBehavior(HLS->functionId))
79 reset_type =
HLSMgr->get_parameter()->getOption<std::string>(OPT_reset_type);
87 if(HLS->
Param->isOption(OPT_context_switch))
89 auto omp_functions = GetPointer<OmpFunctions>(HLSMgr_->Rfuns);
91 if(HLSMgr_->is_reading_writing_function(HLS->
functionId) &&
92 omp_functions->kernel_functions.find(HLS->
functionId) != omp_functions->kernel_functions.end())
96 if(HLSMgr_->is_reading_writing_function(HLS->
functionId) &&
97 omp_functions->parallelized_functions.find(HLS->
functionId) != omp_functions->parallelized_functions.end())
101 if(omp_functions->atomic_functions.find(HLS->
functionId) != omp_functions->atomic_functions.end())
117 "---Storage Value: " +
STR(it->first) +
" for variable " +
119 " stored into register " + it->second->get_string());
126 "at least a storage value has to be mapped on register r");
138 unsigned long long max_bits = 0;
139 for(
const auto reg_var : reg_vars)
144 "- Analyzing node " +
STR(reg_var) +
", whose type is " + node_type0.get_name() +
145 " (size: " +
STR(node_type0.size) +
", vector_size: " +
STR(node_type0.vector_size) +
")");
146 max_bits = max_bits < node_size ? node_size : max_bits;
161 const auto reg_m = GetPointerS<module>(reg);
162 const auto& in_type = reg_m->get_in_port(0)->get_typeRef();
163 const auto& out_type = reg_m->get_out_port(0)->get_typeRef();
167 static_cast<unsigned int>(reg_m->get_in_port(1
U)->get_id() ==
RESET_PORT_NAME);
171 reg_m->get_in_port(offset)->type_resize(max_bits);
173 "- " + reg_m->get_in_port(offset)->get_path() +
" -> " + in_type->get_name() +
174 " (size: " +
STR(in_type->size) +
", vector_size: " +
STR(in_type->vector_size) +
")");
178 reg_m->get_out_port(0)->type_resize(max_bits);
180 "- " + reg_m->get_out_port(0)->get_path() +
" -> " + out_type->get_name() +
181 " (size: " +
STR(out_type->size) +
", vector_size: " +
STR(out_type->vector_size) +
")");
187 std::map<unsigned int, unsigned int> n_in;
188 std::map<unsigned int, unsigned int> n_out;
193 for(
const auto li : live_in)
195 if(n_in.find(li) == n_in.end())
197 n_in[li] = 1
U + dummy_offset;
201 n_in[li] = n_in[li] + 1
U + dummy_offset;
205 for(
const auto lo : live_out)
209 n_out[lo] = 1 + dummy_offset;
210 if(live_in.count(lo))
212 n_out[lo] = 2 + dummy_offset;
217 n_out[lo] = n_out[lo] + 1 + dummy_offset;
224 const auto all_woe = [&]() {
225 const auto store_vars_set =
get_vars(i);
226 for(
const auto sv : store_vars_set)
228 if(n_in.find(sv) == n_in.end() || n_in.find(sv)->second != 1 || n_out.find(sv) == n_out.end() ||
229 n_out.find(sv)->second != 1)
256 for(
unsigned int var : live_in)
267 auto i = this->find(sv);
282 return *GetPointerS<register_obj>(at(v));
288 const auto& circuit = SM->
get_circ();
292 const auto stallable_pipeline =
FB->is_pipeline_enabled() && !
FB->is_simple_pipeline();
293 if(stallable_pipeline)
316 const auto library =
HLS->
HLS_D->get_technology_manager()->get_library(register_type_name);
317 auto reg_mod = SM->add_module_from_technology_library(name, register_type_name, library, circuit,
318 HLS->
HLS_D->get_technology_manager());
321 THROW_ASSERT(port_ck,
"Clock port missing from register.");
322 SM->add_connection(clock_port, port_ck);
326 SM->add_connection(reset_port, port_rst);
333 "Register " +
STR(i) +
" also needs a stall register, allocating it...");
334 name =
"stall_" + name;
335 reg_mod = SM->add_module_from_technology_library(name, register_type_name, library, circuit,
336 HLS->
HLS_D->get_technology_manager());
339 SM->add_connection(clock_port, port_ck);
341 THROW_ASSERT(port_rst !=
nullptr,
"The stall register was not allocated a reset port");
342 SM->add_connection(reset_port, port_rst);
350 auto number_ff = 0ull;
356 "---Total number of flip-flops in function " +
FB->CGetBehavioralHelper()->get_function_name() +
357 ": " +
STR(number_ff));
362 "---All registers are without enable: function pipelining may come for free");
Class specification to contain liveness information.
#define DEBUG_LEVEL_VERY_PEDANTIC
extremely verbose debugging print is performed.
unsigned long long compute_bitsize(unsigned int r)
return and set the bitsize associated with given register
Data structure representing the entire HLS information.
~reg_binding() override
Destructor.
std::map< unsigned int, generic_objRef > stall_reg_table
map between std register index and stall register object for pipelines
File containing functions and utilities to support the printing of debug messagges.
#define PRINT_DBG_MEX(dbgLevel, curDbgLevel, mex)
We are producing a debug version of the program, so the message is printed;.
refcount< reg_binding > reg_bindingRef
RefCount type definition of the reg_binding class structure.
structural_managerRef datapath
Store the datapath description.
This file contains the structures needed to manage a graph that will represent the state transition g...
Structure representing the most relevant information about the type of a structural object...
const ParameterConstRef Param
class containing all the parameters
CustomOrderedSet< unsigned int > get_vars(const unsigned int &r) const
Returns the set of variable associated with the register.
const structural_objectRef get_circ() const
Get a reference to circ field.
bool all_regs_without_enable
when true all registers do not require write enable: pipelining comes for free
bool is_a_dummy_state(vertex state)
check if a state is a dummy state
const FunctionBehaviorConstRef FB
#define INDENT_OUT_MEX(outLevel, curOutLevel, mex)
std::map< unsigned int, unsigned long long > bitsize_map
relation between registers and their bitsize
const HLS_deviceRef HLS_D
reference to the information representing the target for the synthesis
void bind(unsigned int sv, unsigned int index)
class modeling a register object
void insert(node_tree **tree, int val)
std::map< unsigned int, generic_objRef > unique_table
map between register index and object
reg_binding(const hlsRef &HLS, const HLS_managerRef HLSMgr_)
Constructor.
void set_structural_obj(const structural_objectRef &SM_)
Sets structural_object associated to this object.
Class specification of the manager of the technology library data structures.
#define OUTPUT_LEVEL_MINIMUM
minimum debugging print is performed.
hlsRef HLS
HLS data-structure.
#define STR(s)
Macro which performs a lexical_cast to a string.
const register_obj & operator[](unsigned int v)
redefinition of the [] operator
static std::string reset_type
static reg_bindingRef create_reg_binding(const hlsRef &HLS, const HLS_managerRef HLSMgr_)
Base class for all resources into datapath.
#define CLOCK_PORT_NAME
standard name for ports
unsigned long long get_bitsize(unsigned int r) const
return bitsize
const std::list< vertex > & get_support() const
return the support set of the live in/out
const std::string get_string() const
Returns the name associated with the element.
Data structure used to store the register binding of variables.
StorageValueInformationRef storage_value_information
data-structure for storage values
const HLS_managerRef HLSMgr
information about all the HLS synthesis
std::map< unsigned int, CustomOrderedSet< unsigned int > > reg2storage_values
map between the register and the associated storage value
Class specification of the data structures used to manage technology information. ...
const std::string get_path() const
Return a unique identifier of the structural object.
int output_level
verbosity level of the class
redefinition of set to manage ordered/unordered structures
Base class for all register into datapath.
unsigned offset[NUM_VERTICES+1]
This file contains the structures needed to manage a graph that will represent the state transition g...
const CustomOrderedSet< unsigned int > & get_live_out(const vertex &v) const
Get the set of variables live at the output of a vertex.
virtual void specialise_reg(structural_objectRef ®, unsigned int r)
Specialise a register according to the type of the variables crossing it.
int debug
level of the verbosity during the debugging
livenessRef Rliv
data-structure containing the variable liveness
#define register_STD
simple register without reset
#define OUTPUT_LEVEL_VERY_PEDANTIC
verbose debugging print is performed.
virtual std::string GetRegisterFUName(unsigned int i)
return the name of register to be used
#define register_SARSE
register with synchronized asynchronous reset and synchronous enable
unsigned int get_used_regs() const
returns number of used register
void compute_is_without_enable()
compute the is with out enable relation
virtual void add_to_SM(structural_objectRef clock_port, structural_objectRef reset_port)
Add the resulting registers to the structural description of the datapath.
this class is used to manage the command-line or XML options.
#define register_SRSE
register with synchronous reset and synchronous enable
CustomOrderedSet< unsigned int > is_without_enable
store the set of register without enable
StateTransitionGraphRef GetStg()
Returns pointer to state transition graph created.
unsigned int functionId
this is the identifier of the function to be implemented
Class implementation of the structural_manager.
StateTransitionGraphManagerRef STG
Store the refcounted state transition graph.
void print_el(const_iterator &it) const override
Function that print the register binding associated with a storage value.
#define register_SE
register with synchronous enable
Datastructure to describe functions allocation in high-level synthesis.
unsigned int used_regs
number of used register
Data structure definition for high-level synthesis flow.
int debug_level
debugging level of the class
std::map< unsigned int, unsigned int > reverse_map
bind the storage value with the register instance
refcount< generic_obj > generic_objRef
RefCount definition for generic_obj class.
HLS specialization of generic_device.
A brief description of the C++ Header File.
const CustomOrderedSet< unsigned int > & get_live_in(const vertex &v) const
Get the set of variables live at the input of a vertex.
#define STD_GET_SIZE(structural_obj)
Macro returning the size of a type.
#define THROW_ASSERT(cond, str_expr)
helper function used to check an assert and if needed to throw an error in a standard way ...