PandA-2024.02
WB4_interface.cpp
Go to the documentation of this file.
1 /*
2  *
3  * _/_/_/ _/_/ _/ _/ _/_/_/ _/_/
4  * _/ _/ _/ _/ _/_/ _/ _/ _/ _/ _/
5  * _/_/_/ _/_/_/_/ _/ _/_/ _/ _/ _/_/_/_/
6  * _/ _/ _/ _/ _/ _/ _/ _/ _/
7  * _/ _/ _/ _/ _/ _/_/_/ _/ _/
8  *
9  * ***********************************************
10  * PandA Project
11  * URL: http://panda.dei.polimi.it
12  * Politecnico di Milano - DEIB
13  * System Architectures Group
14  * ***********************************************
15  * Copyright (C) 2004-2024 Politecnico di Milano
16  *
17  * This file is part of the PandA framework.
18  *
19  * The PandA framework is free software; you can redistribute it and/or modify
20  * it under the terms of the GNU General Public License as published by
21  * the Free Software Foundation; either version 3 of the License, or
22  * (at your option) any later version.
23  *
24  * This program is distributed in the hope that it will be useful,
25  * but WITHOUT ANY WARRANTY; without even the implied warranty of
26  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
27  * GNU General Public License for more details.
28  *
29  * You should have received a copy of the GNU General Public License
30  * along with this program. If not, see <http://www.gnu.org/licenses/>.
31  *
32  */
49 #include "WB4_interface.hpp"
50 #include "HDL_manager.hpp"
51 #include "Parameter.hpp"
52 #include "application_manager.hpp"
53 #include "behavioral_helper.hpp"
54 #include "copyrights_strings.hpp"
55 #include "hls.hpp"
56 #include "hls_constraints.hpp"
57 #include "hls_device.hpp"
58 #include "hls_manager.hpp"
59 #include "language_writer.hpp"
60 #include "memory.hpp"
61 #include "memory_allocation.hpp"
62 #include "structural_manager.hpp"
63 #include "structural_objects.hpp"
64 #include "technology_manager.hpp"
65 #include "technology_node.hpp"
66 #include "technology_wishbone.hpp"
67 #include "tree_helper.hpp"
68 #include "tree_manager.hpp"
69 
70 WB4_interface::WB4_interface(const ParameterConstRef _parameters, const HLS_managerRef _HLSMgr, unsigned int _funId,
71  const DesignFlowManagerConstRef _design_flow_manager,
72  const HLSFlowStep_Type _hls_flow_step_type)
73  : minimal_interface(_parameters, _HLSMgr, _funId, _design_flow_manager, _hls_flow_step_type)
74 {
75 }
76 
78 
80 {
81  // WB4 construction starts on top of the minimal interface.
83 
84  const structural_managerRef SM = HLS->top;
85 
86  structural_objectRef wrappedObj = SM->get_circ();
87  std::string module_name = wrappedObj->get_id() + "_wb4_interface";
88 
90  structural_type_descriptorRef module_type =
92  SM_wb4_interface->set_top_info(module_name, module_type);
93  structural_objectRef interfaceObj = SM_wb4_interface->get_circ();
94 
95  // add the core to the wrapper
96  wrappedObj->set_owner(interfaceObj);
97  wrappedObj->set_id(wrappedObj->get_id() + "_i0");
98 
99  GetPointer<module>(interfaceObj)->add_internal_object(wrappedObj);
101  GetPointer<module>(interfaceObj)
102  ->set_description("WB4 interface for top component: " + wrappedObj->get_typeRef()->id_type);
103  GetPointer<module>(interfaceObj)->set_copyright(GENERATED_COPYRIGHT);
104  GetPointer<module>(interfaceObj)->set_authors("Component automatically generated by bambu");
105  GetPointer<module>(interfaceObj)->set_license(GENERATED_LICENSE);
106 
107  build_WB4_bus_interface(SM_wb4_interface);
108 
109  build_WB4_complete_logic(SM_wb4_interface, wrappedObj, interfaceObj);
110 
111  if(parameters->isOption(OPT_expose_globals) && parameters->getOption<bool>(OPT_expose_globals))
112  {
113  memory::propagate_memory_parameters(HLS->top->get_circ(), SM_wb4_interface);
114  }
115 
116  // Generation completed
117  HLS->top = SM_wb4_interface;
119 }
120 
122 {
123  const auto function_behavior = HLSMgr->CGetFunctionBehavior(HLS->functionId);
124  const auto behavioral_helper = function_behavior->CGetBehavioralHelper();
125  const auto function_parameters = HLSMgr->Rmem->get_function_parameters(HLS->functionId);
126 
127  auto data_bus_bitsize = HLSMgr->Rmem->get_bus_data_bitsize();
128  for(const auto& function_parameter : function_parameters)
129  {
130  if(function_parameter.first != HLS->functionId)
131  {
132  data_bus_bitsize =
133  std::max(data_bus_bitsize,
134  tree_helper::Size(HLSMgr->get_tree_manager()->CGetTreeReindex(function_parameter.first)));
135  }
136  }
137  return data_bus_bitsize;
138 }
139 
141 {
142  auto addr_bus_bitsize = HLSMgr->get_address_bitsize();
143  auto allocated_space = HLSMgr->Rmem->get_max_address();
144  unsigned int parameter_addr_bit = 1;
145  while(allocated_space >>= 1)
146  {
147  ++parameter_addr_bit;
148  }
149 
150  return std::max(parameter_addr_bit, addr_bus_bitsize);
151 }
152 
154 {
155  structural_objectRef interfaceObj = SM->get_circ();
156 
158 
159  auto data_bus_bitsize = get_data_bus_bitsize();
160  auto addr_bus_bitsize = get_addr_bus_bitsize();
161 
163  structural_type_descriptorRef(new structural_type_descriptor("bool", data_bus_bitsize / 8));
165  structural_type_descriptorRef(new structural_type_descriptor("bool", addr_bus_bitsize));
167  structural_type_descriptorRef(new structural_type_descriptor("bool", data_bus_bitsize));
168 
169  // Parameters
170  std::string functionName = tree_helper::name_function(HLSMgr->get_tree_manager(), HLS->functionId);
171  memory::add_memory_parameter(SM, STR(WB_BASE_ADDRESS) + "_" + functionName, STR(0));
172 
173  // Common Inputs
174  SM->add_port(CLOCK_PORT_NAME, port_o::IN, interfaceObj, b_type);
175  SM->add_port(RESET_PORT_NAME, port_o::IN, interfaceObj, b_type);
176  SM->add_port(WB_IRQ_PORT_NAME, port_o::OUT, interfaceObj, b_type);
177 
178  // Master Inputs
179  SM->add_port(WB_DATIM_PORT_NAME, port_o::IN, interfaceObj, data_type);
180  SM->add_port(WB_ACKIM_PORT_NAME, port_o::IN, interfaceObj, b_type);
181 
182  // Master Outputs
183  SM->add_port(WB_CYCOM_PORT_NAME, port_o::OUT, interfaceObj, b_type);
184  SM->add_port(WB_STBOM_PORT_NAME, port_o::OUT, interfaceObj, b_type);
185  SM->add_port(WB_WEOM_PORT_NAME, port_o::OUT, interfaceObj, b_type);
186  SM->add_port(WB_ADDROM_PORT_NAME, port_o::OUT, interfaceObj, addr_type);
187  SM->add_port(WB_DATOM_PORT_NAME, port_o::OUT, interfaceObj, data_type);
188  SM->add_port(WB_SELOM_PORT_NAME, port_o::OUT, interfaceObj, sel_type);
189 
190  // Slave Inputs
191  SM->add_port(WB_CYCIS_PORT_NAME, port_o::IN, interfaceObj, b_type);
192  SM->add_port(WB_STBIS_PORT_NAME, port_o::IN, interfaceObj, b_type);
193  SM->add_port(WB_WEIS_PORT_NAME, port_o::IN, interfaceObj, b_type);
194  SM->add_port(WB_ADDRIS_PORT_NAME, port_o::IN, interfaceObj, addr_type);
195  SM->add_port(WB_DATIS_PORT_NAME, port_o::IN, interfaceObj, data_type);
196  SM->add_port(WB_SELIS_PORT_NAME, port_o::IN, interfaceObj, sel_type);
197 
198  // Slave Outputs
199  SM->add_port(WB_DATOS_PORT_NAME, port_o::OUT, interfaceObj, data_type);
200  SM->add_port(WB_ACKOS_PORT_NAME, port_o::OUT, interfaceObj, b_type);
201 }
202 
204  structural_objectRef portB, std::string signalName)
205 {
206  structural_objectRef signA = GetPointer<port_o>(portA)->get_connected_signal();
207  structural_objectRef signB = GetPointer<port_o>(portB)->get_connected_signal();
208 
209  THROW_ASSERT(portA->get_kind() == port_o_K && portB->get_kind() == port_o_K,
210  "WB4 Interface portA = " + portA->get_path() + " portB = " + portB->get_path());
211 
212  // std::cerr << "CONNECT SIGNAL NAME: " << signalName << "\n";
213  // std::cerr << "CONNECT SIGNAL: size A = " << GET_TYPE_SIZE(portA)
214  // << " size B = " << GET_TYPE_SIZE(portB) << "\n";
215  if(!signA && !signB)
216  {
218  if(GET_TYPE_SIZE(portA) < GET_TYPE_SIZE(portB))
219  {
220  // std::cerr << "using size A\n";
221  sign = SM->add_sign(signalName, SM->get_circ(), portA->get_typeRef());
222  }
223  else
224  {
225  // std::cerr << "using size B\n";
226  sign = SM->add_sign(signalName, SM->get_circ(), portB->get_typeRef());
227  }
228  SM->add_connection(portA, sign);
229  SM->add_connection(sign, portB);
230  }
231  else if(!signA && signB)
232  {
233  SM->add_connection(portA, signB);
234  }
235  else if(!signB && signA)
236  {
237  SM->add_connection(portB, signA);
238  }
239  else if(signA && signB)
240  {
241  SM->add_connection(signA, signB);
242  }
243 }
244 
246  structural_objectRef B, std::string Bsignal, const std::string& signalName)
247 {
248  structural_objectRef port1 = A->find_member(Asignal, port_o_K, A);
249  structural_objectRef port2 = B->find_member(Bsignal, port_o_K, B);
250  connect_with_signal_name(SM, port1, port2, signalName);
251 }
252 
254  structural_objectRef B, std::string Bsignal, const std::string& signalName)
255 {
256  structural_objectRef port1 = B->find_member(Bsignal, port_o_K, B);
257  connect_with_signal_name(SM, APort, port1, signalName);
258 }
259 
261  structural_objectRef portB)
262 {
263  connect_with_signal_name(SM, portA, portB, portA->get_id() + "_INT");
264 }
265 
267  structural_objectRef B, std::string Bsignal)
268 {
269  structural_objectRef port1 = A->find_member(Asignal, port_o_K, A);
270  structural_objectRef port2 = B->find_member(Bsignal, port_o_K, B);
271  connect_with_signal(SM, port1, port2);
272 }
273 
275  std::string Bsignal)
276 {
277  structural_objectRef port2 = B->find_member(Bsignal, port_o_K, B);
278  connect_with_signal(SM, APort, port2);
279 }
280 
282  structural_objectRef portB)
283 {
284  structural_objectRef port1 = A->find_member(Asignal, port_o_K, A);
285  connect_with_signal(SM, port1, portB);
286 }
287 
289  structural_objectRef interfaceObj)
290 {
291  // Master OUT
292  structural_objectRef Mout_data_ram_size_port = wrappedObj->find_member("Mout_data_ram_size", port_o_K, wrappedObj);
293  structural_objectRef Mout_Wdata_ram_port = wrappedObj->find_member("Mout_Wdata_ram", port_o_K, wrappedObj);
294  structural_objectRef Mout_addr_ram_port = wrappedObj->find_member("Mout_addr_ram", port_o_K, wrappedObj);
295  structural_objectRef Mout_we_ram_port = wrappedObj->find_member("Mout_we_ram", port_o_K, wrappedObj);
296  structural_objectRef Mout_oe_ram_port = wrappedObj->find_member("Mout_oe_ram", port_o_K, wrappedObj);
297  // Master IN
298  structural_objectRef M_DataRdy_port = wrappedObj->find_member("M_DataRdy", port_o_K, wrappedObj);
299  structural_objectRef M_Rdata_ram_port = wrappedObj->find_member("M_Rdata_ram", port_o_K, wrappedObj);
300  // Slave OUT
301  structural_objectRef Sout_DataRdy_port = wrappedObj->find_member("Sout_DataRdy", port_o_K, wrappedObj);
302  structural_objectRef Sout_Rdata_ram_port = wrappedObj->find_member("Sout_Rdata_ram", port_o_K, wrappedObj);
303  // Slave IN
304  structural_objectRef S_data_ram_size_port = wrappedObj->find_member("S_data_ram_size", port_o_K, wrappedObj);
305  structural_objectRef S_Wdata_ram_port = wrappedObj->find_member("S_Wdata_ram", port_o_K, wrappedObj);
306  structural_objectRef S_addr_ram_port = wrappedObj->find_member("S_addr_ram", port_o_K, wrappedObj);
307  structural_objectRef S_we_ram_port = wrappedObj->find_member("S_we_ram", port_o_K, wrappedObj);
308  structural_objectRef S_oe_ram_port = wrappedObj->find_member("S_oe_ram", port_o_K, wrappedObj);
309 
310  // check consitency of the interfaces
311  bool is_slave = false, is_master = false;
312  bool only_mm_parameters_allocated =
313  HLSMgr->Rmem->get_allocated_parameters_memory() == HLSMgr->Rmem->get_allocated_internal_memory();
314 
315  if(S_data_ram_size_port && S_Wdata_ram_port && S_addr_ram_port && S_we_ram_port && S_oe_ram_port &&
316  Sout_DataRdy_port && Sout_Rdata_ram_port)
317  {
318  is_slave = true;
319  }
320  else if(!S_data_ram_size_port && !S_Wdata_ram_port && !S_addr_ram_port && !S_we_ram_port && !S_oe_ram_port &&
321  !Sout_DataRdy_port && !Sout_Rdata_ram_port)
322  {
323  is_slave = false;
324  }
325  else
326  {
327  THROW_UNREACHABLE("Inconsistent slave interface");
328  }
329 
330  if(Mout_data_ram_size_port && Mout_Wdata_ram_port && Mout_addr_ram_port && Mout_we_ram_port && Mout_oe_ram_port &&
331  M_DataRdy_port && M_Rdata_ram_port)
332  {
333  is_master = true;
334  }
335  else if(!Mout_data_ram_size_port && !Mout_Wdata_ram_port && !Mout_addr_ram_port && !Mout_we_ram_port &&
336  !Mout_oe_ram_port && !M_DataRdy_port && !M_Rdata_ram_port)
337  {
338  is_master = false;
339  }
340  else
341  {
342  THROW_UNREACHABLE("Inconsistent master interface");
343  }
344 
345  // check memory allocation consistency
346  if(HLSMgr->Rmem->get_max_address() > parameters->getOption<unsigned long long int>(OPT_base_address))
347  {
348  THROW_ERROR("Internal memory addresses overlap with the external addresses: change the base address value with "
349  "--base-address");
350  }
351 
352  // Connect clock, start, reset and done port since they are always present
353  SM->add_connection(interfaceObj->find_member(CLOCK_PORT_NAME, port_o_K, interfaceObj),
354  wrappedObj->find_member(CLOCK_PORT_NAME, port_o_K, wrappedObj));
355 
356  SM->add_connection(interfaceObj->find_member(RESET_PORT_NAME, port_o_K, interfaceObj),
357  wrappedObj->find_member(RESET_PORT_NAME, port_o_K, wrappedObj));
358 
359  connect_with_signal_name(SM, wrappedObj, DONE_PORT_NAME, interfaceObj, WB_IRQ_PORT_NAME,
360  STR(DONE_PORT_NAME) + "_INT");
361 
362  auto data_bus_bitsize = get_data_bus_bitsize();
363  auto addr_bus_bitsize = get_addr_bus_bitsize();
364 
366  structural_type_descriptorRef(new structural_type_descriptor("bool", addr_bus_bitsize));
367 
369  structural_type_descriptorRef(new structural_type_descriptor("bool", data_bus_bitsize));
370 
372  structural_type_descriptorRef(new structural_type_descriptor("bool", data_bus_bitsize / 8));
373 
374  std::string functionName = tree_helper::name_function(HLSMgr->get_tree_manager(), HLS->functionId);
375  std::string baseAddressParameter = STR(WB_BASE_ADDRESS) + "_" + functionName;
376  // ---- Add the master output control logic ----
377  structural_objectRef signControl;
378  structural_objectRef signControl_delayed;
379  if(is_master)
380  {
381  PRINT_DBG_MEX(OUTPUT_LEVEL_VERBOSE, debug_level, "Adding master output control logic");
382  connect_with_signal(SM, Mout_we_ram_port, interfaceObj->find_member(WB_WEOM_PORT_NAME, port_o_K, interfaceObj));
383 
385  "orGateReWe", OR_GATE_STD, LIBRARY_STD, interfaceObj, HLS->HLS_D->get_technology_manager());
386 
387  structural_objectRef port_objReWe = orGateReWe->find_member("in", port_o_K, orGateReWe);
388  auto* in_portReWe = GetPointer<port_o>(port_objReWe);
389  in_portReWe->add_n_ports(2, port_objReWe);
390 
391  connect_with_signal(SM, Mout_we_ram_port, in_portReWe->get_port(0));
392  connect_with_signal(SM, Mout_oe_ram_port, in_portReWe->get_port(1));
393 
395  "notGateSTB", NOT_GATE_STD, LIBRARY_STD, interfaceObj, HLS->HLS_D->get_technology_manager());
396 
397  SM->add_connection(interfaceObj->find_member(WB_ACKIM_PORT_NAME, port_o_K, interfaceObj),
398  notGateSTB->find_member("in1", port_o_K, notGateSTB));
399 
401  "andGateSTB", AND_GATE_STD, LIBRARY_STD, interfaceObj, HLS->HLS_D->get_technology_manager());
402 
403  structural_objectRef port_objAndSTB = andGateSTB->find_member("in", port_o_K, andGateSTB);
404  auto* in_portAndSTB = GetPointer<port_o>(port_objAndSTB);
405  in_portAndSTB->add_n_ports(2, port_objAndSTB);
406 
407  connect_with_signal_name(SM, notGateSTB->find_member("out1", port_o_K, notGateSTB), in_portAndSTB->get_port(1),
408  "NotAckIM");
409  SM->add_connection(andGateSTB->find_member("out1", port_o_K, andGateSTB),
410  interfaceObj->find_member(WB_STBOM_PORT_NAME, port_o_K, interfaceObj));
411 
412  if(is_slave) // add the control logic for the multiplexers
413  {
414  PRINT_DBG_MEX(OUTPUT_LEVEL_VERBOSE, debug_level, "Adding mux control logic");
415 
416  PRINT_DBG_MEX(DEBUG_LEVEL_VERBOSE, debug_level, "Adding addressRangeChecker");
417  structural_objectRef addressRangeChecker =
419  interfaceObj, HLS->HLS_D->get_technology_manager());
420 
421  structural_objectRef arcAddress = addressRangeChecker->find_member("address", port_o_K, addressRangeChecker);
422  GetPointer<port_o>(arcAddress)->set_type(addr_type);
423  connect_with_signal(SM, Mout_addr_ram_port, arcAddress);
424 
425  structural_objectRef arcBase = addressRangeChecker->find_member("base", port_o_K, addressRangeChecker);
426  GetPointer<port_o>(arcBase)->set_type(addr_type);
427 
428  structural_objectRef arcMaxAddress =
429  addressRangeChecker->find_member("max_address", port_o_K, addressRangeChecker);
430  GetPointer<port_o>(arcMaxAddress)->set_type(addr_type);
431 
433  "const_base_address", CONSTANT_STD, LIBRARY_STD, interfaceObj, HLS->HLS_D->get_technology_manager());
434 
435  structural_objectRef constBaseAddressOut1 = constBaseAddress->find_member("out1", port_o_K, constBaseAddress);
436  GetPointer<port_o>(constBaseAddressOut1)->set_type(addr_type);
437  constBaseAddress->SetParameter("value", baseAddressParameter + " + " +
438  STR(HLSMgr->Rmem->get_first_address(HLS->functionId)));
439  connect_with_signal(SM, addressRangeChecker, "base", constBaseAddress, "out1");
440 
442  "const_max_address", CONSTANT_STD, LIBRARY_STD, interfaceObj, HLS->HLS_D->get_technology_manager());
443 
444  structural_objectRef constMaxAddressOut1 = constMaxAddress->find_member("out1", port_o_K, constMaxAddress);
445  GetPointer<port_o>(constMaxAddressOut1)->set_type(addr_type);
446  constMaxAddress->SetParameter("value", baseAddressParameter + " + " +
447  STR(HLSMgr->Rmem->get_last_address(HLS->functionId, HLSMgr)));
448  connect_with_signal(SM, addressRangeChecker, "max_address", constMaxAddress, "out1");
449  PRINT_DBG_MEX(DEBUG_LEVEL_VERBOSE, debug_level, "Added addressRangeChecker");
450 
451  PRINT_DBG_MEX(DEBUG_LEVEL_VERBOSE, debug_level, "Adding control signal");
453  "internalNotGate", NOT_GATE_STD, LIBRARY_STD, interfaceObj, HLS->HLS_D->get_technology_manager());
454  connect_with_signal_name(SM, addressRangeChecker, "isInRange", internalNotGate, "in1", "internal");
455  structural_objectRef signNotInternal =
456  SM->add_sign("notInternal", SM->get_circ(),
457  internalNotGate->find_member("out1", port_o_K, internalNotGate)->get_typeRef());
458  SM->add_connection(internalNotGate->find_member("out1", port_o_K, internalNotGate), signNotInternal);
459  if(!only_mm_parameters_allocated)
460  {
462  "orGateControl", OR_GATE_STD, LIBRARY_STD, interfaceObj, HLS->HLS_D->get_technology_manager());
463  structural_objectRef port_objControl = orGateControl->find_member("in", port_o_K, orGateControl);
464  auto* in_portControl = GetPointer<port_o>(port_objControl);
465  in_portControl->add_n_ports(2, port_objControl);
466 
467  SM->add_connection(signNotInternal, in_portControl->get_port(0));
468  SM->add_connection(interfaceObj->find_member(WB_STBIS_PORT_NAME, port_o_K, interfaceObj),
469  in_portControl->get_port(1));
470 
471  signControl = SM->add_sign("control", SM->get_circ(), in_portControl->get_port(0)->get_typeRef());
472  SM->add_connection(signControl, orGateControl->find_member("out1", port_o_K, orGateControl));
473  PRINT_DBG_MEX(DEBUG_LEVEL_VERBOSE, debug_level, "Added control signal");
474 
475  const auto memory_allocation_policy = HLSMgr->CGetFunctionBehavior(funId)->GetMemoryAllocationPolicy();
476  const auto Has_extern_allocated_data =
477  ((HLSMgr->Rmem->get_memory_address() - HLSMgr->base_address) > 0 &&
478  memory_allocation_policy != MemoryAllocation_Policy::EXT_PIPELINED_BRAM) ||
479  (HLSMgr->Rmem->has_unknown_addresses() &&
480  memory_allocation_policy != MemoryAllocation_Policy::ALL_BRAM &&
481  memory_allocation_policy != MemoryAllocation_Policy::EXT_PIPELINED_BRAM);
482  if(Has_extern_allocated_data)
483  {
484  signControl_delayed = signControl;
485  }
486  else
487  {
488  PRINT_DBG_MEX(DEBUG_LEVEL_VERBOSE, debug_level, "Adding delayed mux control logic");
489  structural_objectRef internalNotGate_delayed =
491  interfaceObj, HLS->HLS_D->get_technology_manager());
492 
493  connect_with_signal_name(SM, addressRangeChecker, "isInRange", internalNotGate_delayed, "internal1",
494  "internal");
495  structural_objectRef port_ck1 =
496  internalNotGate_delayed->find_member(CLOCK_PORT_NAME, port_o_K, internalNotGate_delayed);
497  structural_objectRef clock1 = interfaceObj->find_member(CLOCK_PORT_NAME, port_o_K, interfaceObj);
498 
499  SM->add_connection(port_ck1, clock1);
500  connect_with_signal(SM, Mout_we_ram_port, internalNotGate_delayed, "we1");
501  connect_with_signal(SM, Mout_oe_ram_port, internalNotGate_delayed, "oe1");
502 
503  structural_objectRef orGateControl_delayed =
504  SM->add_module_from_technology_library("orGateControl_delayed", OR_GATE_STD, LIBRARY_STD,
505  interfaceObj, HLS->HLS_D->get_technology_manager());
506  structural_objectRef port_objControl_delayed =
507  orGateControl_delayed->find_member("in", port_o_K, orGateControl_delayed);
508  auto* in_portControl_delayed = GetPointer<port_o>(port_objControl_delayed);
509  in_portControl_delayed->add_n_ports(2, port_objControl_delayed);
510 
511  structural_objectRef signNotInternal_delayed = SM->add_sign(
512  "notInternal_delayed", SM->get_circ(), in_portControl_delayed->get_port(0)->get_typeRef());
513 
514  SM->add_connection(signNotInternal_delayed,
515  internalNotGate_delayed->find_member("out1", port_o_K, internalNotGate_delayed));
516  SM->add_connection(signNotInternal_delayed, in_portControl_delayed->get_port(0));
517  SM->add_connection(in_portControl_delayed->get_port(1),
518  interfaceObj->find_member(WB_STBIS_PORT_NAME, port_o_K, interfaceObj));
519 
520  signControl_delayed =
521  SM->add_sign("control_delayed", SM->get_circ(), in_portControl->get_port(0)->get_typeRef());
522  SM->add_connection(signControl_delayed,
523  orGateControl_delayed->find_member("out1", port_o_K, orGateControl_delayed));
524  PRINT_DBG_MEX(DEBUG_LEVEL_VERBOSE, debug_level, "Added delayed mux control logic");
525  }
526  }
527 
528  PRINT_DBG_MEX(DEBUG_LEVEL_VERBOSE, debug_level, "Connecting mux control logic to master output logic");
530  "andGateStbCyc", AND_GATE_STD, LIBRARY_STD, interfaceObj, HLS->HLS_D->get_technology_manager());
531 
532  structural_objectRef port_objStbCyc = andGateStbCyc->find_member("in", port_o_K, andGateStbCyc);
533  auto* in_portStbCyc = GetPointer<port_o>(port_objStbCyc);
534  in_portStbCyc->add_n_ports(2, port_objStbCyc);
535 
536  SM->add_connection(signNotInternal, in_portStbCyc->get_port(1));
537  connect_with_signal_name(SM, orGateReWe->find_member("out1", port_o_K, orGateReWe), in_portStbCyc->get_port(0),
538  "Mout_we_or_oe");
539 
540  connect_with_signal_name(SM, andGateStbCyc->find_member("out1", port_o_K, andGateStbCyc),
541  in_portAndSTB->get_port(0), "StbCyc");
542  connect_with_signal_name(SM, andGateStbCyc->find_member("out1", port_o_K, andGateStbCyc),
543  interfaceObj->find_member(WB_CYCOM_PORT_NAME, port_o_K, interfaceObj), "StbCyc");
544  PRINT_DBG_MEX(DEBUG_LEVEL_VERBOSE, debug_level, "Connected mux control logic to master output logic");
545 
546  PRINT_DBG_MEX(OUTPUT_LEVEL_VERBOSE, debug_level, "Added mux control logic");
547  }
548  else // no need for multiplexers nor range checker. master output control logic is also easier
549  {
550  connect_with_signal_name(SM, orGateReWe->find_member("out1", port_o_K, orGateReWe),
551  interfaceObj->find_member(WB_CYCOM_PORT_NAME, port_o_K, interfaceObj),
552  "Mout_we_or_oe");
553  connect_with_signal_name(SM, orGateReWe->find_member("out1", port_o_K, orGateReWe), in_portAndSTB->get_port(0),
554  "Mout_we_or_oe");
555  }
556  PRINT_DBG_MEX(OUTPUT_LEVEL_VERBOSE, debug_level, "Added master output control logic");
557  }
558 
559  THROW_ASSERT(((is_master && is_slave) && ((signControl && signControl_delayed) || only_mm_parameters_allocated)) ||
560  (!(is_master && is_slave) && !signControl && !signControl_delayed),
561  "If we have both master and slave we need control signals for multiplexers");
562 
563  // ---- Add the slave input R/W enable signals ----
564  if(is_slave)
565  {
566  PRINT_DBG_MEX(DEBUG_LEVEL_VERBOSE, debug_level, "Adding slave input R/W enable logic");
568  "andGateWeICS", AND_GATE_STD, LIBRARY_STD, interfaceObj, HLS->HLS_D->get_technology_manager());
569  structural_objectRef port_objWeICS = andGateWeICS->find_member("in", port_o_K, andGateWeICS);
570  auto* in_portWeICS = GetPointer<port_o>(port_objWeICS);
571  in_portWeICS->add_n_ports(3, port_objWeICS);
572 
573  SM->add_connection(interfaceObj->find_member(WB_WEIS_PORT_NAME, port_o_K, interfaceObj),
574  in_portWeICS->get_port(0));
575  SM->add_connection(interfaceObj->find_member(WB_STBIS_PORT_NAME, port_o_K, interfaceObj),
576  in_portWeICS->get_port(1));
577  SM->add_connection(interfaceObj->find_member(WB_CYCIS_PORT_NAME, port_o_K, interfaceObj),
578  in_portWeICS->get_port(2));
579 
581  "weISNotGate", NOT_GATE_STD, LIBRARY_STD, interfaceObj, HLS->HLS_D->get_technology_manager());
582  SM->add_connection(interfaceObj->find_member(WB_WEIS_PORT_NAME, port_o_K, interfaceObj),
583  weISNotGate->find_member("in1", port_o_K, weISNotGate));
584 
586  "andGateReICS", AND_GATE_STD, LIBRARY_STD, interfaceObj, HLS->HLS_D->get_technology_manager());
587  structural_objectRef port_objReICS = andGateReICS->find_member("in", port_o_K, andGateReICS);
588  auto* in_portReICS = GetPointer<port_o>(port_objReICS);
589  in_portReICS->add_n_ports(3, port_objReICS);
590 
591  structural_objectRef signNotWeIS =
592  SM->add_sign("notWeIS", SM->get_circ(), in_portReICS->get_port(0)->get_typeRef());
593 
594  SM->add_connection(weISNotGate->find_member("out1", port_o_K, weISNotGate), signNotWeIS);
595  SM->add_connection(signNotWeIS, in_portReICS->get_port(0));
596  SM->add_connection(interfaceObj->find_member(WB_STBIS_PORT_NAME, port_o_K, interfaceObj),
597  in_portReICS->get_port(1));
598  SM->add_connection(interfaceObj->find_member(WB_CYCIS_PORT_NAME, port_o_K, interfaceObj),
599  in_portReICS->get_port(2));
600  PRINT_DBG_MEX(DEBUG_LEVEL_VERBOSE, debug_level, "Added slave input R/W enable logic");
601  if(is_master)
602  {
603  if(only_mm_parameters_allocated)
604  {
605  connect_with_signal_name(SM, S_we_ram_port, andGateWeICS, "out1", "weI_CS");
606  connect_with_signal_name(SM, S_oe_ram_port, andGateReICS, "out1", "reI_CS");
607  }
608  else
609  {
610  PRINT_DBG_MEX(DEBUG_LEVEL_VERBOSE, debug_level, "Inserting weMux");
611  // insert weMux
613  "weMux", MUX_GATE_STD, HLS->HLS_D->get_technology_manager()->get_library(MUX_GATE_STD), interfaceObj,
614  HLS->HLS_D->get_technology_manager());
615 
616  connect_with_signal_name(SM, andGateWeICS, "out1", weMux, "in1", "weI_CS");
617  connect_with_signal(SM, Mout_we_ram_port, weMux->find_member("in2", port_o_K, weMux));
618  connect_with_signal(SM, S_we_ram_port, weMux->find_member("out1", port_o_K, weMux));
619  SM->add_connection(signControl, weMux->find_member("sel", port_o_K, weMux));
620  PRINT_DBG_MEX(DEBUG_LEVEL_VERBOSE, debug_level, "Inserted weMux");
621  PRINT_DBG_MEX(DEBUG_LEVEL_VERBOSE, debug_level, "Inserting oeMux");
622  // insert oeMux
624  "oeMux", MUX_GATE_STD, HLS->HLS_D->get_technology_manager()->get_library(MUX_GATE_STD), interfaceObj,
625  HLS->HLS_D->get_technology_manager());
626 
627  connect_with_signal_name(SM, andGateReICS, "out1", oeMux, "in1", "reI_CS");
628  connect_with_signal(SM, Mout_oe_ram_port, oeMux->find_member("in2", port_o_K, oeMux));
629  connect_with_signal(SM, S_oe_ram_port, oeMux->find_member("out1", port_o_K, oeMux));
630  SM->add_connection(signControl, oeMux->find_member("sel", port_o_K, oeMux));
631  PRINT_DBG_MEX(DEBUG_LEVEL_VERBOSE, debug_level, "Inserted oeMux");
632  }
633  }
634  else
635  {
636  // no need for multiplexing, connect directly
637  connect_with_signal_name(SM, S_we_ram_port, andGateWeICS, "out1", "weI_CS");
638  connect_with_signal_name(SM, S_oe_ram_port, andGateReICS, "out1", "reI_CS");
639  }
640  }
641 
642  // ---- Add the Wdata logic ----
643  if(is_master)
644  {
645  PRINT_DBG_MEX(DEBUG_LEVEL_VERBOSE, debug_level, "Connecting Mout_Wdata_ram");
646  connect_with_signal(SM, Mout_Wdata_ram_port,
647  interfaceObj->find_member(WB_DATOM_PORT_NAME, port_o_K, interfaceObj));
648  PRINT_DBG_MEX(DEBUG_LEVEL_VERBOSE, debug_level, "Connected Mout_Wdata_ram");
649  }
650  if(is_slave)
651  {
652  if(is_master)
653  {
654  if(only_mm_parameters_allocated)
655  {
656  connect_with_signal(SM, S_Wdata_ram_port,
657  interfaceObj->find_member(WB_DATIS_PORT_NAME, port_o_K, interfaceObj));
658  }
659  else
660  {
661  PRINT_DBG_MEX(DEBUG_LEVEL_VERBOSE, debug_level, "Inserting wDataMux");
663  "wDataMux", MUX_GATE_STD, HLS->HLS_D->get_technology_manager()->get_library(MUX_GATE_STD), interfaceObj,
664  HLS->HLS_D->get_technology_manager());
665 
666  structural_objectRef wDataMuxIn1 = wDataMux->find_member("in1", port_o_K, wDataMux);
667  GetPointer<port_o>(wDataMuxIn1)->set_type(data_type);
668 
669  structural_objectRef wDataMuxIn2 = wDataMux->find_member("in2", port_o_K, wDataMux);
670  GetPointer<port_o>(wDataMuxIn2)->set_type(data_type);
671 
672  structural_objectRef wDataMuxOut1 = wDataMux->find_member("out1", port_o_K, wDataMux);
673  GetPointer<port_o>(wDataMuxOut1)->set_type(data_type);
674 
675  SM->add_connection(interfaceObj->find_member(WB_DATIS_PORT_NAME, port_o_K, interfaceObj), wDataMuxIn1);
676  connect_with_signal(SM, Mout_Wdata_ram_port, wDataMuxIn2);
677  connect_with_signal(SM, S_Wdata_ram_port, wDataMuxOut1);
678  SM->add_connection(signControl, wDataMux->find_member("sel", port_o_K, wDataMux));
679  PRINT_DBG_MEX(DEBUG_LEVEL_VERBOSE, debug_level, "Inserted wDataMux");
680  }
681  }
682  else
683  {
684  PRINT_DBG_MEX(DEBUG_LEVEL_VERBOSE, debug_level, "Connecting S_Wdata_ram");
685  connect_with_signal(SM, S_Wdata_ram_port,
686  interfaceObj->find_member(WB_DATIS_PORT_NAME, port_o_K, interfaceObj));
687  PRINT_DBG_MEX(DEBUG_LEVEL_VERBOSE, debug_level, "Connected S_Wdata_ram");
688  }
689  // ---- Add the Rdata logic ----
690  PRINT_DBG_MEX(DEBUG_LEVEL_VERBOSE, debug_level, "Connecting Sout_Rdata_ram");
691  connect_with_signal(SM, Sout_Rdata_ram_port,
692  interfaceObj->find_member(WB_DATOS_PORT_NAME, port_o_K, interfaceObj));
693  PRINT_DBG_MEX(DEBUG_LEVEL_VERBOSE, debug_level, "Connected Sout_Rdata_ram");
694  }
695 
696  if(is_master)
697  {
698  if(is_slave)
699  {
700  if(only_mm_parameters_allocated)
701  {
702  connect_with_signal(SM, M_Rdata_ram_port,
703  interfaceObj->find_member(WB_DATIM_PORT_NAME, port_o_K, interfaceObj));
704  }
705  else
706  {
707  PRINT_DBG_MEX(DEBUG_LEVEL_VERBOSE, debug_level, "Inserting rDataMux");
709  "rDataMux", MUX_GATE_STD, HLS->HLS_D->get_technology_manager()->get_library(MUX_GATE_STD), interfaceObj,
710  HLS->HLS_D->get_technology_manager());
711 
712  structural_objectRef rDataMuxIn1 = rDataMux->find_member("in1", port_o_K, rDataMux);
713  GetPointer<port_o>(rDataMuxIn1)->set_type(data_type);
714 
715  structural_objectRef rDataMuxIn2 = rDataMux->find_member("in2", port_o_K, rDataMux);
716  GetPointer<port_o>(rDataMuxIn2)->set_type(data_type);
717 
718  structural_objectRef rDataMuxOut1 = rDataMux->find_member("out1", port_o_K, rDataMux);
719  GetPointer<port_o>(rDataMuxOut1)->set_type(data_type);
720 
721  SM->add_connection(interfaceObj->find_member(WB_DATIM_PORT_NAME, port_o_K, interfaceObj), rDataMuxIn1);
722  connect_with_signal(SM, Sout_Rdata_ram_port, rDataMuxIn2);
723  connect_with_signal(SM, M_Rdata_ram_port, rDataMuxOut1);
724  SM->add_connection(signControl_delayed, rDataMux->find_member("sel", port_o_K, rDataMux));
725  PRINT_DBG_MEX(DEBUG_LEVEL_VERBOSE, debug_level, "Inserted rDataMux");
726  }
727  }
728  else
729  {
730  PRINT_DBG_MEX(DEBUG_LEVEL_VERBOSE, debug_level, "Connecting Sout_Rdata_ram");
731  connect_with_signal(SM, M_Rdata_ram_port,
732  interfaceObj->find_member(WB_DATIM_PORT_NAME, port_o_K, interfaceObj));
733  PRINT_DBG_MEX(DEBUG_LEVEL_VERBOSE, debug_level, "Connected Sout_Rdata_ram");
734  }
735  }
736 
737  // ---- Data Ram Size Logic ----
739  if(is_master)
740  {
741  PRINT_DBG_MEX(DEBUG_LEVEL_VERBOSE, debug_level, "Inserting master dataRamSizeConverter");
742  drs_type = Mout_data_ram_size_port->get_typeRef();
743  structural_objectRef dataRamSizeConverter =
745  interfaceObj, HLS->HLS_D->get_technology_manager());
746 
747  structural_objectRef dRSCIn = dataRamSizeConverter->find_member("dataRamSize", port_o_K, dataRamSizeConverter);
748  GetPointer<port_o>(dRSCIn)->set_type(drs_type);
749 
750  structural_objectRef dRSCOut = dataRamSizeConverter->find_member("sel", port_o_K, dataRamSizeConverter);
751  GetPointer<port_o>(dRSCOut)->set_type(sel_type);
752 
753  connect_with_signal(SM, interfaceObj, WB_SELOM_PORT_NAME, dataRamSizeConverter, "sel");
754  connect_with_signal(SM, Mout_data_ram_size_port, dataRamSizeConverter, "dataRamSize");
755  PRINT_DBG_MEX(DEBUG_LEVEL_VERBOSE, debug_level, "Inserted master dataRamSizeConverter");
756  }
757 
758  if(is_slave)
759  {
760  PRINT_DBG_MEX(DEBUG_LEVEL_VERBOSE, debug_level, "Inserting slave selConverter");
761 
762  drs_type = S_data_ram_size_port->get_typeRef();
763  // sel converter
765  "selConverter", SEL_CONVERTER_WB, WBLIBRARY, interfaceObj, HLS->HLS_D->get_technology_manager());
766 
767  structural_objectRef selCOut = selConverter->find_member("dataRamSize", port_o_K, selConverter);
768  GetPointer<port_o>(selCOut)->set_type(drs_type);
769 
770  structural_objectRef selCIn = selConverter->find_member("sel", port_o_K, selConverter);
771  GetPointer<port_o>(selCIn)->set_type(sel_type);
772 
773  SM->add_connection(interfaceObj->find_member(WB_SELIS_PORT_NAME, port_o_K, interfaceObj),
774  selConverter->find_member("sel", port_o_K, selConverter));
775 
776  PRINT_DBG_MEX(DEBUG_LEVEL_VERBOSE, debug_level, "Inserted slave selConverter");
777 
778  if(is_master)
779  {
780  if(only_mm_parameters_allocated)
781  {
782  connect_with_signal(SM, S_data_ram_size_port, selCOut);
783  }
784  else
785  {
786  THROW_ASSERT(structural_type_descriptor::check_type(drs_type, Mout_data_ram_size_port->get_typeRef()),
787  "Mout_data_ram_size->get_typeRef() != S_data_ram_size->get_typeRef()");
788  PRINT_DBG_MEX(DEBUG_LEVEL_VERBOSE, debug_level, "Inserting dRSMux");
790  "dRSMux", MUX_GATE_STD, HLS->HLS_D->get_technology_manager()->get_library(MUX_GATE_STD), interfaceObj,
791  HLS->HLS_D->get_technology_manager());
792 
793  structural_objectRef dRSMuxIn1 = dRSMux->find_member("in1", port_o_K, dRSMux);
794  GetPointer<port_o>(dRSMuxIn1)->set_type(drs_type);
795  structural_objectRef dRSMuxIn2 = dRSMux->find_member("in2", port_o_K, dRSMux);
796  GetPointer<port_o>(dRSMuxIn2)->set_type(drs_type);
797  structural_objectRef dRSMuxOut1 = dRSMux->find_member("out1", port_o_K, dRSMux);
798  GetPointer<port_o>(dRSMuxOut1)->set_type(drs_type);
799 
800  connect_with_signal(SM, Mout_data_ram_size_port, dRSMuxIn2);
801  connect_with_signal_name(SM, dRSMuxIn1, selConverter, "dataRamSize", "sel_is_c");
802  connect_with_signal(SM, S_data_ram_size_port, dRSMuxOut1);
803  SM->add_connection(signControl, dRSMux->find_member("sel", port_o_K, dRSMux));
804  PRINT_DBG_MEX(DEBUG_LEVEL_VERBOSE, debug_level, "Inserted dRSMux");
805  }
806  }
807  else
808  {
809  PRINT_DBG_MEX(DEBUG_LEVEL_VERBOSE, debug_level, "Connecting S_data_ram_size");
810  connect_with_signal_name(SM, S_data_ram_size_port, selCOut, "sel_is_c");
811  PRINT_DBG_MEX(DEBUG_LEVEL_VERBOSE, debug_level, "Connected S_data_ram_size");
812  }
813  }
814 
815  // ---- Address decoding/encoding logic ----
816  if(is_master)
817  {
818  PRINT_DBG_MEX(DEBUG_LEVEL_VERBOSE, debug_level, "Connecting Mout_addr_ram");
819  connect_with_signal(SM, Mout_addr_ram_port,
820  interfaceObj->find_member(WB_ADDROM_PORT_NAME, port_o_K, interfaceObj));
821  PRINT_DBG_MEX(DEBUG_LEVEL_VERBOSE, debug_level, "Connected Mout_addr_ram");
822  }
823 
824  if(is_slave)
825  {
826  PRINT_DBG_MEX(DEBUG_LEVEL_VERBOSE, debug_level, "Adding slave addressFilter");
828  "addressFilterAddrIS", ADDRESS_FILTER_WB, WBLIBRARY, interfaceObj, HLS->HLS_D->get_technology_manager());
829  GetPointer<module>(addressFilterAddrIS)
830  ->SetParameter("MAX_ADDRESS",
831  baseAddressParameter + " + " + STR(HLSMgr->Rmem->get_last_address(HLS->functionId, HLSMgr)));
832 
833  structural_objectRef afAddrISIn1 = addressFilterAddrIS->find_member("in1", port_o_K, addressFilterAddrIS);
834  GetPointer<port_o>(afAddrISIn1)->set_type(addr_type);
835 
836  structural_objectRef afAddrISOut1 = addressFilterAddrIS->find_member("out1", port_o_K, addressFilterAddrIS);
837  GetPointer<port_o>(afAddrISOut1)->set_type(addr_type);
838 
839  SM->add_connection(interfaceObj->find_member(WB_ADDRIS_PORT_NAME, port_o_K, interfaceObj), afAddrISIn1);
840  PRINT_DBG_MEX(DEBUG_LEVEL_VERBOSE, debug_level, "Added slave addressFilter");
841 
842  if(is_master)
843  {
844  if(only_mm_parameters_allocated)
845  {
846  connect_with_signal(SM, S_addr_ram_port, afAddrISOut1);
847  }
848  else
849  {
850  PRINT_DBG_MEX(DEBUG_LEVEL_VERBOSE, debug_level, "Adding addrMux");
852  "addrMux", MUX_GATE_STD, HLS->HLS_D->get_technology_manager()->get_library(MUX_GATE_STD), interfaceObj,
853  HLS->HLS_D->get_technology_manager());
854 
855  structural_objectRef addrMuxIn1 = addrMux->find_member("in1", port_o_K, addrMux);
856  GetPointer<port_o>(addrMuxIn1)->set_type(addr_type);
857 
858  structural_objectRef addrMuxIn2 = addrMux->find_member("in2", port_o_K, addrMux);
859  GetPointer<port_o>(addrMuxIn2)->set_type(addr_type);
860 
861  structural_objectRef addrMuxOut1 = addrMux->find_member("out1", port_o_K, addrMux);
862  GetPointer<port_o>(addrMuxOut1)->set_type(addr_type);
863 
864  SM->add_connection(signControl, addrMux->find_member("sel", port_o_K, addrMux));
865  connect_with_signal_name(SM, afAddrISOut1, addrMuxIn1, "addr_is_f");
866  connect_with_signal(SM, Mout_addr_ram_port, addrMuxIn2);
867  connect_with_signal(SM, S_addr_ram_port, addrMuxOut1);
868  PRINT_DBG_MEX(DEBUG_LEVEL_VERBOSE, debug_level, "Added addrMux");
869  }
870  }
871  else
872  {
873  // if not master there is no need to check the addresses
874  PRINT_DBG_MEX(DEBUG_LEVEL_VERBOSE, debug_level, "Connecting S_addr_ram");
875  connect_with_signal_name(SM, S_addr_ram_port, afAddrISOut1, "addr_is_f");
876  PRINT_DBG_MEX(DEBUG_LEVEL_VERBOSE, debug_level, "Connected S_addr_ram");
877  }
878 
879  // ---- Data ready ack logic ----
880  PRINT_DBG_MEX(DEBUG_LEVEL_VERBOSE, debug_level, "Inserting AckOSGate");
882  "andGateAckOS", AND_GATE_STD, LIBRARY_STD, interfaceObj, HLS->HLS_D->get_technology_manager());
883 
884  structural_objectRef port_objAndAckOS = andGateAckOS->find_member("in", port_o_K, andGateAckOS);
885  auto* in_portAndAckOS = GetPointer<port_o>(port_objAndAckOS);
886  in_portAndAckOS->add_n_ports(3, port_objAndAckOS);
887 
888  SM->add_connection(interfaceObj->find_member(WB_STBIS_PORT_NAME, port_o_K, interfaceObj),
889  in_portAndAckOS->get_port(1));
890 
891  SM->add_connection(interfaceObj->find_member(WB_CYCIS_PORT_NAME, port_o_K, interfaceObj),
892  in_portAndAckOS->get_port(2));
893 
894  SM->add_connection(interfaceObj->find_member(WB_ACKOS_PORT_NAME, port_o_K, interfaceObj),
895  andGateAckOS->find_member("out1", port_o_K, andGateAckOS));
896  PRINT_DBG_MEX(DEBUG_LEVEL_VERBOSE, debug_level, "Inserted AckOSGate");
897 
898  if(is_master)
899  {
900  if(only_mm_parameters_allocated)
901  {
902  connect_with_signal(SM, interfaceObj->find_member(WB_ACKIM_PORT_NAME, port_o_K, interfaceObj),
903  M_DataRdy_port);
904  connect_with_signal_name(SM, Sout_DataRdy_port, in_portAndAckOS->get_port(0), "Sout_DataRdyToWb");
905  }
906  else
907  {
908  PRINT_DBG_MEX(DEBUG_LEVEL_VERBOSE, debug_level, "Inserting dataRdyDemux");
910  "dataRdyDemux", DEMUX_GATE_STD, HLS->HLS_D->get_technology_manager()->get_library(DEMUX_GATE_STD),
911  interfaceObj, HLS->HLS_D->get_technology_manager());
912 
913  connect_with_signal_name(SM, dataRdyDemux->find_member("out2", port_o_K, dataRdyDemux),
914  in_portAndAckOS->get_port(0), "Sout_DataRdyToWb");
915  SM->add_connection(signControl_delayed, dataRdyDemux->find_member("sel", port_o_K, dataRdyDemux));
916  connect_with_signal(SM, Sout_DataRdy_port, dataRdyDemux->find_member("in1", port_o_K, dataRdyDemux));
917  PRINT_DBG_MEX(DEBUG_LEVEL_VERBOSE, debug_level, "Inserted dataRdyDemux");
918 
919  PRINT_DBG_MEX(DEBUG_LEVEL_VERBOSE, debug_level, "Inserting soutDRMux");
921  "soutDRMux", MUX_GATE_STD, HLS->HLS_D->get_technology_manager()->get_library(MUX_GATE_STD),
922  interfaceObj, HLS->HLS_D->get_technology_manager());
923 
924  SM->add_connection(signControl, soutDRMux->find_member("sel", port_o_K, soutDRMux));
925  SM->add_connection(interfaceObj->find_member(WB_ACKIM_PORT_NAME, port_o_K, interfaceObj),
926  soutDRMux->find_member("in1", port_o_K, soutDRMux));
927  connect_with_signal_name(SM, dataRdyDemux->find_member("out1", port_o_K, dataRdyDemux),
928  soutDRMux->find_member("in2", port_o_K, soutDRMux), "Sout_DataRdyDemux");
929  connect_with_signal(SM, M_DataRdy_port, soutDRMux->find_member("out1", port_o_K, soutDRMux));
930  PRINT_DBG_MEX(DEBUG_LEVEL_VERBOSE, debug_level, "Inserting soutDRMux");
931  }
932  }
933  else
934  {
935  PRINT_DBG_MEX(DEBUG_LEVEL_VERBOSE, debug_level, "Connecting Sout_DataRdy");
936  connect_with_signal_name(SM, Sout_DataRdy_port, in_portAndAckOS->get_port(0), "Sout_DataRdyToWb");
937  PRINT_DBG_MEX(DEBUG_LEVEL_VERBOSE, debug_level, "Connected Sout_DataRdy");
938  }
939  }
940  else if(is_master)
941  {
942  PRINT_DBG_MEX(DEBUG_LEVEL_VERBOSE, debug_level, "Connecting M_DataRdy");
943  SM->add_connection(interfaceObj->find_member(WB_ACKIM_PORT_NAME, port_o_K, interfaceObj), M_DataRdy_port);
944  PRINT_DBG_MEX(DEBUG_LEVEL_VERBOSE, debug_level, "Connected M_DataRdy");
945  }
946 }
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 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
Definition: hls_step.hpp:205
#define ADDRESS_FILTER_WB
#define OR_GATE_STD
Data structure representing the entire HLS information.
WB4_interface(const ParameterConstRef _parameters, const HLS_managerRef HLSMgr, unsigned int funId, const DesignFlowManagerConstRef design_flow_manager, const HLSFlowStep_Type hls_flow_step_type=HLSFlowStep_Type::WB4_INTERFACE_GENERATION)
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.
#define PRINT_DBG_MEX(dbgLevel, curDbgLevel, mex)
We are producing a debug version of the program, so the message is printed;.
void connect_with_signal(structural_managerRef SM, structural_objectRef portA, structural_objectRef portB)
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.
~WB4_interface() override
Destructor.
#define GENERATED_LICENSE
Definition of the class representing a generic C application.
const structural_objectRef get_circ() const
Get a reference to circ field.
#define DEMUX_GATE_STD
#define AND_GATE_STD
#define CONSTANT_STD
#define WBLIBRARY
void set_owner(const structural_objectRef new_owner)
set the owner of the structural object
const unsigned int funId
identifier of the function to be processed (0 means that it is a global step)
#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
Definition: hls.hpp:107
#define WB_BASE_ADDRESS
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...
void connect_with_signal_name(structural_managerRef SM, structural_objectRef portA, structural_objectRef portB, std::string signalName)
#define WB_IRQ_PORT_NAME
unsigned int get_addr_bus_bitsize()
Class specification of the manager of the technology library data structures.
all objects that need to be stored in memory are allocated on an external memory
#define A
Definition: generate.c:13
#define STR(s)
Macro which performs a lexical_cast to a 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
#define max
Definition: backprop.h:17
#define WB_CYCOM_PORT_NAME
static bool check_type(structural_type_descriptorRef src_type, structural_type_descriptorRef dest_type)
Check if two type descriptors are consistent.
#define CLOCK_PORT_NAME
standard name for ports
structural_managerRef top
Store the top description.
Definition: hls.hpp:164
void build_WB4_bus_interface(structural_managerRef SM)
#define THROW_UNREACHABLE(str_expr)
helper function used to specify that some points should never be reached
Definition: exceptions.hpp:292
#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
#define DATARAMSIZE_CONVERTER_WB
void set_top_info(const std::string &id, const technology_managerRef &LM, const std::string &Library="")
#define DONE_PORT_NAME
all global variables, static variables and strings are allocated on BRAMs
HLSFlowStep_Type
Definition: hls_step.hpp:95
This class writes different HDL based descriptions (VHDL, Verilog, SystemC) starting from a structura...
Class specification of the data structures used to manage technology information. ...
const std::string get_path() const
Return a unique identifier of the structural object.
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.
#define LIBRARY_STD
standard library where all built-in ports are defined.
#define ADDRESS_RANGE_CHECKER_WB
void SetParameter(const std::string &name, const std::string &value)
Set a parameter value.
#define WB_WEIS_PORT_NAME
virtual enum so_kind get_kind() const =0
Virtual function used to find the real type of a structural_object instance.
#define WB_STBOM_PORT_NAME
const ParameterConstRef parameters
Set of input parameters.
DesignFlowStep_Status
The status of a step.
Base class to allocate memories in high-level synthesis.
#define WB_SELIS_PORT_NAME
#define THROW_ERROR(str_expr)
helper function used to throw an error in a standard way
Definition: exceptions.hpp:263
#define WB_SELOM_PORT_NAME
#define WB_ACKIM_PORT_NAME
refcount< structural_manager > structural_managerRef
RefCount type definition of the structural_manager class structure.
Data structure definition for HLS constraints.
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.
DesignFlowStep_Status InternalExec() override
Execute the step.
#define GET_TYPE_SIZE(structural_obj)
Macro returning the size of the type of a structural object.
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.
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 NOT_INTERNAL_COMPONENT
hlsRef HLS
HLS data structure of the function to be analyzed.
void build_WB4_complete_logic(structural_managerRef SM, structural_objectRef wrappedObj, structural_objectRef interfaceObj)
#define WB_DATOM_PORT_NAME
Template borrowed from the ANTLR library by Terence Parr (http://www.jGuru.com - Software rights: htt...
Definition: refcount.hpp:94
Class to generate WB4 interfaces for high-level synthesis.
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.
#define NOT_GATE_STD
#define MUX_GATE_STD
#define SEL_CONVERTER_WB
unsigned int functionId
this is the identifier of the function to be implemented
Definition: hls.hpp:87
#define WB_ADDRIS_PORT_NAME
#define RESET_PORT_NAME
Class implementation of the structural_manager.
uint32_t sign
int debug_level
The debug level.
This class writes different HDL based descriptions (VHDL, Verilog, SystemC) starting from a structura...
#define OUTPUT_LEVEL_VERBOSE
verbose debugging print is performed.
#define WB_WEOM_PORT_NAME
Class generating minimal interfaces.
#define DEBUG_LEVEL_VERBOSE
verbose debugging print is performed.
#define WB_ACKOS_PORT_NAME
#define B
Definition: generate.c:14
Data structure definition for high-level synthesis flow.
#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
#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