PandA-2024.02
TopEntityMemoryMapped.cpp
Go to the documentation of this file.
1 /*
2  * _/_/_/ _/_/ _/ _/ _/_/_/ _/_/
3  * _/ _/ _/ _/ _/_/ _/ _/ _/ _/ _/
4  * _/_/_/ _/_/_/_/ _/ _/_/ _/ _/ _/_/_/_/
5  * _/ _/ _/ _/ _/ _/ _/ _/ _/
6  * _/ _/ _/ _/ _/ _/_/_/ _/ _/
7  *
8  * ***********************************************
9  * PandA Project
10  * URL: http://panda.dei.polimi.it
11  * Politecnico di Milano - DEIB
12  * System Architectures Group
13  * ***********************************************
14  * Copyright (C) 2004-2024 Politecnico di Milano
15  *
16  * This file is part of the PandA framework.
17  *
18  * The PandA framework is free software; you can redistribute it and/or modify
19  * it under the terms of the GNU General Public License as published by
20  * the Free Software Foundation; either version 3 of the License, or
21  * (at your option) any later version.
22  *
23  * This program is distributed in the hope that it will be useful,
24  * but WITHOUT ANY WARRANTY; without even the implied warranty of
25  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
26  * GNU General Public License for more details.
27  *
28  * You should have received a copy of the GNU General Public License
29  * along with this program. If not, see <http://www.gnu.org/licenses/>.
30  */
39 
40 #include "Parameter.hpp"
41 #include "behavioral_helper.hpp"
42 #include "call_graph_manager.hpp"
43 #include "copyrights_strings.hpp"
44 #include "custom_map.hpp"
45 #include "dbgPrintHelper.hpp"
46 #include "fu_binding.hpp"
47 #include "functions.hpp"
48 #include "hls.hpp"
49 #include "hls_device.hpp"
50 #include "hls_manager.hpp"
51 #include "memory.hpp"
52 #include "memory_allocation.hpp"
53 #include "memory_cs.hpp"
54 #include "memory_symbol.hpp"
55 #include "string_manipulation.hpp"
56 #include "structural_manager.hpp"
57 #include "structural_objects.hpp"
58 #include "technology_manager.hpp"
59 #include "technology_node.hpp"
60 #include "tree_helper.hpp"
61 
63  const std::list<std::string>& ParametersName);
64 
66  std::string signalName);
67 
69  structural_objectRef component);
70 
71 static void setBusSizes(structural_objectRef component, const HLS_managerRef HLSMgr);
72 
74  unsigned int _funId, const DesignFlowManagerConstRef _design_flow_manager)
75  : top_entity(_parameters, _HLSMgr, _funId, _design_flow_manager,
77  ParametersName()
78 {
79  debug_level = parameters->get_class_debug_level(GET_CLASS(*this));
80 }
81 
83 
85 {
87  const auto CGM = HLSMgr->CGetCallGraphManager();
88  const auto& top_function_ids = CGM->GetRootFunctions();
89  is_root_function = top_function_ids.count(funId);
91  is_root_function ? parameters->getOption<bool>(OPT_memory_mapped_top) : HLSMgr->hasToBeInterfaced(funId);
92  AddedComponents.clear();
93  const auto FB = HLSMgr->CGetFunctionBehavior(funId);
94  _channels_number = FB->GetChannelsNumber();
95  _channels_type = FB->GetChannelsType();
96 }
97 
99 {
100  const auto super_status = top_entity::InternalExec();
102  {
103  return super_status;
104  }
105  const auto FB = HLSMgr->CGetFunctionBehavior(funId);
106 
107  if(!is_root_function)
108  {
109  const auto& function_parameters = FB->CGetBehavioralHelper()->get_parameters();
110  for(const auto& function_parameter : function_parameters)
111  {
112  INDENT_DBG_MEX(DEBUG_LEVEL_VERY_PEDANTIC, debug_level, "---Analyzing parameter " + STR(function_parameter));
113  ParametersName.push_back(FB->CGetBehavioralHelper()->PrintVariable(function_parameter));
114  }
115  }
116 
117  INDENT_DBG_MEX(DEBUG_LEVEL_VERY_PEDANTIC, debug_level, "---Allocating parameters ");
119  INDENT_DBG_MEX(DEBUG_LEVEL_VERY_PEDANTIC, debug_level, "---Allocated parameters ");
120 
121  const auto wrappedObj = HLS->top->get_circ();
122  const auto module_name = wrappedObj->get_id();
123  wrappedObj->set_id(module_name + "_int");
124 
125  const structural_managerRef SM_mm_interface(new structural_manager(parameters));
126 
127  const structural_type_descriptorRef module_type(new structural_type_descriptor(module_name + "_int"));
128  SM_mm_interface->set_top_info(module_name, wrappedObj->get_typeRef());
129  wrappedObj->set_type(module_type);
130  HLS->top->set_top_info(module_name + "_int", 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);
134  GetPointerS<module>(interfaceObj)->set_copyright(GENERATED_COPYRIGHT);
135  GetPointerS<module>(interfaceObj)->set_authors("Component automatically generated by bambu");
136  GetPointerS<module>(interfaceObj)->set_license(GENERATED_LICENSE);
137 
138  wrappedObj->set_owner(interfaceObj);
139  wrappedObj->set_id(wrappedObj->get_id() + "_i0");
140  GetPointerS<module>(interfaceObj)->add_internal_object(wrappedObj);
141 
142  propagateInterface(SM_mm_interface, wrappedObj, ParametersName);
143 
144  HLS->Rfu->manage_module_ports(HLSMgr, HLS, SM_mm_interface, wrappedObj, 0);
145  AddedComponents.push_back(wrappedObj);
146 
147  insertStatusRegister(SM_mm_interface, wrappedObj);
148 
149  insertMemoryMappedRegister(SM_mm_interface, wrappedObj);
150 
151  insertStartDoneLogic(SM_mm_interface, wrappedObj);
152 
153  unsigned int unique_id = 0;
154  HLS->Rfu->manage_memory_ports_parallel_chained(HLSMgr, SM_mm_interface, AddedComponents, interfaceObj, HLS,
155  unique_id);
156 
157  memory::propagate_memory_parameters(interfaceObj, SM_mm_interface);
158 
159  HLS->top = SM_mm_interface;
161 }
162 
163 void TopEntityMemoryMapped::resizing_IO(module* fu_module, unsigned int max_n_ports) const
164 {
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() : 0U;
170  INDENT_DBG_MEX(DEBUG_LEVEL_VERY_PEDANTIC, debug_level, "-->Resizing input ports");
171  for(auto i = 0U; i < fu_module->get_in_port_size(); i++)
172  {
173  const auto port = fu_module->get_in_port(i);
174  if(port->get_kind() == port_vector_o_K && GetPointerS<port_o>(port)->get_ports_size() == 0)
175  {
176  GetPointerS<port_o>(port)->add_n_ports(max_n_ports, port);
177  }
178 
179  port_o::resize_if_busport(bus_size_bitsize, bus_addr_bitsize, bus_data_bitsize, bus_tag_bitsize, port);
180  }
181  INDENT_DBG_MEX(DEBUG_LEVEL_VERY_PEDANTIC, debug_level, "<--Resized input ports");
182  INDENT_DBG_MEX(DEBUG_LEVEL_VERY_PEDANTIC, debug_level, "-->Resizing output ports");
183  for(auto i = 0U; i < fu_module->get_out_port_size(); i++)
184  {
185  const auto port = fu_module->get_out_port(i);
186  if(port->get_kind() == port_vector_o_K && GetPointerS<port_o>(port)->get_ports_size() == 0)
187  {
188  GetPointerS<port_o>(port)->add_n_ports(max_n_ports, port);
189  }
190  port_o::resize_if_busport(bus_size_bitsize, bus_addr_bitsize, bus_data_bitsize, bus_tag_bitsize, port);
191  }
192  INDENT_DBG_MEX(DEBUG_LEVEL_VERY_PEDANTIC, debug_level, "<--Resized output ports");
193 }
194 
196 {
197  const auto function_behavior = HLSMgr->CGetFunctionBehavior(HLS->functionId);
198  const auto behavioral_helper = function_behavior->CGetBehavioralHelper();
199 
200  // Allocate memory for the start register.
201  auto base_address = HLSMgr->Rmem->get_symbol(funId, funId)->get_symbol_name();
202  memory::add_memory_parameter(HLS->top, base_address, STR(HLSMgr->Rmem->get_parameter_base_address(funId, funId)));
203 
204  // Allocate every parameter on chip.
205  for(const auto& topParam : behavioral_helper->get_parameters())
206  {
207  base_address = HLSMgr->Rmem->get_symbol(topParam, funId)->get_symbol_name();
208  memory::add_memory_parameter(HLS->top, base_address,
209  STR(HLSMgr->Rmem->get_parameter_base_address(funId, topParam)));
210  }
211 
212  // Allocate the return value on chip.
213  const unsigned int function_return = behavioral_helper->GetFunctionReturnType(HLS->functionId);
214  if(function_return)
215  {
216  base_address = HLSMgr->Rmem->get_symbol(function_return, funId)->get_symbol_name();
217  memory::add_memory_parameter(HLS->top, base_address,
218  STR(HLSMgr->Rmem->get_parameter_base_address(funId, function_return)));
219  }
220 }
221 
223 {
224  const auto interfaceObj = SM_mm->get_circ();
225 
226  const auto function_parameters = HLSMgr->Rmem->get_function_parameters(HLS->functionId);
227  const auto FB = HLSMgr->CGetFunctionBehavior(funId);
228  const auto BH = FB->CGetBehavioralHelper();
229 
230  const auto controlSignal = interfaceObj->find_member("ControlSignal", signal_o_K, interfaceObj);
231  const auto multi_channel_bus = _channels_type == MemoryAllocation_ChannelsType::MEM_ACC_NN;
232 
233  for(const auto& function_parameter : function_parameters)
234  {
235  // Do not consider return register and status register here.
236  if(function_parameter.first == BH->GetFunctionReturnType(HLS->functionId) ||
237  function_parameter.first == HLS->functionId)
238  {
239  continue;
240  }
241 
242  const auto signalName = BH->PrintVariable(function_parameter.first);
243  const auto component_name = multi_channel_bus ? MEMORY_MAPPED_REGISTERN_FU : MEMORY_MAPPED_REGISTER_FU;
244  const auto memoryMappedRegister =
245  SM_mm->add_module_from_technology_library("mm_register_" + signalName, component_name,
246  HLS->HLS_D->get_technology_manager()->get_library(component_name),
247  interfaceObj, HLS->HLS_D->get_technology_manager());
248  if(multi_channel_bus)
249  {
250  resizing_IO(GetPointerS<module>(memoryMappedRegister), _channels_number);
251  }
252  GetPointerS<module>(memoryMappedRegister)
253  ->SetParameter("ALLOCATED_ADDRESS",
254  HLSMgr->Rmem->get_symbol(function_parameter.first, HLS->functionId)->get_symbol_name());
255  setBusSizes(memoryMappedRegister, HLSMgr);
256 
257  connectClockAndReset(SM_mm, interfaceObj, memoryMappedRegister);
258 
259  HLS->Rfu->manage_module_ports(HLSMgr, HLS, SM_mm, memoryMappedRegister, 0);
260 
261  AddedComponents.push_back(memoryMappedRegister);
262  const auto parameterPort = wrappedObj->find_member(signalName, port_o_K, wrappedObj);
263  // out1
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()));
266 
267  if(!is_root_function)
268  {
269  // insert wDataMux
270  const auto pMux = SM_mm->add_module_from_technology_library(
271  "pMux_" + signalName, MUX_GATE_STD, HLS->HLS_D->get_technology_manager()->get_library(MUX_GATE_STD),
272  interfaceObj, HLS->HLS_D->get_technology_manager());
273 
274  const auto pMuxIn1 = pMux->find_member("in1", port_o_K, pMux);
275  GetPointerS<port_o>(pMuxIn1)->type_resize(STD_GET_SIZE(port_out1->get_typeRef()));
276  connect_with_signal_name(SM_mm, port_out1, pMuxIn1, "registerToMux" + signalName);
277 
278  const auto pMuxIn2 = pMux->find_member("in2", port_o_K, pMux);
279  GetPointerS<port_o>(pMuxIn2)->type_resize(
280  STD_GET_SIZE(interfaceObj->find_member(signalName, port_o_K, interfaceObj)->get_typeRef()));
281  SM_mm->add_connection(interfaceObj->find_member(signalName, port_o_K, interfaceObj), pMuxIn2);
282 
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()));
285  const auto sign = SM_mm->add_sign("muxTo" + signalName, SM_mm->get_circ(), pMuxOut1->get_typeRef());
286 
287  SM_mm->add_connection(pMuxOut1, sign);
288  SM_mm->add_connection(sign, parameterPort);
289 
290  SM_mm->add_connection(pMux->find_member("sel", port_o_K, pMux), controlSignal);
291  }
292  else
293  {
294  connect_with_signal_name(SM_mm, port_out1, parameterPort, "ConnectTo" + signalName);
295  }
296  }
297 
298  if(BH->GetFunctionReturnType(HLS->functionId))
299  {
300  const auto returnType = BH->GetFunctionReturnType(HLS->functionId);
301  const auto component_name = multi_channel_bus ? RETURN_MM_REGISTERN_FU : RETURN_MM_REGISTER_FU;
302  const auto returnRegister =
303  SM_mm->add_module_from_technology_library("mm_register_" + STR(RETURN_PORT_NAME), component_name,
304  HLS->HLS_D->get_technology_manager()->get_library(component_name),
305  interfaceObj, HLS->HLS_D->get_technology_manager());
306  if(multi_channel_bus)
307  {
308  resizing_IO(GetPointer<module>(returnRegister), _channels_number);
309  }
310  GetPointer<module>(returnRegister)
311  ->SetParameter("ALLOCATED_ADDRESS", HLSMgr->Rmem->get_symbol(returnType, HLS->functionId)->get_symbol_name());
312  setBusSizes(returnRegister, HLSMgr);
313  connectClockAndReset(SM_mm, interfaceObj, returnRegister);
314 
315  AddedComponents.push_back(returnRegister);
316 
317  const auto innerReturnPort = wrappedObj->find_member(RETURN_PORT_NAME, port_o_K, wrappedObj);
318  const auto returnInPort = returnRegister->find_member("in1", port_o_K, returnRegister);
319  GetPointer<port_o>(returnInPort)->set_type(innerReturnPort->get_typeRef());
320  connect_with_signal_name(SM_mm, returnInPort, innerReturnPort, "retToRegister");
321 
322  const auto outerReturnPort = interfaceObj->find_member(RETURN_PORT_NAME, port_o_K, interfaceObj);
323  if(outerReturnPort)
324  {
325  const auto returnOutPort = returnRegister->find_member("out1", port_o_K, returnRegister);
326  GetPointer<port_o>(returnOutPort)->set_type(outerReturnPort->get_typeRef());
327 
328  connect_with_signal_name(SM_mm, returnOutPort, outerReturnPort, "registerToRet");
329  }
330 
331  const auto sig_done_port = interfaceObj->find_member("sig_done_port", signal_o_K, interfaceObj);
332  SM_mm->add_connection(sig_done_port, returnRegister->find_member(DONE_PORT_NAME, port_o_K, returnRegister));
333 
334  HLS->Rfu->manage_module_ports(HLSMgr, HLS, SM_mm, returnRegister, 0);
335  }
336 }
337 
339 {
340  const auto interfaceObj = SM_mm->get_circ();
341 
342  const auto if_start_port = interfaceObj->find_member(START_PORT_NAME, port_o_K, interfaceObj);
343  const auto wrapped_start_port = wrappedObj->find_member(START_PORT_NAME, port_o_K, wrappedObj);
344  const auto reg_start_port = interfaceObj->find_member("sig_reg_start_port", signal_o_K, interfaceObj);
345 
346  if(if_start_port)
347  {
348  const auto merge_start = SM_mm->add_module_from_technology_library(
349  "merge_start", OR_GATE_STD, HLS->HLS_D->get_technology_manager()->get_library(OR_GATE_STD), interfaceObj,
350  HLS->HLS_D->get_technology_manager());
351  const auto merge_in = merge_start->find_member("in", port_o_K, merge_start);
352  const auto merge_in_port = GetPointer<port_o>(merge_in);
353  merge_in_port->add_n_ports(2, merge_in);
354 
355  SM_mm->add_connection(reg_start_port, merge_in_port->get_port(0));
356  SM_mm->add_connection(if_start_port, merge_in_port->get_port(1));
357 
358  connect_with_signal_name(SM_mm, merge_start->find_member("out1", port_o_K, merge_start), wrapped_start_port,
359  "sig_start_port");
360  }
361  else
362  {
363  SM_mm->add_connection(reg_start_port, wrapped_start_port);
364  }
365 
366  const auto if_done_port = interfaceObj->find_member(DONE_PORT_NAME, port_o_K, interfaceObj);
367  const auto sig_done_port = interfaceObj->find_member("sig_done_port", signal_o_K, interfaceObj);
368  if(if_done_port)
369  {
370  THROW_ASSERT(sig_done_port, "");
371  SM_mm->add_connection(sig_done_port, if_done_port);
372  }
373 
374  if(!is_root_function && HLSMgr->CGetCallGraphManager()->ExistsAddressedFunction())
375  {
376  const auto multi_channel_bus = _channels_type == MemoryAllocation_ChannelsType::MEM_ACC_NN;
377  const auto component_name = multi_channel_bus ? NOTYFY_CALLER_MINIMALN_FU : NOTYFY_CALLER_MINIMAL_FU;
378  const auto notifyCaller = SM_mm->add_module_from_technology_library(
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)
382  {
383  resizing_IO(GetPointerS<module>(notifyCaller), _channels_number);
384  }
385  setBusSizes(notifyCaller, HLSMgr);
386  connectClockAndReset(SM_mm, interfaceObj, notifyCaller);
387  HLS->Rfu->manage_module_ports(HLSMgr, HLS, SM_mm, notifyCaller, 0);
388  AddedComponents.push_back(notifyCaller);
389 
390  const auto NotifiedSignal = interfaceObj->find_member("Notified", signal_o_K, interfaceObj);
391  SM_mm->add_connection(notifyCaller->find_member("notified", port_o_K, notifyCaller), NotifiedSignal);
392 
393  // Connect notify address signal and sig_done_port
394  SM_mm->add_connection(sig_done_port, notifyCaller->find_member(DONE_PORT_NAME, port_o_K, notifyCaller));
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));
397  }
398 }
399 
401 {
402  const auto multi_channel_bus = _channels_type == MemoryAllocation_ChannelsType::MEM_ACC_NN;
403  const auto interfaceObj = SM_mm->get_circ();
404  const auto status_reg_name = [&]() {
405  if(!is_root_function && HLSMgr->CGetCallGraphManager()->ExistsAddressedFunction())
406  {
407  return multi_channel_bus ? STATUS_REGISTERN_FU : STATUS_REGISTER_FU;
408  }
410  }();
411  const auto statusRegister = SM_mm->add_module_from_technology_library(
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)
415  {
416  resizing_IO(GetPointer<module>(statusRegister), _channels_number);
417  }
418  GetPointerS<module>(statusRegister)
419  ->SetParameter("ALLOCATED_ADDRESS",
420  HLSMgr->Rmem->get_symbol(HLS->functionId, HLS->functionId)->get_symbol_name());
421  setBusSizes(statusRegister, HLSMgr);
422  connectClockAndReset(SM_mm, interfaceObj, statusRegister);
423 
424  HLS->Rfu->manage_module_ports(HLSMgr, HLS, SM_mm, statusRegister, 0);
425  AddedComponents.push_back(statusRegister);
426 
427  const auto donePort = wrappedObj->find_member(DONE_PORT_NAME, port_o_K, wrappedObj);
428  const auto sig_done_port = SM_mm->add_sign("sig_done_port", interfaceObj, donePort->get_typeRef());
429  SM_mm->add_connection(donePort, sig_done_port);
430  SM_mm->add_connection(sig_done_port, statusRegister->find_member(DONE_PORT_NAME, port_o_K, statusRegister));
431 
432  const auto startPort = statusRegister->find_member(START_PORT_NAME, port_o_K, statusRegister);
433  const auto sig_reg_start_port = SM_mm->add_sign("sig_reg_start_port", interfaceObj, startPort->get_typeRef());
434  SM_mm->add_connection(sig_reg_start_port, startPort);
435 
436  if(!is_root_function && HLSMgr->CGetCallGraphManager()->ExistsAddressedFunction())
437  {
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());
440  SM_mm->add_connection(ControlSignal, controlPort);
441 
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());
446  SM_mm->add_connection(notifyAddressPort, notifyAddressSignal);
447 
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());
451  SM_mm->add_connection(notifiedPort, NotifiedSignal);
452  }
453 }
454 
456  const std::list<std::string>& ParametersName)
457 {
458  THROW_ASSERT(wrappedObj, "Null wrapped object");
459  const auto interfaceObj = SM->get_circ();
460 
461  const auto wrappedModule = GetPointer<module>(wrappedObj);
462  for(unsigned int i = 0; i < wrappedModule->get_num_ports(); ++i)
463  {
464  const auto port = wrappedModule->get_positional_port(i);
465  const auto portObj = GetPointer<port_o>(port);
466 
467  const auto portID = portObj->get_id();
468  if(portID != CLOCK_PORT_NAME && portID != RESET_PORT_NAME && portID != DONE_PORT_NAME &&
469  (ParametersName.empty() || (portID != START_PORT_NAME && portID != RETURN_PORT_NAME &&
470  !std::count(ParametersName.begin(), ParametersName.end(), portID))))
471  {
472  continue;
473  }
474 
475  SM->add_port(portID, portObj->get_port_direction(), interfaceObj, portObj->get_typeRef());
476  }
477 
478  connectClockAndReset(SM, interfaceObj, wrappedObj);
479 }
480 
482  std::string signalName)
483 {
484  const auto signA = GetPointerS<port_o>(portA)->get_connected_signal();
485  const auto signB = GetPointerS<port_o>(portB)->get_connected_signal();
486 
487  if(!signA && !signB)
488  {
490  if(GetPointerS<port_o>(portA)->get_port_size() > GetPointerS<port_o>(portB)->get_port_size())
491  {
492  sign = SM->add_sign(signalName, SM->get_circ(), portA->get_typeRef());
493  }
494  else
495  {
496  sign = SM->add_sign(signalName, SM->get_circ(), portB->get_typeRef());
497  }
498 
499  SM->add_connection(portA, sign);
500  SM->add_connection(sign, portB);
501  }
502  else if(!signA && signB)
503  {
504  SM->add_connection(portA, signB);
505  }
506  else if(!signB && signA)
507  {
508  SM->add_connection(portB, signA);
509  }
510  else if(signA && signB)
511  {
512  SM->add_connection(signA, signB);
513  }
514 }
515 
517  structural_objectRef component)
518 {
519  // Clock and Reset connection
520  const auto port_ck = component->find_member(CLOCK_PORT_NAME, port_o_K, component);
521  const auto clock = interfaceObj->find_member(CLOCK_PORT_NAME, port_o_K, interfaceObj);
522  SM->add_connection(port_ck, clock);
523 
524  const auto port_rst = component->find_member(RESET_PORT_NAME, port_o_K, component);
525  const auto reset = interfaceObj->find_member(RESET_PORT_NAME, port_o_K, interfaceObj);
526  SM->add_connection(port_rst, reset);
527 }
528 
530 {
531  const auto componentModule = GetPointerS<module>(component);
532  for(unsigned int i = 0; i < componentModule->get_num_ports(); ++i)
533  {
534  const auto port = componentModule->get_positional_port(i);
535  const auto portObj = GetPointerS<port_o>(port);
536  if(portObj->get_is_data_bus())
537  {
538  portObj->type_resize(HLSMgr->Rmem->get_bus_data_bitsize());
539  }
540  else if(portObj->get_is_addr_bus())
541  {
542  portObj->type_resize(HLSMgr->get_address_bitsize());
543  }
544  else if(portObj->get_is_size_bus())
545  {
546  portObj->type_resize(HLSMgr->Rmem->get_bus_size_bitsize());
547  }
548  }
549 }
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...
Definition: memory.cpp:654
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
Definition: top_entity.hpp:54
#define DEBUG_LEVEL_VERY_PEDANTIC
extremely verbose debugging print is performed.
const HLS_managerRef HLSMgr
information about all the HLS synthesis
Definition: hls_step.hpp:205
#define OR_GATE_STD
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.
Definition: top_entity.cpp:110
File containing functions and utilities to support the printing of debug messagges.
#define MEMORY_MAPPED_REGISTERN_FU
#define START_PORT_NAME
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
Definition: hls.hpp:169
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.
#define GENERATED_LICENSE
#define NOTYFY_CALLER_MINIMALN_FU
const structural_objectRef get_circ() const
Get a reference to circ field.
void reset()
Definition: adpcm.c:540
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
Definition: hls.hpp:107
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)
#define RETURN_PORT_NAME
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.
Definition: memory.cpp:725
std::list< structural_objectRef > AddedComponents
#define CLOCK_PORT_NAME
standard name for ports
structural_managerRef top
Store the top description.
Definition: hls.hpp:164
#define STATUS_REGISTER_NO_NOTIFIED_FU
fu_bindingRef Rfu
Store the refcounted functional unit binding of the operations.
Definition: hls.hpp:121
#define STATUS_REGISTERN_FU
void set_top_info(const std::string &id, const technology_managerRef &LM, const std::string &Library="")
#define DONE_PORT_NAME
HLSFlowStep_Type
Definition: hls_step.hpp:95
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.
#define MUX_GATE_STD
unsigned int functionId
this is the identifier of the function to be implemented
Definition: hls.hpp:87
void insertMemoryMappedRegister(structural_managerRef SM, structural_objectRef wrappedObj)
#define RESET_PORT_NAME
Wrapper to call graph.
#define RETURN_MM_REGISTER_FU
Class implementation of the structural_manager.
uint32_t sign
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 ...
Definition: exceptions.hpp:289

Generated on Mon Feb 12 2024 13:02:53 for PandA-2024.02 by doxygen 1.8.13