58 unsigned int functionId,
59 const DesignFlowManagerConstRef _design_flow_manager)
60 :
WB4_interface(P, HLSManager, functionId, _design_flow_manager,
78 std::string module_name = wrappedObj->
get_id() +
"_interconnected";
83 SM_wb4_interconnected->
set_top_info(module_name, module_type);
90 GetPointer<module>(interfaceObj)->add_internal_object(wrappedObj);
92 GetPointer<module>(interfaceObj)
93 ->set_description(
"WB4 interface for top component: " + wrappedObj->
get_typeRef()->
id_type);
95 GetPointer<module>(interfaceObj)->set_authors(
"Component automatically generated by bambu");
100 buildCircuit(SM_wb4_interconnected, wrappedObj, interfaceObj, HLS, HLSMgr);
105 HLS->
top = SM_wb4_interconnected;
110 const auto function_behavior = HLSMgr->CGetFunctionBehavior(HLS->
functionId);
111 const auto behavioral_helper = function_behavior->CGetBehavioralHelper();
114 auto data_bus_bitsize = HLSMgr->Rmem->get_bus_data_bitsize();
115 for(
const auto& function_parameter :
parameters)
117 if(function_parameter.first != HLS->
functionId)
121 tree_helper::Size(HLSMgr->get_tree_manager()->CGetTreeReindex(function_parameter.first)));
124 return data_bus_bitsize;
129 auto addr_bus_bitsize = HLSMgr->get_address_bitsize();
130 auto allocated_space = HLSMgr->Rmem->get_max_address();
131 unsigned int parameter_addr_bit = 1;
132 while(allocated_space >>= 1)
134 ++parameter_addr_bit;
137 return std::max(parameter_addr_bit, addr_bus_bitsize);
204 auto* interconModule = GetPointer<module>(interconnect);
205 unsigned int interconPortsNumber = interconModule->get_num_ports();
206 for(
unsigned int i = 0; i < interconPortsNumber; ++i)
209 std::string portId = port->get_id();
213 if((position = portId.find(
"_om")) != std::string::npos)
215 portId.replace(position, 3,
"_is");
217 else if((position = portId.find(
"_im")) != std::string::npos)
219 portId.replace(position, 3,
"_os");
221 else if((position = portId.find(
"_os")) != std::string::npos)
223 portId.replace(position, 3,
"_im");
225 else if((position = portId.find(
"_is")) != std::string::npos)
227 portId.replace(position, 3,
"_om");
231 auto* portPtr = GetPointer<port_o>(port);
232 portPtr->set_type(destPort->get_typeRef());
233 portPtr->add_n_ports(1, port);
234 SM->
add_connection(destPort, portPtr->get_port(portPtr->get_ports_size() - 1));
246 std::string topModuleBaseAddress =
WB_BASE_ADDRESS "_" + topFunctionName +
"_interconnected";
248 std::vector<structural_objectRef> masters, slaves;
249 slaves.push_back(wrappedObj);
251 std::string baseAddressFileName =
"intercon_" +
STR(HLS->
functionId) +
".mem";
252 std::ofstream baseAddressFile(
GetPath(baseAddressFileName));
255 wrappedObj->SetParameter(topFunctionBaseAddress, topModuleBaseAddress +
" + " + topFunctionBaseAddress);
257 baseAddressFile << std::bitset<8 * sizeof(unsigned int)>(HLSMgr->Rmem->get_first_address(HLS->
functionId)) <<
'\n' 258 << std::bitset<8 *
sizeof(
unsigned int)>(HLSMgr->Rmem->get_last_address(HLS->
functionId, HLSMgr))
263 masters.push_back(wrappedObj);
266 const auto additionalTops = HLSMgr->CGetCallGraphManager()->GetAddressedFunctions();
267 for(
unsigned int itr : additionalTops)
270 std::string moduleName = functionName +
"_minimal_interface_wb4_interface";
272 baseAddressFile << std::bitset<8 * sizeof(unsigned int)>(HLSMgr->Rmem->get_first_address(itr)) <<
'\n' 273 << std::bitset<8 *
sizeof(
unsigned int)>(HLSMgr->Rmem->get_last_address(itr, HLSMgr)) <<
'\n';
275 functionName, moduleName,
WORK_LIBRARY, interfaceObj, HLS->
HLS_D->get_technology_manager());
278 additionalTop->SetParameter(acceleratorBaseAddress, topModuleBaseAddress +
" + " + acceleratorBaseAddress);
287 slaves.push_back(additionalTop);
290 masters.push_back(additionalTop);
294 baseAddressFile.close();
298 static_cast<unsigned int>(slaves.size()), interfaceObj, b_type);
300 unsigned int idx = 0;
301 for(
auto itr = slaves.begin(), end = slaves.end(); itr != end; ++itr, ++idx)
304 auto* currentModule = GetPointer<module>(*itr);
305 unsigned int inPortsNumber = currentModule->get_in_port_size();
306 for(
unsigned int i = 0; i < inPortsNumber; ++i)
309 std::string portId = port->get_id();
314 SM->
add_sign(currentModule->get_id() + portId, SM->
get_circ(), port->get_typeRef());
317 auto* destPortPtr = GetPointer<port_o>(destPort);
318 destPortPtr->set_type(port->get_typeRef());
319 destPortPtr->add_n_ports(1, destPort);
320 SM->
add_connection(signal, destPortPtr->get_port(destPortPtr->get_ports_size() - 1));
324 unsigned int outPortsNumber = currentModule->get_out_port_size();
325 for(
unsigned int i = 0; i < outPortsNumber; ++i)
328 std::string portId = port->get_id();
333 SM->
add_sign(currentModule->get_id() + portId, SM->
get_circ(), port->get_typeRef());
336 auto* destPortPtr = GetPointer<port_o>(destPort);
337 destPortPtr->set_type(port->get_typeRef());
338 destPortPtr->add_n_ports(1, destPort);
339 SM->
add_connection(signal, destPortPtr->get_port(destPortPtr->get_ports_size() - 1));
347 SM->
add_connection(GetPointer<port_o>(irqPort)->get_port(idx), irqSignal);
350 interconModule->SetParameter(
"MASTERS",
STR(masters.size() + 1));
351 interconModule->SetParameter(
"SLAVES",
STR(slaves.size() + 1));
352 interconModule->SetParameter(
"MEMORY_INIT_file",
"\"\"" +
GetPath(baseAddressFileName) +
"\"\"");
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...
const HLS_managerRef HLSMgr
information about all the HLS synthesis
Data structure representing the entire HLS information.
WB4Intercon_interface(const ParameterConstRef Param, const HLS_managerRef HLSManager, unsigned int functionId, const DesignFlowManagerConstRef design_flow_manager)
Constructor.
static std::string name_function(const tree_managerConstRef &tm, const unsigned int index)
Return the name of the function.
#define WB_DATIM_PORT_NAME
refcount< structural_type_descriptor > structural_type_descriptorRef
RefCount type definition of the structural_type_descriptor class structure.
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.
static void build_bus_interface(structural_managerRef SM, const hlsRef HLS, const HLS_managerRef HLSMgr)
#define GENERATED_LICENSE
const structural_objectRef get_circ() const
Get a reference to circ field.
~WB4Intercon_interface() override
Destructor.
void set_owner(const structural_objectRef new_owner)
set the owner of the structural object
#define WB_DATIS_PORT_NAME
This class manages the circuit structures.
const HLS_deviceRef HLS_D
reference to the information representing the target for the synthesis
unsigned int get_addr_bus_bitsize()
Class specification of the manager of the technology library data structures.
Module for the generation of the top WB4 component.
#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.
#define WB_CYCOM_PORT_NAME
#define CLOCK_PORT_NAME
standard name for ports
structural_managerRef top
Store the top description.
#define WB_DATOS_PORT_NAME
static unsigned long long Size(const tree_nodeConstRef &tn)
Return the size of a tree object.
unsigned long long get_data_bus_bitsize()
#define WB_STBIS_PORT_NAME
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.
utility function used to read files.
#define WB_WEIS_PORT_NAME
#define WB_STBOM_PORT_NAME
const ParameterConstRef parameters
Set of input parameters.
static void buildCircuit(structural_managerRef SM, structural_objectRef wrappedObj, structural_objectRef interfaceObj, const hlsRef HLS, const HLS_managerRef HLSMgr)
#define WB_SELIS_PORT_NAME
#define WB_SELOM_PORT_NAME
#define WB_ACKIM_PORT_NAME
refcount< structural_manager > structural_managerRef
RefCount type definition of the structural_manager class structure.
This file collects some utility functions.
#define WB_CYCIS_PORT_NAME
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.
Utility header to access wishbone technology library.
std::string id_type
Original type id of the structural object.
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.
std::string GetPath(std::filesystem::path path)
void set_id(const std::string &s)
Set the identifier associated with 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.
#define WORK_LIBRARY
working library.
hlsRef HLS
HLS data structure of the function to be analyzed.
#define WB_DATOM_PORT_NAME
Template borrowed from the ANTLR library by Terence Parr (http://www.jGuru.com - Software rights: htt...
DesignFlowStep_Status InternalExec() override
Execute the step.
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
#define WB_ADDRIS_PORT_NAME
Class implementation of the structural_manager.
#define WB_WEOM_PORT_NAME
#define WB_ACKOS_PORT_NAME
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.
Class specification of the manager of the tree structures extracted from the raw file.
HLS specialization of generic_device.
#define WB_ADDROM_PORT_NAME