67 unsigned int _funId,
const DesignFlowManagerConstRef _design_flow_manager,
69 :
classic_datapath(_parameters, _HLSMgr, _funId, _design_flow_manager, _hls_flow_step_type)
82 switch(relationship_type)
109 const auto FB =
HLSMgr->CGetFunctionBehavior(
funId);
123 GetPointerS<module>(datapath_cir)
124 ->set_description(
"Datapath RTL descrition for " + FB->CGetBehavioralHelper()->get_function_name());
126 GetPointerS<module>(datapath_cir)->set_authors(
"Component automatically generated by bambu");
140 std::vector<structural_objectRef> memory_modules;
142 const auto circuit = SM->
get_circ();
143 const auto omp_functions = GetPointerS<const OmpFunctions>(
HLSMgr->Rfuns);
144 const auto kernel_functions = omp_functions->kernel_functions;
146 if(kernel_functions.size() > 1)
148 for(
const auto kernel_function : kernel_functions)
152 HLSMgr->CGetFunctionBehavior(kernel_function)->CGetBehavioralHelper()->get_function_name());
157 const auto kernel_function_id = *(kernel_functions.begin());
158 const auto kernel_function_name =
159 HLSMgr->CGetFunctionBehavior(kernel_function_id)->CGetBehavioralHelper()->get_function_name();
160 const auto kernel_library =
HLS->
HLS_D->get_technology_manager()->get_library(kernel_function_name);
162 auto addr_kernel =
ceil_log2(
parameters->getOption<
unsigned long long>(OPT_num_accelerators));
167 for(
unsigned int i = 0; i <
parameters->getOption<
unsigned int>(OPT_num_accelerators); ++i)
169 const auto kernel_module_name = kernel_function_name +
"_" +
STR(i);
170 kernel_mod = SM->add_module_from_technology_library(kernel_module_name, kernel_function_name, kernel_library,
171 circuit,
HLS->
HLS_D->get_technology_manager());
172 memory_modules.push_back(kernel_mod);
175 GetPointer<module>(kernel_mod)
176 ->SetParameter(
"KERN_NUM",
STR(addr_kernel) +
"'d" +
STR(i));
182 for(
unsigned int i = 0; i <
parameters->getOption<
unsigned int>(OPT_num_accelerators); ++i)
197 auto num_thread =
parameters->getOption<
unsigned int>(OPT_num_accelerators);
207 SM->
add_port(
"request", port_o::IN, circuit, request_type);
217 std::string prefix =
"in_port_";
229 const std::list<unsigned int>& function_parameters = BH->
get_parameters();
230 for(
auto const function_parameter : function_parameters)
236 if(parameter_datapath ==
nullptr)
243 std::cout <<
"Parameter: " << BH->
PrintVariable(function_parameter) << std::endl;
244 if(parameter_kernel !=
nullptr)
259 SM->
add_connection(start_kernel, GetPointer<port_o>(start_datapath)->get_port(num_kernel));
265 SM->
add_connection(done_kernel, GetPointer<port_o>(done_datapath)->get_port(num_kernel));
271 SM->
add_connection(done_req_kernel, GetPointer<port_o>(done_req_datapath)->get_port(num_kernel));
280 for(
unsigned int j = 0; j < GetPointer<module>(kernel_mod)->get_in_port_size(); j++)
284 if(connectedPort ==
nullptr)
286 std::cout <<
"Found i var" << std::endl;
300 std::string mem_par_model =
"memory_ctrl_parallel";
301 std::string mem_par_name =
"memory_parallel";
302 std::string mem_par_library =
HLS->
HLS_D->get_technology_manager()->get_library(mem_par_model);
304 mem_par_name, mem_par_model, mem_par_library, circuit,
HLS->
HLS_D->get_technology_manager());
318 GetPointer<module>(mem_par_mod)
319 ->SetParameter(
"NUM_CHANNEL",
STR(
parameters->getOption<
unsigned int>(OPT_channels_number)));
320 GetPointer<module>(mem_par_mod)
321 ->SetParameter(
"NUM_ACC",
STR(
parameters->getOption<
unsigned int>(OPT_num_accelerators)));
322 auto addr_task =
ceil_log2(
parameters->getOption<
unsigned long long int>(OPT_context_switch));
327 GetPointer<module>(mem_par_mod)->SetParameter(
"ADDR_TASKS",
STR(addr_task));
328 auto addr_kern =
ceil_log2(
parameters->getOption<
unsigned long long>(OPT_num_accelerators));
333 GetPointer<module>(mem_par_mod)->SetParameter(
"ADDR_ACC",
STR(addr_kern));
341 auto memory_channel =
parameters->getOption<
unsigned int>(OPT_channels_number);
342 auto num_kernel =
parameters->getOption<
unsigned int>(OPT_num_accelerators);
343 for(
unsigned int j = 0; j < GetPointer<module>(mem_par_mod)->get_in_port_size(); j++)
346 if(GetPointer<port_o>(port_i)->get_is_memory())
348 std::string port_name = GetPointer<port_o>(port_i)->get_id();
349 if(port_name.substr(0, 3) ==
"IN_")
359 for(
unsigned int j = 0; j < GetPointer<module>(mem_par_mod)->get_out_port_size(); j++)
362 if(GetPointer<port_o>(port_i)->get_is_memory())
364 std::string port_name = GetPointer<port_o>(port_i)->get_id();
365 if(port_name.substr(0, 4) ==
"OUT_")
379 auto bus_data_bitsize =
HLSMgr->Rmem->get_bus_data_bitsize();
380 auto bus_addr_bitsize =
HLSMgr->get_address_bitsize();
381 auto bus_size_bitsize =
HLSMgr->Rmem->get_bus_size_bitsize();
382 auto bus_tag_bitsize = GetPointer<memory_cs>(
HLSMgr->Rmem)->get_bus_tag_bitsize();
384 if(GetPointer<port_o>(port)->get_is_data_bus())
388 else if(GetPointer<port_o>(port)->get_is_addr_bus())
392 else if(GetPointer<port_o>(port)->get_is_size_bus())
396 else if(GetPointer<port_o>(port)->get_is_tag_bus())
401 GetPointer<port_o>(port)->add_n_ports(vector_size, port);
405 const std::vector<structural_objectRef>& memory_modules,
411 unsigned int num_kernel = 0;
413 for(
const auto& memory_module : memory_modules)
415 for(
unsigned int j = 0; j < GetPointer<module>(memory_module)->get_in_port_size();
419 if(GetPointer<port_o>(port_i)->get_is_memory() && GetPointer<port_o>(port_i)->get_is_global() &&
420 GetPointer<port_o>(port_i)->get_is_extern())
422 std::string port_name = GetPointer<port_o>(port_i)->get_id();
426 THROW_ASSERT(!mem_paral_port || GetPointer<port_o>(mem_paral_port),
"should be a port");
427 SM->
add_connection(GetPointer<port_o>(mem_paral_port)->get_port(num_kernel), mem_paral_Sign);
431 for(
unsigned int j = 0; j < GetPointer<module>(memory_module)->get_out_port_size();
435 if(GetPointer<port_o>(port_i)->get_is_memory() && !GetPointer<port_o>(port_i)->get_is_global() &&
436 !GetPointer<port_o>(port_i)->get_is_extern())
438 std::string port_name = GetPointer<port_o>(port_i)->get_id();
442 THROW_ASSERT(!mem_paral_port || GetPointer<port_o>(mem_paral_port),
"should be a port");
444 SM->
add_connection(mem_paral_Sign, GetPointer<port_o>(mem_paral_port)->get_port(num_kernel));
450 for(
unsigned int j = 0; j < GetPointer<module>(memory_parallel)->get_in_port_size();
454 std::string port_name = GetPointer<port_o>(port_i)->get_id();
455 if(GetPointer<port_o>(port_i)->get_is_memory() && GetPointer<port_o>(port_i)->get_is_global() &&
456 GetPointer<port_o>(port_i)->get_is_extern() && port_name.substr(0, 3) ==
"IN_")
459 THROW_ASSERT(!cir_port || GetPointer<port_o>(cir_port),
"should be a port or null");
462 cir_port = SM->
add_port_vector(port_name, port_o::IN, GetPointer<port_o>(port_i)->get_ports_size(), circuit,
473 for(
unsigned int j = 0; j < GetPointer<module>(memory_parallel)->get_out_port_size();
477 std::string port_name = GetPointer<port_o>(port_i)->get_id();
478 if(GetPointer<port_o>(port_i)->get_is_memory() && !GetPointer<port_o>(port_i)->get_is_global() &&
479 !GetPointer<port_o>(port_i)->get_is_extern() && port_name.substr(0, 4) ==
"OUT_")
483 THROW_ASSERT(!cir_port || GetPointer<port_o>(cir_port),
"should be a port or null");
486 cir_port = SM->
add_port_vector(port_name, port_o::OUT, GetPointer<port_o>(port_i)->get_ports_size(),
~datapath_parallel_cs() override
Destructor.
static void propagate_memory_parameters(const structural_objectRef src, const structural_managerRef tgt)
Propagates the memory parameters from the source (innermost) module to the target (outermost) one...
void add_connection(structural_objectRef src, structural_objectRef dest)
Create a connection between a source structural object and a destination structural object...
#define DEBUG_LEVEL_VERY_PEDANTIC
extremely verbose debugging print is performed.
const HLS_managerRef HLSMgr
information about all the HLS synthesis
Data structure representing the entire HLS information.
#define INDENT_DBG_MEX(dbgLevel, curDbgLevel, mex)
We are producing a debug version of the program, so the message is printed;.
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 ParameterConstRef Param
class containing all the parameters
virtual void add_ports()
Adds the input/output ports of the module.
#define GET_CLASS(obj)
Macro returning the actual type of an object.
#define GENERATED_LICENSE
const structural_objectRef get_circ() const
Get a reference to circ field.
RelationshipType
The relationship type.
Source must be executed to satisfy target.
mathematical utility function not provided by standard libraries
const unsigned int funId
identifier of the function to be processed (0 means that it is a global step)
void manage_extern_global_port_parallel(const structural_managerRef SM, const std::vector< structural_objectRef > &memory_modules, const structural_objectRef circuit)
connect mem_parallel with datapath and kernels
This class manages the circuit structures.
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...
Class specification of the manager of the technology library data structures.
#define STR(s)
Macro which performs a lexical_cast to a string.
void add_ports() override
Adds the input/output ports of the module.
void connect_module_kernel(structural_objectRef kernel, unsigned int num_kernel)
connect datapath with each kernel
DesignFlowStep_Status InternalExec() override
InternalExec.
#define CLOCK_PORT_NAME
standard name for ports
#define THROW_UNREACHABLE(str_expr)
helper function used to specify that some points should never be reached
T ceil_log2(T x)
Return the smallest n such that 2**n >= X.
const std::list< unsigned int > get_parameters() const
Return the list of index of original parameters of the function.
void set_top_info(const std::string &id, const technology_managerRef &LM, const std::string &Library="")
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.
Target must be reexecuted.
redefinition of set to manage ordered/unordered structures
void set_black_box(bool bb)
Set the black box property associated with the structural_object.
static void fix_port_properties(structural_objectRef port_i, structural_objectRef cir_port)
copy the port properties from port_i to cir_port
const BehavioralHelperConstRef CGetBehavioralHelper() const
Returns the helper associated with the function.
virtual enum so_kind get_kind() const =0
Virtual function used to find the real type of a structural_object instance.
const ParameterConstRef parameters
Set of input parameters.
DesignFlowStep_Status
The status of a step.
This file collects some utility functions and macros.
void instantiate_component_parallel(structural_objectRef clock_port, structural_objectRef reset_port)
instantiate memory_parallel
#define DEBUG_LEVEL_NONE
no debugging print is performed.
std::string PrintVariable(unsigned int var) const
Print the name of the variable associated to the index.
refcount< structural_manager > structural_managerRef
RefCount type definition of the structural_manager class structure.
void type_resize(unsigned long long new_bit_size)
Just resize the size of the bits of the object.
void resize_dimension_bus_port(unsigned int vector_size, structural_objectRef port)
for each port resize it depending on the type of bus port
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.
void resize_ctrl_parallel_ports(structural_objectRef mem_par_mod)
for each port decide the vector size
void connect_i_module_kernel(structural_objectRef kernel)
connect datapath with each kernel
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 structural_objectRef add_sign(std::string id, structural_objectRef owner, structural_type_descriptorRef sign_type, unsigned int treenode=0)
Create a new signal.
void add_clock_reset(structural_objectRef &clock_obj, structural_objectRef &reset_obj)
Adds the clock and reset ports to the structural description of the circuit.
hlsRef HLS
HLS data structure of the function to be analyzed.
Template borrowed from the ANTLR library by Terence Parr (http://www.jGuru.com - Software rights: htt...
interface of loops finding algorithm
It collects all the common strings covering PandA copyrights issues.
datapath_parallel_cs(const ParameterConstRef _parameters, const HLS_managerRef HLSMgr, unsigned int funId, const DesignFlowManagerConstRef design_flow_manager, const HLSFlowStep_Type hls_flow_step_type)
Constructor.
const CustomUnorderedSet< std::tuple< HLSFlowStep_Type, HLSFlowStepSpecializationConstRef, HLSFlowStep_Relationship > > ComputeHLSRelationships(const DesignFlowStep::RelationshipType relationship_type) const override
ComputeHLSRelationships datapath need kernel in order to be created.
Class implementation of the structural_manager.
int debug_level
The debug level.
refcount< const HLSFlowStepSpecialization > HLSFlowStepSpecializationConstRef
const refcount definition of the class
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.
#define GENERATED_COPYRIGHT
Datastructure to represent memory information in high-level synthesis.
HLS specialization of generic_device.
A brief description of the C++ Header File.
#define THROW_ASSERT(cond, str_expr)
helper function used to check an assert and if needed to throw an error in a standard way ...