63 const std::list<std::string>& ParametersName);
66 std::string signalName);
74 unsigned int _funId,
const DesignFlowManagerConstRef _design_flow_manager)
75 :
top_entity(_parameters, _HLSMgr, _funId, _design_flow_manager,
87 const auto CGM =
HLSMgr->CGetCallGraphManager();
88 const auto& top_function_ids = CGM->GetRootFunctions();
93 const auto FB =
HLSMgr->CGetFunctionBehavior(
funId);
105 const auto FB =
HLSMgr->CGetFunctionBehavior(
funId);
109 const auto& function_parameters = FB->CGetBehavioralHelper()->get_parameters();
110 for(
const auto& function_parameter : function_parameters)
113 ParametersName.push_back(FB->CGetBehavioralHelper()->PrintVariable(function_parameter));
122 const auto module_name = wrappedObj->
get_id();
123 wrappedObj->set_id(module_name +
"_int");
128 SM_mm_interface->
set_top_info(module_name, wrappedObj->get_typeRef());
129 wrappedObj->set_type(module_type);
131 const auto interfaceObj = SM_mm_interface->
get_circ();
132 GetPointerS<module>(interfaceObj)
133 ->set_description(
"Memory mapped interface for top component: " + wrappedObj->get_typeRef()->id_type);
135 GetPointerS<module>(interfaceObj)->set_authors(
"Component automatically generated by bambu");
138 wrappedObj->set_owner(interfaceObj);
139 wrappedObj->set_id(wrappedObj->get_id() +
"_i0");
140 GetPointerS<module>(interfaceObj)->add_internal_object(wrappedObj);
153 unsigned int unique_id = 0;
159 HLS->
top = SM_mm_interface;
165 const auto bus_addr_bitsize =
HLSMgr->get_address_bitsize();
166 const auto bus_data_bitsize =
HLSMgr->Rmem->get_bus_data_bitsize();
167 const auto bus_size_bitsize =
HLSMgr->Rmem->get_bus_size_bitsize();
168 const auto bus_tag_bitsize =
169 HLS->
Param->isOption(OPT_context_switch) ? GetPointerS<memory_cs>(
HLSMgr->Rmem)->get_bus_tag_bitsize() : 0
U;
174 if(port->get_kind() ==
port_vector_o_K && GetPointerS<port_o>(port)->get_ports_size() == 0)
176 GetPointerS<port_o>(port)->add_n_ports(max_n_ports, port);
186 if(port->get_kind() ==
port_vector_o_K && GetPointerS<port_o>(port)->get_ports_size() == 0)
188 GetPointerS<port_o>(port)->add_n_ports(max_n_ports, port);
198 const auto behavioral_helper = function_behavior->CGetBehavioralHelper();
201 auto base_address =
HLSMgr->Rmem->get_symbol(
funId,
funId)->get_symbol_name();
205 for(
const auto& topParam : behavioral_helper->get_parameters())
207 base_address =
HLSMgr->Rmem->get_symbol(topParam,
funId)->get_symbol_name();
213 const unsigned int function_return = behavioral_helper->GetFunctionReturnType(
HLS->
functionId);
216 base_address =
HLSMgr->Rmem->get_symbol(function_return,
funId)->get_symbol_name();
218 STR(
HLSMgr->Rmem->get_parameter_base_address(
funId, function_return)));
224 const auto interfaceObj = SM_mm->
get_circ();
227 const auto FB =
HLSMgr->CGetFunctionBehavior(
funId);
228 const auto BH = FB->CGetBehavioralHelper();
230 const auto controlSignal = interfaceObj->find_member(
"ControlSignal",
signal_o_K, interfaceObj);
233 for(
const auto& function_parameter : function_parameters)
236 if(function_parameter.first == BH->GetFunctionReturnType(
HLS->
functionId) ||
242 const auto signalName = BH->PrintVariable(function_parameter.first);
244 const auto memoryMappedRegister =
246 HLS->
HLS_D->get_technology_manager()->get_library(component_name),
247 interfaceObj,
HLS->
HLS_D->get_technology_manager());
248 if(multi_channel_bus)
252 GetPointerS<module>(memoryMappedRegister)
253 ->SetParameter(
"ALLOCATED_ADDRESS",
264 const auto port_out1 = memoryMappedRegister->find_member(
"out1",
port_o_K, memoryMappedRegister);
265 GetPointerS<port_o>(port_out1)->type_resize(
STD_GET_SIZE(parameterPort->get_typeRef()));
272 interfaceObj,
HLS->
HLS_D->get_technology_manager());
275 GetPointerS<port_o>(pMuxIn1)->type_resize(
STD_GET_SIZE(port_out1->get_typeRef()));
278 const auto pMuxIn2 = pMux->find_member(
"in2",
port_o_K, pMux);
279 GetPointerS<port_o>(pMuxIn2)->type_resize(
283 const auto pMuxOut1 = pMux->find_member(
"out1",
port_o_K, pMux);
284 GetPointerS<port_o>(pMuxOut1)->type_resize(
STD_GET_SIZE(parameterPort->get_typeRef()));
300 const auto returnType = BH->GetFunctionReturnType(
HLS->
functionId);
302 const auto returnRegister =
304 HLS->
HLS_D->get_technology_manager()->get_library(component_name),
305 interfaceObj,
HLS->
HLS_D->get_technology_manager());
306 if(multi_channel_bus)
310 GetPointer<module>(returnRegister)
311 ->SetParameter(
"ALLOCATED_ADDRESS",
HLSMgr->Rmem->get_symbol(returnType,
HLS->
functionId)->get_symbol_name());
318 const auto returnInPort = returnRegister->find_member(
"in1",
port_o_K, returnRegister);
319 GetPointer<port_o>(returnInPort)->set_type(innerReturnPort->get_typeRef());
325 const auto returnOutPort = returnRegister->find_member(
"out1",
port_o_K, returnRegister);
326 GetPointer<port_o>(returnOutPort)->set_type(outerReturnPort->get_typeRef());
331 const auto sig_done_port = interfaceObj->find_member(
"sig_done_port",
signal_o_K, interfaceObj);
340 const auto interfaceObj = SM_mm->
get_circ();
344 const auto reg_start_port = interfaceObj->find_member(
"sig_reg_start_port",
signal_o_K, interfaceObj);
350 HLS->
HLS_D->get_technology_manager());
352 const auto merge_in_port = GetPointer<port_o>(merge_in);
353 merge_in_port->add_n_ports(2, merge_in);
355 SM_mm->
add_connection(reg_start_port, merge_in_port->get_port(0));
367 const auto sig_done_port = interfaceObj->find_member(
"sig_done_port",
signal_o_K, interfaceObj);
379 "notifyCaller", component_name,
HLS->
HLS_D->get_technology_manager()->get_library(component_name),
380 interfaceObj,
HLS->
HLS_D->get_technology_manager());
381 if(multi_channel_bus)
390 const auto NotifiedSignal = interfaceObj->find_member(
"Notified",
signal_o_K, interfaceObj);
395 const auto notifyAddressSignal = interfaceObj->find_member(
"NotifyAddressSignal",
signal_o_K, interfaceObj);
396 SM_mm->
add_connection(notifyAddressSignal, notifyCaller->find_member(
"notifyAddress",
port_o_K, notifyCaller));
403 const auto interfaceObj = SM_mm->
get_circ();
404 const auto status_reg_name = [&]() {
412 "StatusRegister", status_reg_name,
HLS->
HLS_D->get_technology_manager()->get_library(status_reg_name),
413 interfaceObj,
HLS->
HLS_D->get_technology_manager());
414 if(multi_channel_bus)
418 GetPointerS<module>(statusRegister)
419 ->SetParameter(
"ALLOCATED_ADDRESS",
428 const auto sig_done_port = SM_mm->
add_sign(
"sig_done_port", interfaceObj, donePort->get_typeRef());
433 const auto sig_reg_start_port = SM_mm->
add_sign(
"sig_reg_start_port", interfaceObj, startPort->get_typeRef());
438 const auto controlPort = statusRegister->find_member(
"control",
port_o_K, statusRegister);
439 const auto ControlSignal = SM_mm->
add_sign(
"ControlSignal", interfaceObj, controlPort->get_typeRef());
442 const auto notifyAddressPort = statusRegister->find_member(
"notifyAddress",
port_o_K, statusRegister);
443 const auto notifyAddressSignal =
444 SM_mm->
add_sign(
"NotifyAddressSignal", interfaceObj, notifyAddressPort->get_typeRef());
445 notifyAddressSignal->
set_type(notifyAddressPort->get_typeRef());
448 const auto notifiedPort = statusRegister->find_member(
"notified",
port_o_K, statusRegister);
449 const auto NotifiedSignal = SM_mm->
add_sign(
"Notified", interfaceObj, notifiedPort->get_typeRef());
450 NotifiedSignal->
set_type(notifiedPort->get_typeRef());
459 const auto interfaceObj = SM->
get_circ();
461 const auto wrappedModule = GetPointer<module>(wrappedObj);
462 for(
unsigned int i = 0; i < wrappedModule->get_num_ports(); ++i)
464 const auto port = wrappedModule->get_positional_port(i);
465 const auto portObj = GetPointer<port_o>(port);
467 const auto portID = portObj->
get_id();
470 !std::count(ParametersName.begin(), ParametersName.end(), portID))))
475 SM->
add_port(portID, portObj->get_port_direction(), interfaceObj, portObj->get_typeRef());
482 std::string signalName)
484 const auto signA = GetPointerS<port_o>(portA)->get_connected_signal();
485 const auto signB = GetPointerS<port_o>(portB)->get_connected_signal();
490 if(GetPointerS<port_o>(portA)->get_port_size() > GetPointerS<port_o>(portB)->get_port_size())
502 else if(!signA && signB)
506 else if(!signB && signA)
510 else if(signA && signB)
531 const auto componentModule = GetPointerS<module>(component);
532 for(
unsigned int i = 0; i < componentModule->get_num_ports(); ++i)
534 const auto port = componentModule->get_positional_port(i);
535 const auto portObj = GetPointerS<port_o>(port);
536 if(portObj->get_is_data_bus())
538 portObj->type_resize(HLSMgr->Rmem->get_bus_data_bitsize());
540 else if(portObj->get_is_addr_bus())
542 portObj->type_resize(HLSMgr->get_address_bitsize());
544 else if(portObj->get_is_size_bus())
546 portObj->type_resize(HLSMgr->Rmem->get_bus_size_bitsize());
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 Initialize() override
Initialize the step (i.e., like a constructor, but executed just before exec.
#define RETURN_MM_REGISTERN_FU
void add_connection(structural_objectRef src, structural_objectRef dest)
Create a connection between a source structural object and a destination structural object...
structural_managerRef SM
reference to the resulting circuit
#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;.
static void propagateInterface(structural_managerRef SM, structural_objectRef wrappedObj, const std::list< std::string > &ParametersName)
DesignFlowStep_Status InternalExec() override
Execute the step.
File containing functions and utilities to support the printing of debug messagges.
#define MEMORY_MAPPED_REGISTERN_FU
Structure representing the most relevant information about the type of a structural object...
#define NOTYFY_CALLER_MINIMAL_FU
const ParameterConstRef Param
class containing all the parameters
const std::string & get_id() const
Return the identifier associated with the structural_object.
static void connectClockAndReset(structural_managerRef SM, structural_objectRef interfaceObj, structural_objectRef component)
#define GET_CLASS(obj)
Macro returning the actual type of an object.
bool needMemoryMappedRegisters
#define GENERATED_LICENSE
#define NOTYFY_CALLER_MINIMALN_FU
const structural_objectRef get_circ() const
Get a reference to circ field.
unsigned int get_out_port_size() const
Return the number of output ports.
Datastructure to represent a memory symbol in HLS.
void allocate_parameters() const
Allocates the in/out parameters of the module as internal registers.
const unsigned int funId
identifier of the function to be processed (0 means that it is a global step)
This class manages the circuit structures.
const HLS_deviceRef HLS_D
reference to the information representing the target for the synthesis
DesignFlowStep_Status InternalExec() override
Execute the step.
const structural_objectRef get_in_port(unsigned int n) const
Return the ith input port.
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.
static void connect_with_signal_name(structural_managerRef SM, structural_objectRef portA, structural_objectRef portB, std::string signalName)
redefinition of map to manage ordered/unordered structures
#define STR(s)
Macro which performs a lexical_cast to a string.
Auxiliary methods for manipulating string.
static void add_memory_parameter(const structural_managerRef SM, const std::string &name, const std::string &value)
Adds the given memory parameter to the corresponding object.
std::list< structural_objectRef > AddedComponents
#define CLOCK_PORT_NAME
standard name for ports
structural_managerRef top
Store the top description.
#define STATUS_REGISTER_NO_NOTIFIED_FU
fu_bindingRef Rfu
Store the refcounted functional unit binding of the operations.
#define STATUS_REGISTERN_FU
void set_top_info(const std::string &id, const technology_managerRef &LM, const std::string &Library="")
Class specification of the data structures used to manage technology information. ...
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.
static bool resize_if_busport(unsigned long long bus_size_bitsize, unsigned long long bus_addr_bitsize, unsigned long long bus_data_bitsize, unsigned long long bus_tag_bitsize, structural_objectRef port)
auxiliary function used to resize the bus ports with respect to their associated bus size ...
const structural_objectRef get_out_port(unsigned int n) const
Return the ith output port.
#define STATUS_REGISTER_FU
~TopEntityMemoryMapped() override
Destructor.
Datastructure to describe functions allocation in high-level synthesis.
unsigned int _channels_number
Function scope channels number.
std::list< std::string > ParametersName
Construction of top entity memory mapped interface.
void resizing_IO(module *fu_module, unsigned int max_n_ports) const
bool is_root_function
true when the module is a root function
const ParameterConstRef parameters
Set of input parameters.
DesignFlowStep_Status
The status of a step.
Base class to allocate memories in high-level synthesis.
static void setBusSizes(structural_objectRef component, const HLS_managerRef HLSMgr)
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)
This file collects some utility functions.
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.
unsigned int get_in_port_size() const
Return the number of input ports.
for each memory at maximum n parallel direct accesses and one indirect access
#define MEMORY_MAPPED_REGISTER_FU
memory mapped register
This class describes all classes used to represent a structural object.
virtual bool manage_module_ports(const HLS_managerRef HLSMgr, const hlsRef HLS, const structural_managerRef SM, const structural_objectRef curr_gate, unsigned int num)
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 insertStatusRegister(structural_managerRef SM, structural_objectRef wrappedObj)
void Initialize() override
Initialize the step (i.e., like a constructor, but executed just before exec.
Data structure used to store the functional-unit binding of the vertexes.
void insertStartDoneLogic(structural_managerRef SM, structural_objectRef wrappedObj)
hlsRef HLS
HLS data structure of the function to be analyzed.
#define STATUS_REGISTER_NO_NOTIFIEDN_FU
It collects all the common strings covering PandA copyrights issues.
this class is used to manage the command-line or XML options.
unsigned int functionId
this is the identifier of the function to be implemented
void insertMemoryMappedRegister(structural_managerRef SM, structural_objectRef wrappedObj)
#define RETURN_MM_REGISTER_FU
Class implementation of the structural_manager.
int debug_level
The debug level.
MemoryAllocation_ChannelsType _channels_type
Function scope channels type.
Data structure definition for high-level synthesis flow.
This class describes a generic module.
#define GENERATED_COPYRIGHT
Datastructure to represent memory information in high-level synthesis.
TopEntityMemoryMapped(const ParameterConstRef _parameters, const HLS_managerRef HLSMgr, unsigned int funId, const DesignFlowManagerConstRef design_flow_manager)
Constructor.
HLS specialization of generic_device.
void set_type(const structural_type_descriptorRef &s)
Set the type of the structural_object.
#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 ...