76 const DesignFlowManagerConstRef _design_flow_manager,
78 :
module_interface(_Param, _HLSMgr, _funId, _design_flow_manager, _hls_flow_step_type)
90 THROW_ERROR(
"Top component has not been created yet!");
93 const auto FB =
HLSMgr->CGetFunctionBehavior(
funId);
94 const auto BH = FB->CGetBehavioralHelper();
95 const auto top_functions =
HLSMgr->CGetCallGraphManager()->GetRootFunctions();
96 const auto is_top = top_functions.find(BH->get_function_index()) != top_functions.end();
97 const auto wrappedObj = SM->get_circ();
98 const auto module_name = is_top ? BH->get_function_name() : wrappedObj->get_id() +
"_minimal_interface";
102 SM_minimal_interface->
set_top_info(module_name, module_type);
103 const auto interfaceObj = SM_minimal_interface->
get_circ();
107 wrappedObj->set_id(wrappedObj->get_id() +
"_i0");
108 GetPointerS<module>(interfaceObj)->add_internal_object(wrappedObj);
110 GetPointerS<module>(interfaceObj)
111 ->set_description(
"Minimal interface for function: " +
112 (is_top ? BH->get_function_name() : wrappedObj->get_typeRef()->id_type));
114 GetPointerS<module>(interfaceObj)->set_authors(
"Component automatically generated by bambu");
117 build_wrapper(wrappedObj, interfaceObj, SM_minimal_interface);
119 if(!is_top || (
parameters->isOption(OPT_expose_globals) &&
parameters->getOption<
bool>(OPT_expose_globals)))
124 HLS->
top = SM_minimal_interface;
129 std::pair<unsigned int, memory_symbolRef>& second)
132 if(first.second->get_address() < second.second->get_address())
143 std::map<unsigned long long, structural_objectRef> null_values;
145 const auto& base_address =
HLSMgr->base_address;
146 const auto has_extern_mem =
HLSMgr->Rmem->get_memory_address() - base_address > 0;
147 const auto has_unknown_addresses =
HLSMgr->Rmem->has_unknown_addresses();
148 const auto FB =
HLSMgr->CGetFunctionBehavior(
funId);
149 const auto channels_number = FB->GetChannelsNumber();
150 const auto channels_type = FB->GetChannelsType();
151 const auto memory_allocation_policy = FB->GetMemoryAllocationPolicy();
152 const auto top_function_ids =
HLSMgr->CGetCallGraphManager()->GetRootFunctions();
153 const auto Has_intern_shared_data =
154 HLSMgr->Rmem->has_intern_shared_data() ||
157 (top_function_ids.count(
funId) ?
parameters->getOption<
bool>(OPT_memory_mapped_top) :
159 bool with_master =
false;
160 bool with_slave =
false;
161 for(
auto i = 0
U; i < GetPointerS<module>(wrappedObj)->get_in_port_size(); ++i)
163 const auto port_obj = GetPointerS<module>(wrappedObj)->get_in_port(i);
164 if(GetPointerS<port_o>(port_obj)->get_is_memory())
166 if(GetPointerS<port_o>(port_obj)->get_is_master())
170 else if(GetPointerS<port_o>(port_obj)->get_is_slave())
192 portsToConstant.insert(wrappedObj->
find_member(
"Min_data_ram_size",
port_o_K, wrappedObj));
195 std::map<structural_objectRef, structural_objectRef> portsToConnect;
196 std::map<structural_objectRef, structural_objectRef> portsToSigConnect;
201 const auto fname = FB->CGetBehavioralHelper()->GetMangledFunctionName();
202 const auto func_arch =
HLSMgr->module_arch->GetArchitecture(fname);
203 THROW_ASSERT(func_arch,
"Expected interface architecture for function " + fname);
204 for(
const auto& [parm_name, attrs] : func_arch->parms)
206 const auto& bundle_name = attrs.at(FunctionArchitecture::parm_bundle);
207 THROW_ASSERT(func_arch->ifaces.find(bundle_name) != func_arch->ifaces.end(),
208 "Expected bundle " + bundle_name +
" in function " + fname);
209 const auto& iface_attrs = func_arch->ifaces.at(bundle_name);
210 const auto& iface_mode = iface_attrs.at(FunctionArchitecture::iface_mode);
211 if(iface_mode !=
"default")
214 THROW_ASSERT(parm_port,
"Expected parameter port " + parm_name +
" in function " + fname);
215 const auto forward_port = iface_mode ==
"m_axi" && attrs.at(FunctionArchitecture::parm_offset) ==
"direct";
218 portsToConstant.insert(parm_port);
220 param_renamed.insert(parm_name);
225 auto do_not_expose_globals_case = [&] {
226 auto manage_feedback1 = [&](
const std::string& portS,
const std::string& portM) {
234 GetPointerS<port_o>(port2)->get_ports_size(), interfaceObj,
239 sign = SM_minimal_interface->
add_sign(port2->get_id() +
"_INT", interfaceObj, port2->
get_typeRef());
243 portsToSigConnect[port2] =
sign;
246 auto manage_feedback2 = [&](
const std::string& portSin,
const std::string& portSout,
const std::string& portM) {
253 GetPointerS<port_o>(port2)->get_ports_size(), interfaceObj,
258 sign = SM_minimal_interface->
add_sign(port2->get_id() +
"_INT", interfaceObj, port2->
get_typeRef());
262 portsToSigConnect[port2] =
sign;
267 sign = SM_minimal_interface->
add_sign_vector(port1Out->get_id() +
"_INT",
268 GetPointerS<port_o>(port1Out)->get_ports_size(), interfaceObj,
273 sign = SM_minimal_interface->
add_sign(port1Out->get_id() +
"_INT", interfaceObj, port1Out->
get_typeRef());
281 manage_feedback1(
"S_oe_ram",
"Mout_oe_ram");
282 manage_feedback1(
"S_we_ram",
"Mout_we_ram");
283 manage_feedback1(
"S_addr_ram",
"Mout_addr_ram");
284 manage_feedback1(
"S_Wdata_ram",
"Mout_Wdata_ram");
285 manage_feedback1(
"S_data_ram_size",
"Mout_data_ram_size");
286 manage_feedback2(
"Sin_DataRdy",
"Sout_DataRdy",
"M_DataRdy");
287 manage_feedback2(
"Sin_Rdata_ram",
"Sout_Rdata_ram",
"M_Rdata_ram");
288 portsToConstant.erase(portsToConstant.find(wrappedObj->
find_member(
"Sin_DataRdy",
port_o_K, wrappedObj)));
289 portsToConstant.erase(portsToConstant.find(wrappedObj->
find_member(
"Sin_Rdata_ram",
port_o_K, wrappedObj)));
291 if(!Has_intern_shared_data)
295 if(!with_master && with_slave)
307 else if(with_master && !with_slave)
312 else if(with_master && with_slave && has_unknown_addresses &&
313 HLSMgr->Rmem->get_allocated_internal_memory() == 0)
326 else if(with_master && with_slave && !has_unknown_addresses)
354 else if(with_slave &&
355 (!
parameters->isOption(OPT_expose_globals) || !
parameters->getOption<
bool>(OPT_expose_globals)))
357 do_not_expose_globals_case();
366 if(with_master && !has_unknown_addresses &&
HLSMgr->Rmem->get_ext_memory_variables().empty())
371 bool is_memory_splitted;
372 std::string latency_postfix =
"";
373 if(
parameters->getOption<std::string>(OPT_bram_high_latency) !=
"")
375 latency_postfix =
parameters->getOption<std::string>(OPT_bram_high_latency);
380 is_memory_splitted =
false;
383 HLSMgr->get_HLS_device()->get_technology_manager());
387 is_memory_splitted =
true;
390 HLSMgr->get_HLS_device()->get_technology_manager());
392 auto bus_data_bitsize =
HLSMgr->Rmem->get_bus_data_bitsize();
393 auto bus_addr_bitsize =
HLSMgr->get_address_bitsize();
394 auto bus_size_bitsize =
HLSMgr->Rmem->get_bus_size_bitsize();
395 auto bram_bitsize =
HLSMgr->Rmem->get_bram_bitsize();
396 unsigned long long int n_bytes =
HLSMgr->Rmem->get_memory_address() - base_address;
397 unsigned long long int vec_size = n_bytes / (bus_data_bitsize / 8);
398 std::string init_filename =
"shared_memory.mem";
399 std::ofstream init_file_a(
GetPath(init_filename));
400 std::ofstream init_file_b(
GetPath(
"0_" + init_filename));
402 auto* shared_memory_module = GetPointer<module>(shared_memory);
403 shared_memory_module->SetParameter(
"address_space_begin",
STR(base_address));
404 shared_memory_module->SetParameter(
"address_space_rangesize",
STR(n_bytes));
407 shared_memory_module->SetParameter(
"USE_SPARSE_MEMORY",
"1");
411 shared_memory_module->SetParameter(
"USE_SPARSE_MEMORY",
"0");
413 if(is_memory_splitted)
415 shared_memory_module->SetParameter(
"MEMORY_INIT_file_a",
"\"\"" +
GetPath(init_filename) +
"\"\"");
416 shared_memory_module->SetParameter(
"MEMORY_INIT_file_b",
417 "\"\"" +
GetPath(
"0_" + init_filename) +
"\"\"");
421 shared_memory_module->SetParameter(
"MEMORY_INIT_file",
"\"\"" +
GetPath(init_filename) +
"\"\"");
423 shared_memory_module->SetParameter(
"n_elements",
STR(vec_size));
424 shared_memory_module->SetParameter(
"data_size",
STR(bus_data_bitsize));
425 shared_memory_module->SetParameter(
"BRAM_BITSIZE",
STR(bram_bitsize));
426 if(has_extern_mem || has_unknown_addresses)
428 shared_memory_module->SetParameter(
"BUS_PIPELINED",
"0");
432 shared_memory_module->SetParameter(
"BUS_PIPELINED",
"1");
434 for(
unsigned int i = 0; i < shared_memory_module->get_in_port_size(); i++)
438 GetPointer<port_o>(port)->get_ports_size() == 0)
440 GetPointer<port_o>(port)->add_n_ports(channels_number, port);
442 if(GetPointer<port_o>(port) && GetPointer<port_o>(port)->get_is_data_bus())
446 else if(GetPointer<port_o>(port) && GetPointer<port_o>(port)->get_is_addr_bus())
450 else if(GetPointer<port_o>(port) && GetPointer<port_o>(port)->get_is_size_bus())
455 for(
unsigned int i = 0; i < shared_memory_module->get_out_port_size(); i++)
459 GetPointer<port_o>(port)->get_ports_size() == 0)
461 GetPointer<port_o>(port)->add_n_ports(channels_number, port);
463 if(GetPointer<port_o>(port) && GetPointer<port_o>(port)->get_is_data_bus())
467 else if(GetPointer<port_o>(port) && GetPointer<port_o>(port)->get_is_addr_bus())
471 else if(GetPointer<port_o>(port) && GetPointer<port_o>(port)->get_is_size_bus())
476 const auto& mem_vars =
HLSMgr->Rmem->get_ext_memory_variables();
477 auto nbyte_on_memory = (bram_bitsize / 8);
480 std::string current_bits;
483 std::list<std::pair<unsigned int, memory_symbolRef>> mem_variables;
484 for(
const auto& mem_var : mem_vars)
486 mem_variables.push_back(std::make_pair(mem_var.first, mem_var.second));
490 std::list<std::pair<unsigned int, memory_symbolRef>>::const_iterator m_next;
491 for(
auto m = mem_variables.begin(); m != mem_variables.end(); ++m)
493 const auto splitted =
495 unsigned int byte_allocated = 0;
496 unsigned long long int actual_byte =
498 std::vector<std::string> eightbit_string;
499 for(
const auto& i : splitted)
502 for(
unsigned int base_index = 0; base_index < current_bits.size();
503 base_index = base_index + 8, ++byte_allocated)
505 eightbit_string.push_back(current_bits.substr(current_bits.size() - 8 - base_index, 8));
510 for(
unsigned int l = 0; l < eightbit_string.size();)
514 str_bit = eightbit_string[l] + str_bit;
517 if(counter % nbyte_on_memory == 0)
519 if(is_even || !is_memory_splitted)
521 init_file_a << str_bit << std::endl;
525 init_file_b << str_bit << std::endl;
530 }
while(l < eightbit_string.size());
533 if(actual_byte > byte_allocated)
535 for(
unsigned int base_index = 0; base_index < actual_byte - byte_allocated; ++base_index)
537 str_bit =
"00000000" + str_bit;
539 if(counter % nbyte_on_memory == 0)
541 if(is_even || !is_memory_splitted)
543 init_file_a << str_bit << std::endl;
547 init_file_b << str_bit << std::endl;
557 unsigned long long int object_offset;
558 if(m_next != mem_variables.end())
568 THROW_ASSERT(object_offset >= actual_byte,
"more allocated memory than expected");
569 if(object_offset > actual_byte)
571 for(
unsigned long long int base_index = 0; base_index < object_offset - actual_byte; ++base_index)
573 str_bit =
"00000000" + str_bit;
575 if(counter % nbyte_on_memory == 0)
577 if(is_even || !is_memory_splitted)
579 init_file_a << str_bit << std::endl;
583 init_file_b << str_bit << std::endl;
596 clock_port = SM_minimal_interface->
add_port(
parameters->getOption<std::string>(OPT_clock_name),
601 clock_port = SM_minimal_interface->
add_port(GetPointer<port_o>(port_ck)->get_id(), port_o::IN,
609 reset_port = SM_minimal_interface->
add_port(
parameters->getOption<std::string>(OPT_reset_name),
610 port_o::IN, interfaceObj, port_rst->
get_typeRef());
614 reset_port = SM_minimal_interface->
add_port(GetPointer<port_o>(port_rst)->get_id(), port_o::IN,
629 GetPointer<port_o>(port1)->get_ports_size(),
643 GetPointer<port_o>(port1)->get_ports_size(),
657 GetPointer<port_o>(port1)->get_ports_size(),
671 GetPointer<port_o>(port1)->get_ports_size(),
685 GetPointer<port_o>(port1)->get_ports_size(),
696 if(null_values.find(
GET_TYPE_SIZE(port1)) == null_values.end())
704 for(
unsigned int p = 0; p < GetPointer<port_o>(port1)->get_ports_size(); ++p)
716 if(null_values.find(
GET_TYPE_SIZE(port1)) == null_values.end())
724 for(
unsigned int p = 0; p < GetPointer<port_o>(port1)->get_ports_size(); ++p)
758 GetPointer<port_o>(port1)->get_ports_size(),
768 portsToSkip.insert(port1);
776 GetPointer<port_o>(port1)->get_ports_size(),
786 portsToSkip.insert(port1);
794 GetPointer<port_o>(port1)->get_ports_size(),
804 portsToSkip.insert(port1);
812 GetPointer<port_o>(port1)->get_ports_size(),
822 portsToSkip.insert(port1);
830 GetPointer<port_o>(port1)->get_ports_size(),
840 portsToSkip.insert(port1);
848 GetPointer<port_o>(port1)->get_ports_size(),
863 GetPointer<port_o>(port1)->get_ports_size(),
890 else if(with_slave &&
891 (!
parameters->isOption(OPT_expose_globals) || !
parameters->getOption<
bool>(OPT_expose_globals)))
893 do_not_expose_globals_case();
895 else if(with_slave && (
HLSMgr->Rmem->get_allocated_internal_memory() == 0))
911 for(
unsigned int i = 0; i < GetPointer<module>(wrappedObj)->get_in_port_size(); ++i)
914 auto port_name = GetPointer<port_o>(port_in)->get_id();
915 if(param_renamed.find(port_name) != param_renamed.end())
921 if(GetPointer<port_o>(int_port)->get_port_interface() == port_o::port_interface::PI_RNONE)
923 portsToSkip.insert(int_port);
928 ext_port = SM_minimal_interface->
add_port_vector(port_name, port_o::IN,
929 GetPointer<port_o>(int_port)->get_ports_size(),
935 SM_minimal_interface->
add_port(port_name, port_o::IN, interfaceObj, int_port->
get_typeRef());
941 else if(GetPointer<port_o>(int_port)->get_port_interface() == port_o::port_interface::PI_WNONE)
943 THROW_ASSERT(GetPointer<port_o>(int_port)->get_port_direction() == port_o::port_direction::OUT,
944 "unexpected condition");
946 else if(GetPointer<port_o>(int_port)->get_port_interface() == port_o::port_interface::PI_M_AXI_OFF)
948 portsToConstant.insert(int_port);
950 else if(GetPointer<port_o>(int_port)->get_port_interface() == port_o::port_interface::PI_M_AXI_DIRECT)
952 portsToConstant.insert(int_port);
954 else if(GetPointer<port_o>(int_port)->get_port_interface() != port_o::port_interface::PI_DEFAULT)
965 if(GetPointer<port_o>(int_port)->get_port_interface() == port_o::port_interface::PI_RNONE)
967 portsToSkip.insert(int_port);
970 ext_port = SM_minimal_interface->
add_port_vector(port_name +
"_i", port_o::IN,
971 GetPointer<port_o>(int_port)->get_ports_size(),
976 ext_port = SM_minimal_interface->
add_port(port_name +
"_i", port_o::IN, interfaceObj,
982 else if(GetPointer<port_o>(int_port)->get_port_interface() != port_o::port_interface::PI_DEFAULT)
993 if(GetPointer<port_o>(int_port)->get_port_interface() == port_o::port_interface::PI_RNONE ||
994 GetPointer<port_o>(int_port)->get_port_interface() == port_o::port_interface::PI_FDOUT ||
995 GetPointer<port_o>(int_port)->get_port_interface() == port_o::port_interface::PI_S_AXIS_TDATA)
997 portsToSkip.insert(int_port);
1000 ext_port = SM_minimal_interface->
add_port_vector(port_name +
"_dout", port_o::IN,
1001 GetPointer<port_o>(int_port)->get_ports_size(),
1006 ext_port = SM_minimal_interface->
add_port(port_name +
"_dout", port_o::IN, interfaceObj,
1012 else if(GetPointer<port_o>(int_port)->get_port_interface() != port_o::port_interface::PI_DEFAULT)
1023 if(GetPointer<port_o>(int_port)->get_port_interface() == port_o::port_interface::PI_WNONE ||
1024 GetPointer<port_o>(int_port)->get_port_interface() == port_o::port_interface::PI_FDIN ||
1025 GetPointer<port_o>(int_port)->get_port_interface() == port_o::port_interface::PI_M_AXIS_TDATA)
1029 portsToSkip.insert(int_port);
1038 if(GetPointer<port_o>(int_port)->get_port_interface() == port_o::port_interface::PI_DIN)
1042 portsToSkip.insert(int_port);
1051 if(GetPointer<port_o>(int_port)->get_port_interface() == port_o::port_interface::PI_DOUT)
1055 portsToSkip.insert(int_port);
1061 int_port = wrappedObj->
find_member(
"_m_axis_" + port_name +
"_TDATA",
port_o_K, wrappedObj);
1064 if(GetPointer<port_o>(int_port)->get_port_interface() ==
1065 port_o::port_interface::PI_FDIN ||
1066 GetPointer<port_o>(int_port)->get_port_interface() ==
1067 port_o::port_interface::PI_M_AXIS_TDATA)
1071 portsToSkip.insert(int_port);
1081 if(GetPointer<port_o>(int_port)->get_port_interface() ==
1082 port_o::port_interface::PI_FDOUT ||
1083 GetPointer<port_o>(int_port)->get_port_interface() ==
1084 port_o::port_interface::PI_S_AXIS_TDATA)
1086 portsToSkip.insert(int_port);
1090 "s_axis_" + port_name +
"_TDATA", port_o::IN,
1091 GetPointer<port_o>(int_port)->get_ports_size(), interfaceObj,
1097 SM_minimal_interface->
add_port(
"s_axis_" + port_name +
"_TDATA", port_o::IN,
1103 else if(GetPointer<port_o>(int_port)->get_port_interface() !=
1104 port_o::port_interface::PI_DEFAULT)
1122 const auto tn =
HLSMgr->get_tree_manager()->CGetTreeReindex(tnIndex);
1128 ext_port = SM_minimal_interface->
add_port(port_name, port_o::IN, interfaceObj, Intype);
1129 GetPointerS<port_o>(ext_port)->set_port_interface(port_o::port_interface::PI_RNONE);
1138 port_name =
parameters->getOption<std::string>(OPT_clock_name);
1142 port_name =
parameters->getOption<std::string>(OPT_reset_name);
1146 port_name =
parameters->getOption<std::string>(OPT_start_name);
1149 if(portsToSkip.find(port_in) == portsToSkip.end() && portsToConnect.find(port_in) == portsToConnect.end() &&
1150 portsToConstant.find(port_in) == portsToConstant.end() &&
1151 portsToSigConnect.find(port_in) == portsToSigConnect.end())
1153 if(GetPointer<port_o>(port_in)->get_port_interface() != port_o::port_interface::PI_DEFAULT)
1155 std::string ext_name = port_name[0] ==
'_' ? port_name.substr(1) : port_name;
1161 ext_port = SM_minimal_interface->
add_port_vector(ext_name, port_o::IN,
1162 GetPointer<port_o>(port_in)->get_ports_size(),
1167 ext_port = SM_minimal_interface->
add_port(ext_name, port_o::IN, interfaceObj, port_in->
get_typeRef());
1181 ext_port = SM_minimal_interface->
add_port_vector(port_name, port_o::IN,
1182 GetPointer<port_o>(port_in)->get_ports_size(),
1192 ext_port = SM_minimal_interface->
add_port(port_name, port_o::IN, interfaceObj, vecbool);
1197 SM_minimal_interface->
add_port(port_name, port_o::IN, interfaceObj, port_in->
get_typeRef());
1205 else if(portsToConnect.find(port_in) != portsToConnect.end())
1211 GetPointer<port_o>(port_in)->get_ports_size(), interfaceObj,
1219 SM_minimal_interface->
add_connection(sign, portsToConnect[port_in]);
1221 else if(portsToConstant.find(port_in) != portsToConstant.end())
1223 if(null_values.find(
GET_TYPE_SIZE(port_in)) == null_values.end())
1231 for(
unsigned int p = 0; p < GetPointer<port_o>(port_in)->get_ports_size(); ++p)
1242 else if(portsToSigConnect.find(port_in) != portsToSigConnect.end())
1249 ext_port = SM_minimal_interface->
add_port_vector(port_name, port_o::IN,
1250 GetPointer<port_o>(port_in)->get_ports_size(),
1260 ext_port = SM_minimal_interface->
add_port(port_name, port_o::IN, interfaceObj, vecbool);
1265 SM_minimal_interface->
add_port(port_name, port_o::IN, interfaceObj, port_in->
get_typeRef());
1270 SM_minimal_interface->
add_connection(portsToSigConnect[port_in], ext_port);
1275 for(
unsigned int i = 0; i < GetPointer<module>(wrappedObj)->get_out_port_size(); ++i)
1278 auto port_name = GetPointer<port_o>(port_out)->get_id();
1279 if(GetPointer<port_o>(port_out)->get_port_interface() != port_o::port_interface::PI_DEFAULT)
1281 auto check_interfaces = [&](std::set<port_o::port_interface> interfList) ->
bool {
1282 return interfList.find(GetPointer<port_o>(port_out)->get_port_interface()) != interfList.end();
1284 if(check_interfaces({port_o::port_interface::PI_WNONE, port_o::port_interface::PI_WVALID,
1285 port_o::port_interface::PI_RACK, port_o::port_interface::PI_READ,
1286 port_o::port_interface::PI_FDOUT, port_o::port_interface::PI_WRITE,
1287 port_o::port_interface::PI_FDIN, port_o::port_interface::PI_ADDRESS,
1288 port_o::port_interface::PI_CHIPENABLE, port_o::port_interface::PI_WRITEENABLE,
1289 port_o::port_interface::PI_DOUT, port_o::port_interface::M_AXI_AWVALID,
1290 port_o::port_interface::M_AXI_AWADDR, port_o::port_interface::M_AXI_AWID,
1291 port_o::port_interface::M_AXI_AWLEN, port_o::port_interface::M_AXI_AWSIZE,
1292 port_o::port_interface::M_AXI_AWBURST, port_o::port_interface::M_AXI_AWLOCK,
1293 port_o::port_interface::M_AXI_AWCACHE, port_o::port_interface::M_AXI_AWPROT,
1294 port_o::port_interface::M_AXI_AWQOS, port_o::port_interface::M_AXI_AWREGION,
1295 port_o::port_interface::M_AXI_AWUSER, port_o::port_interface::M_AXI_WVALID,
1296 port_o::port_interface::M_AXI_WDATA, port_o::port_interface::M_AXI_WSTRB,
1297 port_o::port_interface::M_AXI_WLAST, port_o::port_interface::M_AXI_WUSER,
1298 port_o::port_interface::M_AXI_ARVALID, port_o::port_interface::M_AXI_ARADDR,
1299 port_o::port_interface::M_AXI_ARID, port_o::port_interface::M_AXI_ARLEN,
1300 port_o::port_interface::M_AXI_ARSIZE, port_o::port_interface::M_AXI_ARBURST,
1301 port_o::port_interface::M_AXI_ARLOCK, port_o::port_interface::M_AXI_ARCACHE,
1302 port_o::port_interface::M_AXI_ARPROT, port_o::port_interface::M_AXI_ARQOS,
1303 port_o::port_interface::M_AXI_ARREGION, port_o::port_interface::M_AXI_ARUSER,
1304 port_o::port_interface::M_AXI_RREADY, port_o::port_interface::M_AXI_BREADY,
1305 port_o::port_interface::M_AXI_BUSER, port_o::port_interface::S_AXIL_AWVALID,
1306 port_o::port_interface::S_AXIL_AWREADY, port_o::port_interface::S_AXIL_AWADDR,
1307 port_o::port_interface::S_AXIL_WVALID, port_o::port_interface::S_AXIL_WREADY,
1308 port_o::port_interface::S_AXIL_WDATA, port_o::port_interface::S_AXIL_WSTRB,
1309 port_o::port_interface::S_AXIL_ARVALID, port_o::port_interface::S_AXIL_ARREADY,
1310 port_o::port_interface::S_AXIL_ARADDR, port_o::port_interface::S_AXIL_RVALID,
1311 port_o::port_interface::S_AXIL_RREADY, port_o::port_interface::S_AXIL_RDATA,
1312 port_o::port_interface::S_AXIL_RRESP, port_o::port_interface::S_AXIL_BVALID,
1313 port_o::port_interface::S_AXIL_BREADY, port_o::port_interface::S_AXIL_BRESP,
1314 port_o::port_interface::PI_S_AXIS_TREADY, port_o::port_interface::PI_S_AXIS_TDATA,
1315 port_o::port_interface::PI_M_AXIS_TVALID, port_o::port_interface::PI_M_AXIS_TDATA}))
1317 portsToSkip.insert(port_out);
1318 std::string ext_name = port_name[0] ==
'_' ? port_name.substr(1) : port_name;
1324 ext_port = SM_minimal_interface->
add_port_vector(ext_name, port_o::OUT,
1325 GetPointer<port_o>(port_out)->get_ports_size(),
1331 SM_minimal_interface->
add_port(ext_name, port_o::OUT, interfaceObj, port_out->
get_typeRef());
1339 THROW_ERROR(
"not yet supported port interface" +
STR(GetPointer<port_o>(port_out)->get_port_interface()));
1342 if(portsToSkip.find(port_out) == portsToSkip.end() && portsToConnect.find(port_out) == portsToConnect.end() &&
1343 portsToSigConnect.find(port_out) == portsToSigConnect.end())
1347 port_name =
parameters->getOption<std::string>(OPT_done_name);
1352 ext_port = SM_minimal_interface->
add_port_vector(port_name, port_o::OUT,
1353 GetPointer<port_o>(port_out)->get_ports_size(),
1360 auto TM =
HLSMgr->get_HLS_device()->get_technology_manager();
1368 SM_minimal_interface->
add_sign(
"out_" + c_obj->get_id(), interfaceObj, port_out->
get_typeRef());
1376 ext_port = SM_minimal_interface->
add_port(port_name, port_o::OUT, interfaceObj, vecbool);
1381 auto TM =
HLSMgr->get_HLS_device()->get_technology_manager();
1389 SM_minimal_interface->
add_sign(
"out_" + c_obj->get_id(), interfaceObj, port_out->
get_typeRef());
1397 ext_port = SM_minimal_interface->
add_port(port_name, port_o::OUT, interfaceObj, vecbool);
1402 ext_port = SM_minimal_interface->
add_port(port_name, port_o::OUT, interfaceObj, port_out->
get_typeRef());
1408 else if(portsToSigConnect.find(port_out) != portsToSigConnect.end())
1415 ext_port = SM_minimal_interface->
add_port_vector(port_name, port_o::OUT,
1416 GetPointer<port_o>(port_out)->get_ports_size(),
1429 SM_minimal_interface->
add_port(port_name, port_o::OUT, interfaceObj, port_out->
get_typeRef());
1434 SM_minimal_interface->
add_connection(portsToSigConnect.find(port_out)->second, ext_port);
1438 for(
unsigned int p = 0; p < GetPointer<port_o>(port_out)->get_ports_size(); ++p)
1441 if(!GetPointer<port_o>(port_d)->find_bounded_object())
1443 std::string name =
"null_out_signal_" + port_out->
get_owner()->get_id() +
"_" + port_out->
get_id() +
1453 for(
unsigned int i = 0; i < GetPointer<module>(wrappedObj)->get_in_out_port_size(); ++i)
1459 ext_port = SM_minimal_interface->
add_port_vector(GetPointer<port_o>(port_in_out)->get_id(), port_o::IO,
1460 GetPointer<port_o>(port_in_out)->get_ports_size(),
1465 ext_port = SM_minimal_interface->
add_port(GetPointer<port_o>(port_in_out)->get_id(), port_o::IO, interfaceObj,
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.
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.
#define GENERATED_LICENSE
const structural_objectRef get_circ() const
Get a reference to circ field.
void set_owner(const structural_objectRef new_owner)
set the owner of the structural object
Datastructure to represent a memory symbol in HLS.
const unsigned int funId
identifier of the function to be processed (0 means that it is a global step)
Generate HDL testbench for the top-level kernel testing.
This class manages the circuit structures.
static std::vector< std::string > print_var_init(const tree_managerConstRef TreeM, unsigned int var, const memoryRef mem)
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.
all objects that need to be stored in memory are allocated on an external memory
redefinition of map to manage ordered/unordered structures
#define VIEW_CONVERT_STD_UINT
static bool compareMemVarsPair(std::pair< unsigned int, memory_symbolRef > &first, std::pair< unsigned int, memory_symbolRef > &second)
#define STR(s)
Macro which performs a lexical_cast to a string.
Auxiliary methods for manipulating string.
s_type type
The type of the port or the signal.
unsigned long long size
The size of the object (in bit). The objects having a size are: ports, signals, channels, data, and actions.
#define CLOCK_PORT_NAME
standard name for ports
structural_managerRef top
Store the top description.
static unsigned long long Size(const tree_nodeConstRef &tn)
Return the size of a tree object.
void set_top_info(const std::string &id, const technology_managerRef &LM, const std::string &Library="")
Class specification of the data structures used to manage technology information. ...
static structural_objectRef add_port(const std::string &id, port_o::port_direction pdir, structural_objectRef owner, structural_type_descriptorRef type_descr, unsigned int treenode=0)
Create a new port.
unsigned int treenode
Treenode id of the type.
redefinition of set to manage ordered/unordered structures
#define LIBRARY_STD
standard library where all built-in ports are defined.
utility function used to read files.
#define VIEW_CONVERT_STD_INT
static void fix_port_properties(structural_objectRef port_i, structural_objectRef cir_port)
copy the port properties from port_i to cir_port
virtual enum so_kind get_kind() const =0
Virtual function used to find the real type of a structural_object instance.
Classes specification of the tree_node data structures.
const ParameterConstRef parameters
Set of input parameters.
DesignFlowStep_Status
The status of a step.
Base class to allocate memories in high-level synthesis.
Class to generate minimal interfaces for high-level synthesis.
#define THROW_ERROR(str_expr)
helper function used to throw an error in a standard way
void type_resize(unsigned long long new_bit_size)
Just resize the size of the bits of the object.
This file collects some utility functions.
structural_objectRef add_constant(std::string id, structural_objectRef owner, structural_type_descriptorRef type, std::string value, unsigned int treenode=0)
Create a new constant;.
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.
~minimal_interface() override
Destructor.
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)
Class specification of the tree_reindex support class.
static structural_objectRef add_sign(std::string id, structural_objectRef owner, structural_type_descriptorRef sign_type, unsigned int treenode=0)
Create a new signal.
const structural_objectRef get_owner() const
Return the owner.
hlsRef HLS
HLS data structure of the function to be analyzed.
for each memory at maximum n parallel direct accesses and n parallel indirect accesses ...
Template borrowed from the ANTLR library by Terence Parr (http://www.jGuru.com - Software rights: htt...
static tree_nodeConstRef CGetType(const tree_nodeConstRef &node)
Return the treenode of the type of node.
for each memory at maximum one direct access and one indirect access
It collects all the common strings covering PandA copyrights issues.
static tree_nodeConstRef CGetPointedType(const tree_nodeConstRef &pointer)
Return the pointed type of a pointer object.
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
Class implementation of the structural_manager.
unsigned counter[N_THREADS]
void build_wrapper(structural_objectRef wrappedObj, structural_objectRef interfaceObj, structural_managerRef SM_minimal_interface)
all objects that need to be stored in memory are allocated on BRAMs
static bool IsPointerType(const tree_nodeConstRef &type)
Return true if treenode index is a pointer.
minimal_interface(const ParameterConstRef Param, const HLS_managerRef HLSMgr, unsigned int funId, const DesignFlowManagerConstRef design_flow_manager, const HLSFlowStep_Type hls_flow_step_type=HLSFlowStep_Type::MINIMAL_INTERFACE_GENERATION)
Constructor.
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.
static structural_objectRef add_sign_vector(std::string id, unsigned int n_signs, structural_objectRef owner, structural_type_descriptorRef sign_type, unsigned int treenode=0)
#define THROW_ASSERT(cond, str_expr)
helper function used to check an assert and if needed to throw an error in a standard way ...