63 :
fu_binding(_HLSMgr, _function_id, _parameters)
73 auto omp_functions = GetPointer<OmpFunctions>(HLSMgr->Rfuns);
74 if(omp_functions->kernel_functions.find(HLS->
functionId) != omp_functions->kernel_functions.end())
79 if(omp_functions->kernel_functions.find(HLS->
functionId) != omp_functions->kernel_functions.end())
83 else if(omp_functions->atomic_functions.find(HLS->
functionId) != omp_functions->atomic_functions.end() ||
84 omp_functions->parallelized_functions.find(HLS->
functionId) != omp_functions->parallelized_functions.end())
96 std::string scheduler_model =
"scheduler";
97 std::string scheduler_name =
"scheduler_kernel";
99 std::string sche_library = HLS->
HLS_D->get_technology_manager()->get_library(scheduler_model);
101 scheduler_name, scheduler_model, sche_library, circuit, HLS->
HLS_D->get_technology_manager());
105 GetPointer<module>(scheduler_mod)
106 ->SetParameter(
"NUM_TASKS",
STR(
parameters->getOption<
unsigned int>(OPT_context_switch)));
107 auto addr_acc =
ceil_log2(
parameters->getOption<
unsigned long long>(OPT_num_accelerators));
112 GetPointer<module>(scheduler_mod)->SetParameter(
"ADDR_ACC",
STR(addr_acc));
113 GetPointer<module>(scheduler_mod)->SetParameter(
"KERN_NUM",
"KERN_NUM");
138 SM->
add_connection(task_pool_end_datapath, task_pool_end_scheduler);
143 SM->
add_connection(done_request_scheduler, done_request_datapath);
151 for(
unsigned int j = 0; j < GetPointer<module>(scheduler_mod)->get_in_port_size(); j++)
154 if(GetPointer<port_o>(port_i)->get_is_memory())
159 for(
unsigned int j = 0; j < GetPointer<module>(scheduler_mod)->get_out_port_size(); j++)
162 if(GetPointer<port_o>(port_i)->get_is_memory())
171 auto bus_data_bitsize = HLSMgr->Rmem->get_bus_data_bitsize();
172 auto bus_addr_bitsize = HLSMgr->get_address_bitsize();
173 auto bus_size_bitsize = HLSMgr->Rmem->get_bus_size_bitsize();
174 auto bus_tag_bitsize = GetPointer<memory_cs>(HLSMgr->Rmem)->get_bus_tag_bitsize();
176 if(GetPointer<port_o>(port)->get_is_data_bus())
180 else if(GetPointer<port_o>(port)->get_is_addr_bus())
184 else if(GetPointer<port_o>(port)->get_is_size_bus())
188 else if(GetPointer<port_o>(port)->get_is_tag_bus())
199 for(
unsigned int i = 0; i < GetPointer<module>(circuit)->get_internal_objects_size(); i++)
204 if(port_selector_module !=
nullptr)
227 port_selector->
type_resize(static_cast<unsigned>(num_slots));
234 SM->
add_connection(selector_regFile_scheduler, selector_regFile_sign);
235 SM->
add_connection(selector_regFile_sign, selector_regFile_datapath);
238 for(
unsigned int i = 0; i < GetPointer<module>(circuit)->get_internal_objects_size(); i++)
241 if(curr_gate->
get_id() !=
"scheduler_kernel")
245 if(port_selector_module !=
nullptr)
258 for(
unsigned int i = 0; i < GetPointer<module>(circuit)->get_internal_objects_size(); i++)
263 unsigned long long int tag_num = 0;
264 auto addr_tasks =
ceil_log2(
parameters->getOption<
unsigned long long int>(OPT_context_switch));
269 auto addr_acc =
ceil_log2(
parameters->getOption<
unsigned long long>(OPT_num_accelerators));
274 const auto bit_atomic = addr_tasks + addr_acc;
277 THROW_ERROR(
"too large tag value for TAG_MEM_REQ");
279 tag_num = 1ULL << bit_atomic;
286 const std::list<structural_objectRef>& memory_modules,
288 unsigned int& _unique_id)
290 auto omp_functions = GetPointer<OmpFunctions>(HLSMgr->Rfuns);
291 if(omp_functions->kernel_functions.find(HLS->
functionId) != omp_functions->kernel_functions.end())
295 else if(omp_functions->hierarchical_functions.find(HLS->
functionId) != omp_functions->hierarchical_functions.end())
306 const std::list<structural_objectRef>& memory_modules,
308 unsigned int& _unique_id)
310 std::map<structural_objectRef, std::list<structural_objectRef>,
jms_sorter> primary_outs;
315 for(
unsigned int j = 0; j < GetPointer<module>(scheduler)->get_in_port_size();
319 std::string port_name = GetPointer<port_o>(port_i)->get_id();
320 if(GetPointer<port_o>(port_i)->get_is_memory() && GetPointer<port_o>(port_i)->get_is_global() &&
321 GetPointer<port_o>(port_i)->get_is_extern() && port_name.substr(0, 3) ==
"IN_")
325 THROW_ASSERT(!cir_port || GetPointer<port_o>(cir_port),
"should be a port or null");
330 cir_port = SM->
add_port_vector(port_name, port_o::IN, GetPointer<port_o>(port_i)->get_ports_size(),
347 for(
const auto& memory_module : memory_modules)
349 for(
unsigned int j = 0; j < GetPointer<const module>(memory_module)->get_in_port_size(); j++)
353 if(GetPointer<port_o>(port_i)->get_is_memory() && GetPointer<port_o>(port_i)->get_is_global() &&
354 GetPointer<port_o>(port_i)->get_is_extern())
356 std::string port_name = GetPointer<port_o>(port_i)->get_id();
358 scheMemorySign = GetPointer<port_o>(sche_port)->get_connected_signal();
359 if(scheMemorySign ==
nullptr)
364 THROW_ASSERT(GetPointer<port_o>(sche_port),
"should be a port");
369 for(
unsigned int j = 0; j < GetPointer<const module>(memory_module)->get_out_port_size();
373 if(GetPointer<port_o>(port_i)->get_is_memory() && !GetPointer<port_o>(port_i)->get_is_global() &&
374 !GetPointer<port_o>(port_i)->get_is_extern())
376 std::string port_name = GetPointer<port_o>(port_i)->get_id();
378 THROW_ASSERT(!sche_port || GetPointer<port_o>(sche_port),
"should be a port");
379 if(std::find(primary_outs[sche_port].begin(), primary_outs[sche_port].end(), port_i) ==
380 primary_outs[sche_port].end())
382 primary_outs[sche_port].push_back(port_i);
389 for(
unsigned int j = 0; j < GetPointer<module>(scheduler)->get_out_port_size();
393 std::string port_name = GetPointer<port_o>(port_i)->get_id();
394 if(GetPointer<port_o>(port_i)->get_is_memory() && !GetPointer<port_o>(port_i)->get_is_global() &&
395 !GetPointer<port_o>(port_i)->get_is_extern() && port_name.substr(0, 4) ==
"OUT_")
399 THROW_ASSERT(!cir_port || GetPointer<port_o>(cir_port),
"should be a port or null");
404 cir_port = SM->
add_port_vector(port_name, port_o::OUT, GetPointer<port_o>(port_i)->get_ports_size(),
420 const std::list<structural_objectRef>& memory_modules,
422 unsigned int& _unique_id)
424 std::map<structural_objectRef, std::list<structural_objectRef>,
jms_sorter> primary_outs;
427 for(
const auto& memory_module : memory_modules)
429 for(
unsigned int j = 0; j < GetPointer<const module>(memory_module)->get_in_port_size(); j++)
432 if(GetPointer<port_o>(port_i)->get_is_memory() && GetPointer<port_o>(port_i)->get_is_global() &&
433 GetPointer<port_o>(port_i)->get_is_extern())
435 std::string port_name = GetPointer<port_o>(port_i)->get_id();
437 THROW_ASSERT(!cir_port || GetPointer<port_o>(cir_port),
"should be a port or null");
448 GetPointer<port_o>(port_i)->get_port(0));
449 if(GetPointer<port_o>(port_i)->get_ports_size() > 1)
451 for(
unsigned int num_chan = 1; num_chan <
parameters->getOption<
unsigned int>(OPT_channels_number);
455 GetPointer<port_o>(cir_port)->get_port(num_chan),
456 GetPointer<port_o>(port_i)->get_port(num_chan));
462 SM->
add_connection(GetPointer<port_o>(cir_port)->get_port(0), port_i);
467 for(
unsigned int j = 0; j < GetPointer<const module>(memory_module)->get_out_port_size(); j++)
470 if(GetPointer<port_o>(port_i)->get_is_memory() && !GetPointer<port_o>(port_i)->get_is_global() &&
471 !GetPointer<port_o>(port_i)->get_is_extern())
473 std::string port_name = GetPointer<port_o>(port_i)->get_id();
475 THROW_ASSERT(!cir_port || GetPointer<port_o>(cir_port),
"should be a port or null");
485 if(std::find(primary_outs[GetPointer<port_o>(cir_port)->get_port(0)].begin(),
486 primary_outs[GetPointer<port_o>(cir_port)->get_port(0)].end(),
487 GetPointer<port_o>(port_i)->get_port(0)) ==
488 primary_outs[GetPointer<port_o>(cir_port)->get_port(0)].end())
490 primary_outs[GetPointer<port_o>(cir_port)->get_port(0)].push_back(
491 GetPointer<port_o>(port_i)->get_port(0));
493 if(GetPointer<port_o>(port_i)->get_ports_size() > 1)
495 for(
unsigned int num_chan = 1; num_chan <
parameters->getOption<
unsigned int>(OPT_channels_number);
499 GetPointer<port_o>(port_i)->get_port(num_chan),
500 GetPointer<port_o>(cir_port)->get_port(num_chan));
504 else if(std::find(primary_outs[GetPointer<port_o>(cir_port)->get_port(0)].begin(),
505 primary_outs[GetPointer<port_o>(cir_port)->get_port(0)].end(),
506 port_i) == primary_outs[GetPointer<port_o>(cir_port)->get_port(0)].end())
508 primary_outs[GetPointer<port_o>(cir_port)->get_port(0)].push_back(port_i);
521 if(_dir == port_o::IO)
523 THROW_ERROR(
"port declared as IO not accepted in context switch");
527 auto omp_functions = GetPointer<OmpFunctions>(HLSMgr->Rfuns);
528 if(omp_functions->kernel_functions.find(HLS->
functionId) != omp_functions->kernel_functions.end() ||
529 omp_functions->hierarchical_functions.find(HLS->
functionId) != omp_functions->hierarchical_functions.end())
531 if(!GetPointer<port_o>(port_in)->get_is_memory())
void add_connection(structural_objectRef src, structural_objectRef dest)
Create a connection between a source structural object and a destination structural object...
void manage_memory_ports_parallel_chained(const HLS_managerRef HLSMgr, const structural_managerRef SM, const std::list< structural_objectRef > &memory_modules, const structural_objectRef circuit, const hlsRef HLS, unsigned int &_unique_id) override
decide based on function what function to call in order to connect appropriately the datapath memory_...
#define DEBUG_LEVEL_VERY_PEDANTIC
extremely verbose debugging print is performed.
Data structure representing the entire HLS information.
int debug_level
The debug level.
refcount< structural_type_descriptor > structural_type_descriptorRef
RefCount type definition of the structural_type_descriptor class structure.
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;.
structural_managerRef datapath
Store the datapath description.
Structure representing the most relevant information about the type of a structural object...
const std::string & get_id() const
Return the identifier associated with the structural_object.
#define GET_CLASS(obj)
Macro returning the actual type of an object.
const structural_objectRef get_circ() const
Get a reference to circ field.
void add_to_SM(const HLS_managerRef HLSMgr, const hlsRef HLS, structural_objectRef clock_port, structural_objectRef reset_port) override
Call different method that instantiate the new component for each function_type.
void manage_extern_global_port(const HLS_managerRef HLSMgr, const hlsRef HLS, const structural_managerRef SM, structural_objectRef port_in, unsigned int dir, structural_objectRef circuit, unsigned int num) override
manage_extern_global_port based on function attach the input of memory modules
mathematical utility function not provided by standard libraries
~fu_binding_cs() override
Destructor.
void resize_dimension_bus_port(const HLS_managerRef HLSMgr, structural_objectRef port)
for each port resize it using vector size
const HLS_deviceRef HLS_D
reference to the information representing the target for the synthesis
virtual structural_objectRef find_member(const std::string &id, so_kind type, const structural_objectRef owner) const =0
Return the object named id of a given type which belongs to or it is associated with the object...
virtual void add_to_SM(const HLS_managerRef HLSMgr, const hlsRef HLS, structural_objectRef clock_port, structural_objectRef reset_port)
Instance the functional unit inside the structural representation of the datapath.
virtual void manage_extern_global_port(const HLS_managerRef HLSMgr, const hlsRef HLS, const structural_managerRef SM, structural_objectRef port_in, unsigned int dir, structural_objectRef circuit, unsigned int num)
Class specification of the manager of the technology library data structures.
redefinition of map to manage ordered/unordered structures
Derived class to add module scheduler, mem_ctrl_parallel and bind correctly the channels.
#define STR(s)
Macro which performs a lexical_cast to a string.
#define CLOCK_PORT_NAME
standard name for ports
T ceil_log2(T x)
Return the smallest n such that 2**n >= X.
void set_atomic_memory_parameter(const hlsRef HLS)
set_atomic_memory_parameter need to set in order to have memory operation defined as atomic ...
void manage_memory_port_kernel(const structural_managerRef SM, const std::list< structural_objectRef > &memory_modules, const structural_objectRef circuit, const hlsRef HLS, unsigned int &_unique_id)
manage_memory_port_kernel connect correctly memory port when in kernel function
static structural_objectRef add_port(const std::string &id, port_o::port_direction pdir, structural_objectRef owner, structural_type_descriptorRef type_descr, unsigned int treenode=0)
Create a new port.
redefinition of set to manage ordered/unordered structures
fu_binding_cs(const HLS_managerConstRef _HLSMgr, const unsigned int function_id, const ParameterConstRef parameters)
static void fix_port_properties(structural_objectRef port_i, structural_objectRef cir_port)
copy the port properties from port_i to cir_port
void instantiate_component_kernel(const HLS_managerRef HLSMgr, const hlsRef HLS, structural_objectRef clock_port, structural_objectRef reset_port)
instantiate_component_kernel
void SetParameter(const std::string &name, const std::string &value)
Set a parameter value.
void connect_selector(const hlsRef HLS)
connect_selector in function not kernel connect selector with all the module that have the right port...
virtual enum so_kind get_kind() const =0
Virtual function used to find the real type of a structural_object instance.
This file collects some utility functions and macros.
void connect_selector_kernel(const hlsRef HLS)
connect_selector_kernel, kernel take selector from scheduler
#define THROW_ERROR(str_expr)
helper function used to throw an error in a standard way
virtual void manage_memory_ports_parallel_chained(const HLS_managerRef HLSMgr, const structural_managerRef SM, const std::list< structural_objectRef > &memory_modules, const structural_objectRef circuit, const hlsRef HLS, unsigned int &unique_id)
void type_resize(unsigned long long new_bit_size)
Just resize the size of the bits of the object.
structural_objectRef add_module_from_technology_library(const std::string &id, const std::string &fu_name, const std::string &library_name, const structural_objectRef owner, const technology_managerConstRef TM)
Create a new object starting from a library component.
This class describes all classes used to represent a structural object.
const structural_type_descriptorRef & get_typeRef() const
Return the type descriptor of the structural_object.
static void join_merge_split(const structural_managerRef SM, const hlsRef HLS, std::map< structural_objectRef, std::list< structural_objectRef >, jms_sorter > &primary_outs, const structural_objectRef circuit, unsigned int &unique_id)
static structural_objectRef add_sign(std::string id, structural_objectRef owner, structural_type_descriptorRef sign_type, unsigned int treenode=0)
Create a new signal.
void manage_memory_port_hierarchical(const structural_managerRef SM, const std::list< structural_objectRef > &memory_modules, const structural_objectRef circuit, const hlsRef HLS, unsigned int &_unique_id)
manage_memory_port_hierarchical connect correctly memory port when in hierarchical function ...
bool ExistsParameter(std::string name) const
Check if a parameter has been specified.
Template borrowed from the ANTLR library by Terence Parr (http://www.jGuru.com - Software rights: htt...
this class is used to manage the command-line or XML options.
#define SELECTOR_REGISTER_FILE
unsigned int functionId
this is the identifier of the function to be implemented
Class implementation of the structural_manager.
Class managing the functional-unit binding.
const ParameterConstRef parameters
The set of input parameters.
Datastructure to describe functions allocation in high-level synthesis.
#define DEBUG_LEVEL_VERBOSE
verbose debugging print is performed.
Data structure definition for high-level synthesis flow.
static structural_objectRef add_port_vector(std::string id, port_o::port_direction pdir, unsigned int n_ports, structural_objectRef owner, structural_type_descriptorRef type_descr, unsigned int treenode=0)
Create a new port_vector.
Datastructure to represent memory information in high-level synthesis.
void resize_scheduler_ports(const HLS_managerRef HLSMgr, structural_objectRef scheduler_mod)
for each port decide its vector size
HLS specialization of generic_device.
#define THROW_ASSERT(cond, str_expr)
helper function used to check an assert and if needed to throw an error in a standard way ...