From 3cae5998beaf870a717d5c380e8b873ecbc93ea7 Mon Sep 17 00:00:00 2001 From: Fabrizio Ferrandi Date: Thu, 11 Apr 2024 21:15:32 +0200 Subject: [PATCH 01/13] Fixed interface infer in case one of the parameter is of bool type. --- .../IR_analysis/InterfaceInfer.cpp | 17 +++++++++++++---- 1 file changed, 13 insertions(+), 4 deletions(-) diff --git a/src/frontend_analysis/IR_analysis/InterfaceInfer.cpp b/src/frontend_analysis/IR_analysis/InterfaceInfer.cpp index ba868c40b..4333e8452 100644 --- a/src/frontend_analysis/IR_analysis/InterfaceInfer.cpp +++ b/src/frontend_analysis/IR_analysis/InterfaceInfer.cpp @@ -94,7 +94,8 @@ enum class InterfaceInfer::m_axi_type enum class InterfaceInfer::datatype { generic, - ac_type + ac_type, + bool_type }; struct InterfaceInfer::interface_info @@ -130,7 +131,7 @@ struct InterfaceInfer::interface_info void update(const tree_nodeRef& tn, const std::string& _type_name, ParameterConstRef parameters) { - if(type != datatype::ac_type) + if(type != datatype::ac_type && type != datatype::bool_type) { bool is_signed, is_fixed; const auto type_name = @@ -182,6 +183,13 @@ struct InterfaceInfer::interface_info alignment = std::max(alignment, _alignment); } + else if(std::regex_search(_type_name, std::regex(("bool[&*]")))) + { + _bitwidth = 1; + type = datatype::bool_type; + alignment = 8; + } + if(_fixed_size && bitwidth && bitwidth != _bitwidth) { THROW_ERROR("Unaligned access not allowed for required interface!"); @@ -644,8 +652,9 @@ DesignFlowStep_Status InterfaceInfer::Exec() { continue; } - THROW_ERROR("Parameter '" + arg_name + "' cannot have interface type '" + interface_type + - "' since no load/store is associated with it"); + THROW_WARNING("Parameter '" + arg_name + "' cannot have interface type '" + interface_type + + "' since no load/store is associated with it"); + continue; } info.factor = std::max( From 5297a3b0303223b5643e030d27051137bf7eb46e Mon Sep 17 00:00:00 2001 From: Fabrizio Ferrandi Date: Thu, 11 Apr 2024 21:44:57 +0200 Subject: [PATCH 02/13] Extended interface infer support to _Bool type. --- src/frontend_analysis/IR_analysis/InterfaceInfer.cpp | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/frontend_analysis/IR_analysis/InterfaceInfer.cpp b/src/frontend_analysis/IR_analysis/InterfaceInfer.cpp index 4333e8452..c4ee84107 100644 --- a/src/frontend_analysis/IR_analysis/InterfaceInfer.cpp +++ b/src/frontend_analysis/IR_analysis/InterfaceInfer.cpp @@ -183,7 +183,8 @@ struct InterfaceInfer::interface_info alignment = std::max(alignment, _alignment); } - else if(std::regex_search(_type_name, std::regex(("bool[&*]")))) + else if(std::regex_search(_type_name, std::regex(("bool[&*]"))) || + std::regex_search(_type_name, std::regex(("_Bool[&*]")))) { _bitwidth = 1; type = datatype::bool_type; From 4b5475b617a0f2615a7f32c25a3827caae9ae9eb Mon Sep 17 00:00:00 2001 From: Fabrizio Ferrandi Date: Thu, 11 Apr 2024 21:46:41 +0200 Subject: [PATCH 03/13] Fixed a complex case where a parameter is not used but it is just passed to called functions. --- src/frontend_analysis/IR_analysis/InterfaceInfer.cpp | 3 +++ 1 file changed, 3 insertions(+) diff --git a/src/frontend_analysis/IR_analysis/InterfaceInfer.cpp b/src/frontend_analysis/IR_analysis/InterfaceInfer.cpp index c4ee84107..c3af3a179 100644 --- a/src/frontend_analysis/IR_analysis/InterfaceInfer.cpp +++ b/src/frontend_analysis/IR_analysis/InterfaceInfer.cpp @@ -653,6 +653,9 @@ DesignFlowStep_Status InterfaceInfer::Exec() { continue; } + // BEAWARE: none is used here in place of default to avoid memory allocation to consider this as + // an active pointer parameter + interface_type = "none"; THROW_WARNING("Parameter '" + arg_name + "' cannot have interface type '" + interface_type + "' since no load/store is associated with it"); continue; From 4dd1d7a19515cbca806470e7c974b6864d7b3783 Mon Sep 17 00:00:00 2001 From: Fabrizio Ferrandi Date: Fri, 12 Apr 2024 14:25:26 +0200 Subject: [PATCH 04/13] Fixed support for unused parameters. --- panda_regressions/hls/Makefile.am | 2 + .../hls/bambu_interface_test/unused_param.c | 11 ++++ .../hls/bambu_interface_test/unused_param.xml | 4 ++ .../hls/bambu_interface_test_list | 1 + src/HLS/Makefile.am | 1 + src/HLS/binding/module/fu_binding.cpp | 55 +++++++++++++++- src/HLS/hls_manager.hpp | 3 + .../ReadWrite_m_axiModuleGenerator.cpp | 10 ++- .../IR_analysis/InterfaceInfer.cpp | 66 ++++++++++++------- .../IR_analysis/InterfaceInfer.hpp | 12 ++-- 10 files changed, 132 insertions(+), 33 deletions(-) create mode 100644 panda_regressions/hls/bambu_interface_test/unused_param.c create mode 100644 panda_regressions/hls/bambu_interface_test/unused_param.xml diff --git a/panda_regressions/hls/Makefile.am b/panda_regressions/hls/Makefile.am index 0f6988a4a..7954f41d7 100644 --- a/panda_regressions/hls/Makefile.am +++ b/panda_regressions/hls/Makefile.am @@ -108,6 +108,8 @@ EXTRA_DIST= \ %D%/bambu_interface_test/simpleif_c1_none.c \ %D%/bambu_interface_test/simpleif_c1_none_test.xml \ %D%/bambu_interface_test/simple_test.c \ + %D%/bambu_interface_test/unused_param.c \ + %D%/bambu_interface_test/unused_param.xml \ %D%/bambu_specific_test5/adders.c \ %D%/bambu_specific_test5/function_call.c \ %D%/bambu_specific_test5/if_clauses.c \ diff --git a/panda_regressions/hls/bambu_interface_test/unused_param.c b/panda_regressions/hls/bambu_interface_test/unused_param.c new file mode 100644 index 000000000..5116b5a3f --- /dev/null +++ b/panda_regressions/hls/bambu_interface_test/unused_param.c @@ -0,0 +1,11 @@ +unsigned long long test(_Bool *a1, _Bool a2[1], _Bool *a3, _Bool *a4, double b, double c) +{ +#pragma HLS interface port = a1 mode = axis +#pragma HLS interface port = a3 mode = fifo +#pragma HLS interface port = a4 mode = m_axi offset = direct bundle = gmem0 + + return b+c; +} + + + diff --git a/panda_regressions/hls/bambu_interface_test/unused_param.xml b/panda_regressions/hls/bambu_interface_test/unused_param.xml new file mode 100644 index 000000000..65365465c --- /dev/null +++ b/panda_regressions/hls/bambu_interface_test/unused_param.xml @@ -0,0 +1,4 @@ + + + + diff --git a/panda_regressions/hls/bambu_interface_test_list b/panda_regressions/hls/bambu_interface_test_list index c620a1857..69ff67290 100644 --- a/panda_regressions/hls/bambu_interface_test_list +++ b/panda_regressions/hls/bambu_interface_test_list @@ -41,6 +41,7 @@ bambu_interface_test/simple_c4_fifo_multiple.c --generate-tb=a="{1,2,3,4,5,6,7,8 bambu_interface_test/simple_c4_fifo.c --generate-tb=a=1,b=2,c=3,d=0 --top-fname=sum3numbers bambu_interface_test/simple_c4_handshake.c --generate-tb=a=1,b=2,c=3,d=0 --top-fname=sum3numbers bambu_interface_test/simple_test.c --generate-tb=a="-7",b="{0}" --top-fname=test +bambu_interface_test/unused_param.c --generate-tb=BENCHMARKS_ROOT/bambu_interface_test/unused_param.xml --top-fname=test bambu_interface_test/simpleif_c1_none.c --generate-tb=BENCHMARKS_ROOT/bambu_interface_test/simpleif_c1_none_test.xml --top-fname=kim --benchmark-name=simpleif_c1_none_xml bambu_interface_test/simpleif_c1_none.c --generate-tb=i1=9,i2=1,i3=5,i4=6,i5=17,i6=19,c1=2,c2=6,c3=13,c4=17,c6=9,COND1=1,COND2=1,o1=0,o2=0 --top-fname=kim --benchmark-name=simpleif_c1_none_no_xml bambu_interface_test/simple_axi_m.c --top-fname=maxNumbers --generate-tb=a="{1,2,3,4,5}",n_ptr="{5}" diff --git a/src/HLS/Makefile.am b/src/HLS/Makefile.am index ea98f72e8..9bd2a0954 100644 --- a/src/HLS/Makefile.am +++ b/src/HLS/Makefile.am @@ -314,6 +314,7 @@ lib_modulebinding_la_CPPFLAGS = \ -I$(top_srcdir)/src/HLS \ -I$(top_srcdir)/src/HLS/function_allocation \ -I$(top_srcdir)/src/HLS/module_allocation \ + -I$(top_srcdir)/src/HLS/module_generator \ -I$(top_srcdir)/src/HLS/virtual_components \ -I$(top_srcdir)/src/HLS/binding \ -I$(top_srcdir)/src/HLS/binding/interconnection \ diff --git a/src/HLS/binding/module/fu_binding.cpp b/src/HLS/binding/module/fu_binding.cpp index 0fe5aa31d..abb2ea72f 100644 --- a/src/HLS/binding/module/fu_binding.cpp +++ b/src/HLS/binding/module/fu_binding.cpp @@ -45,6 +45,8 @@ #include "fu_binding.hpp" +#include "ModuleGeneratorManager.hpp" +#include "exceptions.hpp" #include "fu_binding_cs.hpp" #include "funit_obj.hpp" @@ -1110,7 +1112,9 @@ void fu_binding::add_to_SM(const HLS_managerRef HLSMgr, const hlsRef HLS, struct const auto cg_man = HLSMgr->CGetCallGraphManager(); const auto top_function_ids = cg_man->GetRootFunctions(); - if(top_function_ids.find(HLS->functionId) != top_function_ids.end() && cg_man->ExistsAddressedFunction()) + if(top_function_ids.find(HLS->functionId) != top_function_ids.end() && + (cg_man->ExistsAddressedFunction() || + HLSMgr->unused_interfaces.find(HLS->functionId) != HLSMgr->unused_interfaces.end())) { const auto addressed_functions = cg_man->GetAddressedFunctions(); const auto constBitZero = @@ -1187,7 +1191,56 @@ void fu_binding::add_to_SM(const HLS_managerRef HLSMgr, const hlsRef HLS, struct manage_module_ports(HLSMgr, HLS, SM, FU, 0); memory::propagate_memory_parameters(FU, HLS->datapath); } + if(HLSMgr->unused_interfaces.find(HLS->functionId) != HLSMgr->unused_interfaces.end()) + { + const auto HLS_D = HLSMgr->get_HLS_device(); + const auto TechMan = HLS_D->get_technology_manager(); + const auto& res_pair_set = HLSMgr->unused_interfaces.at(HLS->functionId); + for(const auto& [UPlibrary, FUName] : res_pair_set) + { + auto fu_name = FUName; + technology_nodeRef fuObj = TechMan->get_fu(fu_name, UPlibrary); + const auto structManager_obj = GetPointer(fuObj)->CM; + THROW_ASSERT(structManager_obj, "unexpected condition"); + const auto has_to_be_generated = GetPointer(structManager_obj->get_circ()) + ->get_NP_functionality() + ->exist_NP_functionality(NP_functionality::VERILOG_GENERATOR) || + GetPointer(structManager_obj->get_circ()) + ->get_NP_functionality() + ->exist_NP_functionality(NP_functionality::VHDL_GENERATOR); + if(has_to_be_generated) + { + INDENT_DBG_MEX(DEBUG_LEVEL_VERY_PEDANTIC, debug_level, "Unit has to be specialized."); + const ModuleGeneratorManagerRef modGen(new ModuleGeneratorManager(HLSMgr, parameters)); + { + fu_name = fu_name + "_modgen"; + } + const auto& specialized_fuName = fu_name; + + const auto check_lib = TechM->get_library(specialized_fuName); + modGen->create_generic_module(FUName, NULL_VERTEX, FB, UPlibrary, specialized_fuName); + } + const auto FU = SM->add_module_from_technology_library(fu_name + "_i0", fu_name, UPlibrary, circuit, TechM); + if(std::find(memory_modules.begin(), memory_modules.end(), FU) == memory_modules.end()) + { + memory_modules.push_back(FU); + } + INDENT_DBG_MEX(DEBUG_LEVEL_VERY_PEDANTIC, debug_level, "---Adding unused interface component: " + FUName); + if(const auto clk_prt = FU->find_member(CLOCK_PORT_NAME, port_o_K, FU)) + { + SM->add_connection(clk_prt, circuit->find_member(CLOCK_PORT_NAME, port_o_K, circuit)); + } + if(const auto reset_prt = FU->find_member(RESET_PORT_NAME, port_o_K, FU)) + { + SM->add_connection(reset_prt, circuit->find_member(RESET_PORT_NAME, port_o_K, circuit)); + } + + manage_module_ports(HLSMgr, HLS, SM, FU, 0); + memory::propagate_memory_parameters(FU, HLS->datapath); + } + } } + if(parameters->IsParameter("chained-memory-modules") && parameters->GetParameter("chained-memory-modules") == 1) { manage_memory_ports_chained(SM, memory_modules, circuit); diff --git a/src/HLS/hls_manager.hpp b/src/HLS/hls_manager.hpp index 852635eed..757c75b25 100644 --- a/src/HLS/hls_manager.hpp +++ b/src/HLS/hls_manager.hpp @@ -184,6 +184,9 @@ class HLS_manager : public application_manager /// information about memory allocation memoryRef Rmem; + /// unused port interface + std::map>> unused_interfaces; + /// information about the simulation SimulationInformationRef RSim; diff --git a/src/HLS/module_generator/ReadWrite_m_axiModuleGenerator.cpp b/src/HLS/module_generator/ReadWrite_m_axiModuleGenerator.cpp index 822bf8b2c..0e8b88d03 100644 --- a/src/HLS/module_generator/ReadWrite_m_axiModuleGenerator.cpp +++ b/src/HLS/module_generator/ReadWrite_m_axiModuleGenerator.cpp @@ -186,8 +186,12 @@ void ReadWrite_m_axiModuleGenerator::InternalExec(std::ostream& out, structural_ << " BITSIZE_bid=" << _ports_in[i_bid].type_size << ",\n" << " BITSIZE_rid=" << _ports_in[i_rid].type_size << ";\n\n"; - out << "// BITSIZE_log_data_size = log2(BITISZE_in3 >> 3)\n" - << "localparam BITSIZE_log_data_size = " << ceil_log2(_ports_in[i_in3].type_size / 8) << ";\n "; + if(line_count != 0) + { + out << "// BITSIZE_log_data_size = log2(BITISZE_in3 >> 3)\n" + << "localparam BITSIZE_log_data_size = " << ceil_log2(std::max(_ports_in[i_in3].type_size, 8ull) / 8) + << ";\n "; + } /* No cache, build the AXI controller */ std::string ip_components; @@ -465,4 +469,4 @@ void ReadWrite_m_axiModuleGenerator::InternalExec(std::ostream& out, structural_ << "`undef _CACHE_CNT\n"; } structural_manager::add_NP_functionality(mod, NP_functionality::IP_COMPONENT, ip_components); -} \ No newline at end of file +} diff --git a/src/frontend_analysis/IR_analysis/InterfaceInfer.cpp b/src/frontend_analysis/IR_analysis/InterfaceInfer.cpp index c3af3a179..cea4f8a57 100644 --- a/src/frontend_analysis/IR_analysis/InterfaceInfer.cpp +++ b/src/frontend_analysis/IR_analysis/InterfaceInfer.cpp @@ -183,8 +183,7 @@ struct InterfaceInfer::interface_info alignment = std::max(alignment, _alignment); } - else if(std::regex_search(_type_name, std::regex(("bool[&*]"))) || - std::regex_search(_type_name, std::regex(("_Bool[&*]")))) + else if(std::regex_search(_type_name, std::regex("(_B|b)ool[&*]"))) { _bitwidth = 1; type = datatype::bool_type; @@ -620,20 +619,18 @@ DesignFlowStep_Status InterfaceInfer::Exec() const auto arg_ssa_id = AppM->getSSAFromParm(root_id, arg_id); const auto arg_ssa = TM->GetTreeReindex(arg_ssa_id); THROW_ASSERT(GET_CONST_NODE(arg_ssa)->get_kind() == ssa_name_K, ""); + bool unused_port = false; if(GetPointerS(GET_CONST_NODE(arg_ssa))->CGetUseStmts().empty()) { THROW_WARNING("Parameter '" + arg_name + "' not used by any statement"); if(tree_helper::IsPointerType(arg_type)) { - // BEAWARE: none is used here in place of default to avoid memory allocation to consider this as - // an active pointer parameter - interface_type = "none"; + unused_port = true; } else { THROW_ERROR("parameter not used: specified interface does not make sense - " + interface_type); } - continue; } if(tree_helper::IsPointerType(arg_type)) { @@ -649,16 +646,15 @@ DesignFlowStep_Status InterfaceInfer::Exec() if(!isRead && !isWrite) { - if(interface_type == "m_axi" || starts_with(arg_name, "DF_bambu_")) + if(starts_with(arg_name, "DF_bambu_")) { continue; } - // BEAWARE: none is used here in place of default to avoid memory allocation to consider this as - // an active pointer parameter - interface_type = "none"; - THROW_WARNING("Parameter '" + arg_name + "' cannot have interface type '" + interface_type + - "' since no load/store is associated with it"); - continue; + if(!unused_port) + { + unused_port = true; + THROW_WARNING("Parameter '" + arg_name + "' not used by any statement"); + } } info.factor = std::max( @@ -807,7 +803,7 @@ DesignFlowStep_Status InterfaceInfer::Exec() add_to_modified(stmt); store_vdef(stmt); } - create_resource(operationsR, operationsW, info, func_arch); + create_resource(operationsR, operationsW, info, func_arch, unused_port, root_id); } else if(interface_type == "none") { @@ -1721,9 +1717,10 @@ void InterfaceInfer::setWriteInterface(tree_nodeRef stmt, const std::string& arg } void InterfaceInfer::create_resource_Read_simple(const std::set& operations, const interface_info& info, - FunctionArchitectureRef func_arch, bool IO_port) const + FunctionArchitectureRef func_arch, bool IO_port, bool unused_port, + unsigned root_id) const { - if(operations.empty()) + if(operations.empty() && !unused_port) { return; } @@ -1820,6 +1817,10 @@ void InterfaceInfer::create_resource_Read_simple(const std::set& op CM->add_NP_functionality(interface_top, NP_functionality::VERILOG_GENERATOR, "Read_" + if_name + "ModuleGenerator"); TechMan->add_resource(INTERFACE_LIBRARY, ResourceName, CM); + if(unused_port) + { + HLSMgr->unused_interfaces[root_id].insert(std::make_pair(INTERFACE_LIBRARY, ResourceName)); + } for(const auto& fdName : operations) { TechMan->add_operation(INTERFACE_LIBRARY, ResourceName, fdName); @@ -2013,7 +2014,7 @@ void InterfaceInfer::create_resource_Write_simple(const std::set& o void InterfaceInfer::create_resource_array(const std::set& operationsR, const std::set& operationsW, const interface_info& info, - FunctionArchitectureRef func_arch) const + FunctionArchitectureRef func_arch, bool unused_port, unsigned root_id) const { const auto n_channels = parameters->getOption(OPT_channels_number); const auto isDP = n_channels == 2; @@ -2102,7 +2103,7 @@ void InterfaceInfer::create_resource_array(const std::set& operatio GetPointerS(inPort_we1)->set_port_interface(port_o::port_interface::PI_WRITEENABLE); } } - if(!operationsR.empty()) + if(!operationsR.empty() || unused_port) { const auto inPort_din = CM->add_port("_" + bundle_name + "_q0", port_o::IN, interface_top, dataType); GetPointerS(inPort_din)->set_port_interface(port_o::port_interface::PI_DIN); @@ -2127,6 +2128,10 @@ void InterfaceInfer::create_resource_array(const std::set& operatio CM->add_NP_functionality(interface_top, NP_functionality::VERILOG_GENERATOR, read_write_string + info.name + "ModuleGenerator"); TechMan->add_resource(INTERFACE_LIBRARY, ResourceName, CM); + if(unused_port) + { + HLSMgr->unused_interfaces[root_id].insert(std::make_pair(INTERFACE_LIBRARY, ResourceName)); + } const auto fu = GetPointerS(TechMan->get_fu(ResourceName, INTERFACE_LIBRARY)); fu->area_m = area_info::factory(parameters); fu->area_m->set_area_value(0); @@ -2181,7 +2186,8 @@ void InterfaceInfer::create_resource_array(const std::set& operatio void InterfaceInfer::create_resource_m_axi(const std::set& operationsR, const std::set& operationsW, const interface_info& info, - FunctionArchitectureRef func_arch) const + FunctionArchitectureRef func_arch, bool unused_port, + unsigned int root_id) const { THROW_ASSERT(GetPointer(AppM), ""); const auto HLSMgr = GetPointerS(AppM); @@ -2397,6 +2403,7 @@ void InterfaceInfer::create_resource_m_axi(const std::set& operatio GetPointerS(rready)->set_port_interface(port_o::port_interface::M_AXI_RREADY); bool has_slave = false; + bool has_direct = false; for(auto& p : func_arch->parms) { if(p.second.at(FunctionArchitecture::parm_bundle) == bundle_name) @@ -2408,12 +2415,17 @@ void InterfaceInfer::create_resource_m_axi(const std::set& operatio } else if(parm_offset == "direct") { + has_direct = true; const auto offset_port = CM->add_port("_" + p.first, port_o::IN, interface_top, address_interface_datatype); GetPointerS(offset_port)->set_port_interface(port_o::port_interface::PI_M_AXI_DIRECT); } } } + if(!has_direct) + { + THROW_ERROR("only 'direct' axi interfaces are supported"); + } if(has_slave) { const auto s_awvalid = CM->add_port("_s_axi_AXILiteS_AWVALID", port_o::IN, interface_top, bool_type); @@ -2462,7 +2474,10 @@ void InterfaceInfer::create_resource_m_axi(const std::set& operatio "ReadWrite_" + info.name + "ModuleGenerator"); TechMan->add_resource(INTERFACE_LIBRARY, ResourceName, CM); - + if(unused_port) + { + HLSMgr->unused_interfaces[root_id].insert(std::make_pair(INTERFACE_LIBRARY, ResourceName)); + } const auto fu = GetPointerS(TechMan->get_fu(ResourceName, INTERFACE_LIBRARY)); fu->area_m = area_info::factory(parameters); fu->area_m->set_area_value(0); @@ -2511,23 +2526,24 @@ void InterfaceInfer::create_resource_m_axi(const std::set& operatio } void InterfaceInfer::create_resource(const std::set& operationsR, const std::set& operationsW, - const interface_info& info, FunctionArchitectureRef func_arch) const + const interface_info& info, FunctionArchitectureRef func_arch, bool unused_port, + unsigned root_id) const { if(info.name == "none" || info.name == "acknowledge" || info.name == "valid" || info.name == "ovalid" || info.name == "handshake" || info.name == "fifo" || info.name == "axis") { - THROW_ASSERT(!operationsR.empty() || !operationsW.empty(), "unexpected condition"); + THROW_ASSERT(!operationsR.empty() || !operationsW.empty() || unused_port, "unexpected condition"); const auto IO_P = !operationsR.empty() && !operationsW.empty(); - create_resource_Read_simple(operationsR, info, func_arch, IO_P); + create_resource_Read_simple(operationsR, info, func_arch, IO_P, unused_port, root_id); create_resource_Write_simple(operationsW, info, func_arch, IO_P); } else if(info.name == "array") { - create_resource_array(operationsR, operationsW, info, func_arch); + create_resource_array(operationsR, operationsW, info, func_arch, unused_port, root_id); } else if(info.name == "m_axi") { - create_resource_m_axi(operationsR, operationsW, info, func_arch); + create_resource_m_axi(operationsR, operationsW, info, func_arch, unused_port, root_id); } else { diff --git a/src/frontend_analysis/IR_analysis/InterfaceInfer.hpp b/src/frontend_analysis/IR_analysis/InterfaceInfer.hpp index b1f4ea399..fcbf4fa46 100644 --- a/src/frontend_analysis/IR_analysis/InterfaceInfer.hpp +++ b/src/frontend_analysis/IR_analysis/InterfaceInfer.hpp @@ -94,19 +94,23 @@ class InterfaceInfer : public ApplicationFrontendFlowStep const tree_manipulationRef tree_man, const tree_managerRef TM); void create_resource_Read_simple(const std::set& operations, const interface_info& info, - FunctionArchitectureRef func_arch, bool IO_port) const; + FunctionArchitectureRef func_arch, bool IO_port, bool unused_port, + unsigned int root_id) const; void create_resource_Write_simple(const std::set& operations, const interface_info& info, FunctionArchitectureRef func_arch, bool IO_port) const; void create_resource_array(const std::set& operationsR, const std::set& operationsW, - const interface_info& info, FunctionArchitectureRef func_arch) const; + const interface_info& info, FunctionArchitectureRef func_arch, bool unused_port, + unsigned int root_id) const; void create_resource_m_axi(const std::set& operationsR, const std::set& operationsW, - const interface_info& info, FunctionArchitectureRef func_arch) const; + const interface_info& info, FunctionArchitectureRef func_arch, bool unused_port, + unsigned root_id) const; void create_resource(const std::set& operationsR, const std::set& operationsW, - const interface_info& info, FunctionArchitectureRef func_arch) const; + const interface_info& info, FunctionArchitectureRef func_arch, bool unused_port, + unsigned int root_id) const; public: /** From d1e1ca2dada7390e7605f5ef0799f53c7795bfe9 Mon Sep 17 00:00:00 2001 From: Fabrizio Ferrandi Date: Fri, 12 Apr 2024 16:07:31 +0200 Subject: [PATCH 05/13] Interface name normalization. --- etc/clang_plugin/plugin_ASTAnalyzer.cpp | 38 ++++++++++++ .../interface/minimal/minimal_interface.cpp | 61 ++++++++----------- .../TestbenchAxisModuleGenerator.cpp | 2 +- .../IR_analysis/InterfaceInfer.cpp | 24 +++++--- 4 files changed, 77 insertions(+), 48 deletions(-) diff --git a/etc/clang_plugin/plugin_ASTAnalyzer.cpp b/etc/clang_plugin/plugin_ASTAnalyzer.cpp index 237a4b263..4d27f8dfc 100644 --- a/etc/clang_plugin/plugin_ASTAnalyzer.cpp +++ b/etc/clang_plugin/plugin_ASTAnalyzer.cpp @@ -1303,6 +1303,41 @@ class InterfaceHLSPragmaHandler : public HLSPragmaAnalyzer, public HLSPragmaPars parmIncludePaths = getIncludePaths(paramTypeRemTD); }; + auto normalizeInterface = [&]() { + if(ifaceMode == "ap_fifo") + { + ifaceMode = "fifo"; + } + else if(ifaceMode == "ap_none") + { + ifaceMode = "none"; + } + else if(ifaceMode == "ap_vld") + { + ifaceMode = "valid"; + } + else if(ifaceMode == "ap_ovld") + { + ifaceMode = "ovalid"; + } + else if(ifaceMode == "ap_ack") + { + ifaceMode = "acknowledge"; + } + else if(ifaceMode == "ap_hs") + { + ifaceMode = "handshake"; + } + else if(ifaceMode == "bram") + { + ReportError(ifaceModeReq->first.loc, "Not support HLS interface mode"); + ifaceMode = "array"; + } + else if(ifaceMode == "ap_memory") + { + ifaceMode = "array"; + } + }; if(isa(argType)) { const auto DT = cast(argType)->getOriginalType().IgnoreParens(); @@ -1318,6 +1353,7 @@ class InterfaceHLSPragmaHandler : public HLSPragmaAnalyzer, public HLSPragmaPars parmOriginalTypename = GetTypeNameCanonical(argType, _PP); parmIncludePaths = getIncludePaths(argType); } + normalizeInterface(); if(ifaceMode != "default") { if(ifaceMode != "handshake" && ifaceMode != "fifo" && ifaceMode != "array" && ifaceMode != "bus" && @@ -1345,6 +1381,7 @@ class InterfaceHLSPragmaHandler : public HLSPragmaAnalyzer, public HLSPragmaPars } const auto is_channel_if = parmTypename.find("ac_channel<") == 0 || parmTypename.find("stream<") == 0 || parmTypename.find("hls::stream<") == 0; + normalizeInterface(); if(ifaceMode != "default") { if((ifaceMode != "ptrdefault" && ifaceMode != "none" && ifaceMode != "handshake" && ifaceMode != "valid" && @@ -1367,6 +1404,7 @@ class InterfaceHLSPragmaHandler : public HLSPragmaAnalyzer, public HLSPragmaPars parmTypename = GetTypeNameCanonical(paramTypeRemTD, _PP); parmOriginalTypename = GetTypeNameCanonical(argType, _PP); parmIncludePaths = getIncludePaths(argType); + normalizeInterface(); if(ifaceMode != "default") { if(ifaceMode != "default" && ifaceMode != "none" && ifaceMode != "handshake" && ifaceMode != "valid" && diff --git a/src/HLS/interface/minimal/minimal_interface.cpp b/src/HLS/interface/minimal/minimal_interface.cpp index 5ee1809f8..8826c53bf 100644 --- a/src/HLS/interface/minimal/minimal_interface.cpp +++ b/src/HLS/interface/minimal/minimal_interface.cpp @@ -1057,53 +1057,40 @@ void minimal_interface::build_wrapper(structural_objectRef wrappedObj, structura else { /// check if we have axis master interface - int_port = wrappedObj->find_member("_m_axis_" + port_name + "_TDATA", port_o_K, wrappedObj); - if(int_port) + int_port = wrappedObj->find_member("_" + port_name + "_TDATA", port_o_K, wrappedObj); + if(int_port && + (GetPointer(int_port)->get_port_interface() == port_o::port_interface::PI_FDIN || + GetPointer(int_port)->get_port_interface() == + port_o::port_interface::PI_M_AXIS_TDATA)) { - if(GetPointer(int_port)->get_port_interface() == - port_o::port_interface::PI_FDIN || - GetPointer(int_port)->get_port_interface() == - port_o::port_interface::PI_M_AXIS_TDATA) - { - int_port = wrappedObj->find_member(port_name, port_o_K, wrappedObj); - THROW_ASSERT(int_port, "unexpected condition"); - portsToSkip.insert(int_port); - } + int_port = wrappedObj->find_member(port_name, port_o_K, wrappedObj); + THROW_ASSERT(int_port, "unexpected condition"); + portsToSkip.insert(int_port); } else { /// check if we have axis slave interface - int_port = - wrappedObj->find_member("_s_axis_" + port_name + "_TDATA", port_o_K, wrappedObj); - if(int_port) + int_port = wrappedObj->find_member("_" + port_name + "_TDATA", port_o_K, wrappedObj); + if(int_port && (GetPointer(int_port)->get_port_interface() == + port_o::port_interface::PI_FDOUT || + GetPointer(int_port)->get_port_interface() == + port_o::port_interface::PI_S_AXIS_TDATA)) { - if(GetPointer(int_port)->get_port_interface() == - port_o::port_interface::PI_FDOUT || - GetPointer(int_port)->get_port_interface() == - port_o::port_interface::PI_S_AXIS_TDATA) + portsToSkip.insert(int_port); + if(port_in->get_kind() == port_vector_o_K) { - portsToSkip.insert(int_port); - if(port_in->get_kind() == port_vector_o_K) - { - ext_port = SM_minimal_interface->add_port_vector( - "s_axis_" + port_name + "_TDATA", port_o::IN, - GetPointer(int_port)->get_ports_size(), interfaceObj, - int_port->get_typeRef()); - } - else - { - ext_port = - SM_minimal_interface->add_port("s_axis_" + port_name + "_TDATA", port_o::IN, - interfaceObj, int_port->get_typeRef()); - } - port_o::fix_port_properties(int_port, ext_port); - SM_minimal_interface->add_connection(int_port, ext_port); + ext_port = SM_minimal_interface->add_port_vector( + port_name + "_TDATA", port_o::IN, + GetPointer(int_port)->get_ports_size(), interfaceObj, + int_port->get_typeRef()); } - else if(GetPointer(int_port)->get_port_interface() != - port_o::port_interface::PI_DEFAULT) + else { - THROW_ERROR("not yet supported port interface"); + ext_port = SM_minimal_interface->add_port(port_name + "_TDATA", port_o::IN, + interfaceObj, int_port->get_typeRef()); } + port_o::fix_port_properties(int_port, ext_port); + SM_minimal_interface->add_connection(int_port, ext_port); } } } diff --git a/src/HLS/module_generator/TestbenchAxisModuleGenerator.cpp b/src/HLS/module_generator/TestbenchAxisModuleGenerator.cpp index 75cb935f7..04990db6c 100644 --- a/src/HLS/module_generator/TestbenchAxisModuleGenerator.cpp +++ b/src/HLS/module_generator/TestbenchAxisModuleGenerator.cpp @@ -79,7 +79,7 @@ void TestbenchAxisModuleGenerator::InternalExec(std::ostream& out, structural_ob const auto if_dir = port_o::to_port_direction(iface_attrs.at(FunctionArchitecture::iface_direction)); const auto if_alignment = iface_attrs.at(FunctionArchitecture::iface_alignment); const auto if_ndir = if_dir == port_o::IN ? port_o::OUT : port_o::IN; - const auto port_prefix = (if_dir == port_o::IN ? "s_axis_" : "m_axis_") + arg_name; + const auto port_prefix = arg_name; std::string np_library = mod_cir->get_id() + " index"; std::string ip_components; const auto add_port_parametric = [&](const std::string& suffix, port_o::port_direction dir, unsigned port_size) { diff --git a/src/frontend_analysis/IR_analysis/InterfaceInfer.cpp b/src/frontend_analysis/IR_analysis/InterfaceInfer.cpp index cea4f8a57..450e8d367 100644 --- a/src/frontend_analysis/IR_analysis/InterfaceInfer.cpp +++ b/src/frontend_analysis/IR_analysis/InterfaceInfer.cpp @@ -656,6 +656,10 @@ DesignFlowStep_Status InterfaceInfer::Exec() THROW_WARNING("Parameter '" + arg_name + "' not used by any statement"); } } + if(unused_port && info.type == datatype::generic) + { + info.bitwidth = 8ULL * std::stoull(parm_attrs.at(FunctionArchitecture::parm_size_in_bytes)); + } info.factor = std::max( info.type == datatype::generic ? @@ -761,6 +765,10 @@ DesignFlowStep_Status InterfaceInfer::Exec() return "valid"; } } + else if(unused_port && interface_type == "ptrdefault") + { + return "none"; + } return interface_type; }(); iface_attrs[FunctionArchitecture::iface_bitwidth] = std::to_string(info.bitwidth); @@ -1770,7 +1778,7 @@ void InterfaceInfer::create_resource_Read_simple(const std::set& op port_o::port_interface port_if = port_o::port_interface::PI_RNONE; if(if_name == "axis") { - port_data_name = "_s_axis_" + info.arg_id + "_TDATA"; + port_data_name = "_" + info.arg_id + "_TDATA"; port_if = port_o::port_interface::PI_S_AXIS_TDATA; } else if(if_name == "fifo") @@ -1805,11 +1813,9 @@ void InterfaceInfer::create_resource_Read_simple(const std::set& op } if(if_name == "axis") { - const auto inPort_empty_n = - CM->add_port("_s_axis_" + info.arg_id + "_TVALID", port_o::IN, interface_top, bool_type); + const auto inPort_empty_n = CM->add_port("_" + info.arg_id + "_TVALID", port_o::IN, interface_top, bool_type); GetPointerS(inPort_empty_n)->set_port_interface(port_o::port_interface::PI_S_AXIS_TVALID); - const auto inPort_read = - CM->add_port("_s_axis_" + info.arg_id + "_TREADY", port_o::OUT, interface_top, bool_type); + const auto inPort_read = CM->add_port("_" + info.arg_id + "_TREADY", port_o::OUT, interface_top, bool_type); GetPointerS(inPort_read)->set_port_interface(port_o::port_interface::PI_S_AXIS_TREADY); } @@ -1920,7 +1926,7 @@ void InterfaceInfer::create_resource_Write_simple(const std::set& o port_o::port_interface port_if = port_o::port_interface::PI_WNONE; if(if_name == "axis") { - port_data_name = "_m_axis_" + info.arg_id + "_TDATA"; + port_data_name = "_" + info.arg_id + "_TDATA"; port_if = port_o::port_interface::PI_M_AXIS_TDATA; } else if(if_name == "fifo") @@ -1955,11 +1961,9 @@ void InterfaceInfer::create_resource_Write_simple(const std::set& o } if(if_name == "axis") { - const auto inPort_full_n = - CM->add_port("_m_axis_" + info.arg_id + "_TREADY", port_o::IN, interface_top, bool_type); + const auto inPort_full_n = CM->add_port("_" + info.arg_id + "_TREADY", port_o::IN, interface_top, bool_type); GetPointerS(inPort_full_n)->set_port_interface(port_o::port_interface::PI_M_AXIS_TREADY); - const auto inPort_read = - CM->add_port("_m_axis_" + info.arg_id + "_TVALID", port_o::OUT, interface_top, bool_type); + const auto inPort_read = CM->add_port("_" + info.arg_id + "_TVALID", port_o::OUT, interface_top, bool_type); GetPointerS(inPort_read)->set_port_interface(port_o::port_interface::PI_M_AXIS_TVALID); } From 489fb4c40484462f9f67ef0a515b81c3861a2abc Mon Sep 17 00:00:00 2001 From: Fabrizio Ferrandi Date: Fri, 12 Apr 2024 16:17:39 +0200 Subject: [PATCH 06/13] Fixed some issues on ac_channel and fifo. --- etc/lib/technology/NC_STD_IPs.xml | 5 ++--- etc/libbambu/ac_types/include/ac_channel.h | 3 ++- etc/libbambu/libmdpi/include/mdpi/mdpi_driver.h | 10 +++++++--- etc/libbambu/libmdpi/mdpi.c | 14 ++------------ etc/libbambu/libmdpi/mdpi_driver.cpp | 8 ++++++-- 5 files changed, 19 insertions(+), 21 deletions(-) diff --git a/etc/lib/technology/NC_STD_IPs.xml b/etc/lib/technology/NC_STD_IPs.xml index ce2960970..bbd092093 100644 --- a/etc/lib/technology/NC_STD_IPs.xml +++ b/etc/lib/technology/NC_STD_IPs.xml @@ -3035,8 +3035,7 @@ generate end if(done_port & ~ack_check_next) begin - $display("Acknowledge signal never asserted on interface %0d.", index); - $finish; + $display("WARNING: Acknowledge signal never asserted on interface %0d.", index); end end end @@ -6001,4 +6000,4 @@ generate if (VALUE_PARAMETER != 0) assign out1[VALUE_PARAMETER-1:0] = 0; endgene - \ No newline at end of file + diff --git a/etc/libbambu/ac_types/include/ac_channel.h b/etc/libbambu/ac_types/include/ac_channel.h index b7f1472e8..c11f3045c 100644 --- a/etc/libbambu/ac_types/include/ac_channel.h +++ b/etc/libbambu/ac_types/include/ac_channel.h @@ -677,7 +677,8 @@ class ac_channel __FORCE_INLINE bool nb_read(T& t) { bool res; - t = _read(res); + T temp = _read(res); + t = res ? temp : t; return res; } diff --git a/etc/libbambu/libmdpi/include/mdpi/mdpi_driver.h b/etc/libbambu/libmdpi/include/mdpi/mdpi_driver.h index 1faa2f701..9a0143896 100644 --- a/etc/libbambu/libmdpi/include/mdpi/mdpi_driver.h +++ b/etc/libbambu/libmdpi/include/mdpi/mdpi_driver.h @@ -132,8 +132,12 @@ class channel_interface : public interface { if(!_read_size()) { - if_error("Read on empty channel.\n"); - return IF_EMPTY; + if(shift) + { + if_error("Read on empty channel.\n"); + return IF_EMPTY; + } + return 0; } if(shift) { @@ -188,4 +192,4 @@ void __m_interface_channel(uint8_t id, ac_channel& chan, unsigned int max_siz void __m_interface_set(uint8_t id, interface* if_manager); #endif -#endif // __MDPI_DRIVER_H \ No newline at end of file +#endif // __MDPI_DRIVER_H diff --git a/etc/libbambu/libmdpi/mdpi.c b/etc/libbambu/libmdpi/mdpi.c index 8ac20da00..be4c8c2e4 100644 --- a/etc/libbambu/libmdpi/mdpi.c +++ b/etc/libbambu/libmdpi/mdpi.c @@ -149,12 +149,7 @@ int m_read(uint8_t id, svLogicVecVal* data, uint16_t bitsize, ptr_t addr, uint8_ retval = __m_ipc_operation.payload.interface.info; debug("Interface %u read state -> %d.\n", id, retval); - if(retval < 0) - { - error("Read operation error on interface %u: %u.\n", id, retval); - abort(); - } - else if(__m_ipc_operation.payload.interface.id == id) + if(__m_ipc_operation.payload.interface.id == id) { uint16_t i, size = bitsize / 8 + ((bitsize % 8) != 0); #pragma unroll(4) @@ -221,12 +216,7 @@ int m_write(uint8_t id, CONSTARG svLogicVecVal* data, uint16_t bitsize, ptr_t ad retval = __m_ipc_operation.payload.interface.info; debug("Interface %u write state -> %d.\n", id, retval); - if(retval < 0) - { - error("Write operation error on interface %u: %u.\n", id, retval); - abort(); - } - else if(__m_ipc_operation.payload.interface.id == MDPI_IF_IDX_EMPTY) + if(__m_ipc_operation.payload.interface.id == MDPI_IF_IDX_EMPTY) { debug("Fake pipelined write operation on interface %u.\n", id); } diff --git a/etc/libbambu/libmdpi/mdpi_driver.cpp b/etc/libbambu/libmdpi/mdpi_driver.cpp index 7f2ea8d0d..df4960015 100644 --- a/etc/libbambu/libmdpi/mdpi_driver.cpp +++ b/etc/libbambu/libmdpi/mdpi_driver.cpp @@ -406,8 +406,12 @@ class fifo_interface : public interface assert(bitsize == _bitsize && "Bitsize mismatch"); if(_base == _end) { - if_error("Read on empty FIFO.\n"); - return IF_EMPTY; + if(shift) + { + if_error("Read on empty FIFO.\n"); + return IF_EMPTY; + } + return 0; } if(shift) { From 8bcf523b19020c71f53fa3019d6e8db9c5a79115 Mon Sep 17 00:00:00 2001 From: Fabrizio Ferrandi Date: Fri, 12 Apr 2024 16:27:12 +0200 Subject: [PATCH 07/13] Changed default compiler. --- src/wrapper/compiler/compiler_wrapper.cpp | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/wrapper/compiler/compiler_wrapper.cpp b/src/wrapper/compiler/compiler_wrapper.cpp index e7c8120c9..46f84c959 100644 --- a/src/wrapper/compiler/compiler_wrapper.cpp +++ b/src/wrapper/compiler/compiler_wrapper.cpp @@ -2979,7 +2979,9 @@ int CompilerWrapper::getCompatibleCompilers() int CompilerWrapper::getDefaultCompiler() { return -#if HAVE_I386_CLANG7_COMPILER && defined(_WIN32) +#if HAVE_I386_CLANG16_COMPILER + static_cast(CompilerWrapper_CompilerTarget::CT_I386_CLANG16); +#elif HAVE_I386_CLANG7_COMPILER && defined(_WIN32) static_cast(CompilerWrapper_CompilerTarget::CT_I386_CLANG7); #elif HAVE_I386_GCC49_COMPILER static_cast(CompilerWrapper_CompilerTarget::CT_I386_GCC49); @@ -3011,8 +3013,6 @@ int CompilerWrapper::getDefaultCompiler() static_cast(CompilerWrapper_CompilerTarget::CT_I386_CLANG12); #elif HAVE_I386_CLANG13_COMPILER static_cast(CompilerWrapper_CompilerTarget::CT_I386_CLANG13); -#elif HAVE_I386_CLANG16_COMPILER - static_cast(CompilerWrapper_CompilerTarget::CT_I386_CLANG16); #elif HAVE_I386_CLANGVVD_COMPILER static_cast(CompilerWrapper_CompilerTarget::CT_I386_CLANGVVD); #else From c37553c593b4ee1b0b638af703a81fd515ab8820 Mon Sep 17 00:00:00 2001 From: Fabrizio Ferrandi Date: Fri, 12 Apr 2024 18:51:25 +0200 Subject: [PATCH 08/13] Improved ASTAnalyzer. --- etc/clang_plugin/plugin_ASTAnalyzer.cpp | 68 +++++++++++-------------- 1 file changed, 30 insertions(+), 38 deletions(-) diff --git a/etc/clang_plugin/plugin_ASTAnalyzer.cpp b/etc/clang_plugin/plugin_ASTAnalyzer.cpp index 4d27f8dfc..f3945993f 100644 --- a/etc/clang_plugin/plugin_ASTAnalyzer.cpp +++ b/etc/clang_plugin/plugin_ASTAnalyzer.cpp @@ -849,6 +849,7 @@ class DataflowHLSPragmaHandler : public HLSPragmaAnalyzer, public HLSPragmaParse for(auto& attr : p.attrs) { ReportError(attr.first.loc, "Unexpected attribute"); + return; } GetFuncAttr(FD).attrs.emplace(key_loc_t("dataflow_top", p.loc), "1"); } @@ -892,6 +893,7 @@ class DataflowHLSPragmaHandler : public HLSPragmaAnalyzer, public HLSPragmaParse if(!hasModule) { ReportError(FD->getLocation(), "Dataflow function has no valid submodule"); + return; } } } @@ -932,6 +934,7 @@ class CacheHLSPragmaHandler : public HLSPragmaAnalyzer, public HLSPragmaParser if(bus_size < 32 || bus_size > 1024 || (bus_size & (bus_size - 1)) != 0) { ReportError(attr.first.loc, "Invalid cache bus size"); + return; } } else if(iequals(attr.first.id, "ways")) @@ -939,6 +942,7 @@ class CacheHLSPragmaHandler : public HLSPragmaAnalyzer, public HLSPragmaParser if(std::stoi(attr.second) <= 0) { ReportError(attr.first.loc, "Invalid cache way count"); + return; } } else if(iequals(attr.first.id, "line_count")) @@ -946,6 +950,7 @@ class CacheHLSPragmaHandler : public HLSPragmaAnalyzer, public HLSPragmaParser if(std::stoi(attr.second) <= 0) { ReportError(attr.first.loc, "Invalid cache line count"); + return; } } else if(iequals(attr.first.id, "line_size")) @@ -953,6 +958,7 @@ class CacheHLSPragmaHandler : public HLSPragmaAnalyzer, public HLSPragmaParser if(std::stoi(attr.second) <= 0) { ReportError(attr.first.loc, "Invalid cache line size"); + return; } } else if(iequals(attr.first.id, "num_write_outstanding")) @@ -960,6 +966,7 @@ class CacheHLSPragmaHandler : public HLSPragmaAnalyzer, public HLSPragmaParser if(std::stoi(attr.second) <= 0) { ReportError(attr.first.loc, "Invalid number of outstanding write operations"); + return; } } else if(iequals(attr.first.id, "rep_policy")) @@ -967,6 +974,7 @@ class CacheHLSPragmaHandler : public HLSPragmaAnalyzer, public HLSPragmaParser if(attr.second != "lru" && attr.second != "tree") { ReportError(attr.first.loc, "Invalid cache replacement policy"); + return; } } else if(iequals(attr.first.id, "write_policy")) @@ -974,6 +982,7 @@ class CacheHLSPragmaHandler : public HLSPragmaAnalyzer, public HLSPragmaParser if(attr.second != "wb" && attr.second != "wt") { ReportError(attr.first.loc, "Invalid cache write policy"); + return; } } else @@ -991,10 +1000,12 @@ class CacheHLSPragmaHandler : public HLSPragmaAnalyzer, public HLSPragmaParser if(iface.find(key_loc_t("cache_line_count", SourceLocation())) == iface.end()) { ReportError(p.loc, "Missing cache line count attribute"); + return; } if(iface.find(key_loc_t("cache_line_size", SourceLocation())) == iface.end()) { ReportError(p.loc, "Missing cache line size attribute"); + return; } } @@ -1008,6 +1019,8 @@ class InterfaceHLSPragmaHandler : public HLSPragmaAnalyzer, public HLSPragmaPars SourceManager& _SM; int _parseAction; + static const std::map _ifMapper; + const NamedDecl* getBaseTypeDecl(const QualType& qt) const { const clang::Type* ty = qt.getTypePtr(); @@ -1192,6 +1205,7 @@ class InterfaceHLSPragmaHandler : public HLSPragmaAnalyzer, public HLSPragmaPars if(isUnsupportedInterface(FD)) { ReportError(p.loc, "HLS pragma not supported on variadic function declarations"); + return; } auto portName = p.attrs.find(key_loc_t("port", SourceLocation())); if(portName == p.attrs.end()) @@ -1258,6 +1272,15 @@ class InterfaceHLSPragmaHandler : public HLSPragmaAnalyzer, public HLSPragmaPars const auto argType = parmDecl->getType(); auto& ifaceMode = bundle_attrs.insert(*ifaceModeReq).first->second; + if(_ifMapper.find(ifaceMode) != _ifMapper.end()) + { + ifaceMode = _ifMapper.at(ifaceMode); + if(ifaceMode.empty()) + { + ReportError(ifaceModeReq->first.loc, "Interface mode not supported."); + return; + } + } auto& parmTypename = parm_attrs[key_loc_t("typename", SourceLocation())]; auto& parmSizeInBytes = parm_attrs[key_loc_t("size_in_bytes", SourceLocation())]; auto& parmOriginalTypename = parm_attrs[key_loc_t("original_typename", SourceLocation())]; @@ -1303,41 +1326,6 @@ class InterfaceHLSPragmaHandler : public HLSPragmaAnalyzer, public HLSPragmaPars parmIncludePaths = getIncludePaths(paramTypeRemTD); }; - auto normalizeInterface = [&]() { - if(ifaceMode == "ap_fifo") - { - ifaceMode = "fifo"; - } - else if(ifaceMode == "ap_none") - { - ifaceMode = "none"; - } - else if(ifaceMode == "ap_vld") - { - ifaceMode = "valid"; - } - else if(ifaceMode == "ap_ovld") - { - ifaceMode = "ovalid"; - } - else if(ifaceMode == "ap_ack") - { - ifaceMode = "acknowledge"; - } - else if(ifaceMode == "ap_hs") - { - ifaceMode = "handshake"; - } - else if(ifaceMode == "bram") - { - ReportError(ifaceModeReq->first.loc, "Not support HLS interface mode"); - ifaceMode = "array"; - } - else if(ifaceMode == "ap_memory") - { - ifaceMode = "array"; - } - }; if(isa(argType)) { const auto DT = cast(argType)->getOriginalType().IgnoreParens(); @@ -1353,13 +1341,13 @@ class InterfaceHLSPragmaHandler : public HLSPragmaAnalyzer, public HLSPragmaPars parmOriginalTypename = GetTypeNameCanonical(argType, _PP); parmIncludePaths = getIncludePaths(argType); } - normalizeInterface(); if(ifaceMode != "default") { if(ifaceMode != "handshake" && ifaceMode != "fifo" && ifaceMode != "array" && ifaceMode != "bus" && ifaceMode != "m_axi" && ifaceMode != "axis") { ReportError(ifaceModeReq->first.loc, "Invalid HLS interface mode"); + return; } } } @@ -1381,7 +1369,6 @@ class InterfaceHLSPragmaHandler : public HLSPragmaAnalyzer, public HLSPragmaPars } const auto is_channel_if = parmTypename.find("ac_channel<") == 0 || parmTypename.find("stream<") == 0 || parmTypename.find("hls::stream<") == 0; - normalizeInterface(); if(ifaceMode != "default") { if((ifaceMode != "ptrdefault" && ifaceMode != "none" && ifaceMode != "handshake" && ifaceMode != "valid" && @@ -1390,6 +1377,7 @@ class InterfaceHLSPragmaHandler : public HLSPragmaAnalyzer, public HLSPragmaPars (is_channel_if && ifaceMode != "fifo" && ifaceMode != "axis")) { ReportError(ifaceModeReq->first.loc, "Invalid HLS interface mode"); + return; } } else @@ -1404,13 +1392,13 @@ class InterfaceHLSPragmaHandler : public HLSPragmaAnalyzer, public HLSPragmaPars parmTypename = GetTypeNameCanonical(paramTypeRemTD, _PP); parmOriginalTypename = GetTypeNameCanonical(argType, _PP); parmIncludePaths = getIncludePaths(argType); - normalizeInterface(); if(ifaceMode != "default") { if(ifaceMode != "default" && ifaceMode != "none" && ifaceMode != "handshake" && ifaceMode != "valid" && ifaceMode != "ovalid" && ifaceMode != "acknowledge") { ReportError(ifaceModeReq->first.loc, "Invalid HLS interface mode"); + return; } if((argType->isBuiltinType() || argType->isEnumeralType()) && ifaceMode == "none") { @@ -1426,6 +1414,7 @@ class InterfaceHLSPragmaHandler : public HLSPragmaAnalyzer, public HLSPragmaPars if(ifaceMode == "array" && parm_attrs.find(key_loc_t("elem_count", SourceLocation())) == parm_attrs.end()) { ReportError(ifaceModeReq->first.loc, "HLS interface array element count missing"); + return; } parmTypename = removeSpaces(parmTypename); @@ -1541,6 +1530,9 @@ class InterfaceHLSPragmaHandler : public HLSPragmaAnalyzer, public HLSPragmaPars } static const char* PragmaKeyword; }; +const std::map InterfaceHLSPragmaHandler::_ifMapper = { + {"ap_fifo", "fifo"}, {"ap_none", "none"}, {"ap_vld", "valid"}, {"ap_ovld", "ovalid"}, + {"ap_ack", "acknowledge"}, {"ap_hs", "handshake"}, {"ap_memory", "array"}, {"bram", ""}}; const char* InterfaceHLSPragmaHandler::PragmaKeyword = "interface"; class HLSASTConsumer : public ASTConsumer From 48d937b8a6cd9ff784aa51d0f8d361d1de6c20ce Mon Sep 17 00:00:00 2001 From: Fabrizio Ferrandi Date: Fri, 12 Apr 2024 19:03:58 +0200 Subject: [PATCH 09/13] Fixed the regression scripts defaults. --- examples/crypto_designs/multi.sh | 2 +- examples/panda_bench_altera.sh | 2 +- examples/panda_bench_hw_list | 8 +++--- examples/panda_bench_lattice.sh | 2 +- examples/panda_bench_nanoxplore.sh | 2 +- examples/panda_bench_sim.sh | 2 +- examples/panda_bench_sim_list | 2 +- examples/panda_bench_xilinx_ise.sh | 2 +- examples/panda_bench_xilinx_vvd_list | 42 ++++++++++++++-------------- 9 files changed, 32 insertions(+), 32 deletions(-) diff --git a/examples/crypto_designs/multi.sh b/examples/crypto_designs/multi.sh index 5fe7444fb..e4d2170ef 100755 --- a/examples/crypto_designs/multi.sh +++ b/examples/crypto_designs/multi.sh @@ -25,7 +25,7 @@ return_value=$? if test $return_value != 0; then exit $return_value fi -timeout 2h bambu --simulator=MODELSIM --use-raw --top-fname=keccak_coproc --channels-type=MEM_ACC_11 --device-name=LFE335EA8FN484C src/keccak -I./include --simulate --generate-tb=$root_dir/multi-keccak/tb_keccak.c --print-dot "$@" +timeout 2h bambu --simulator=MODELSIM --use-raw --top-fname=keccak_coproc --channels-type=MEM_ACC_11 --compiler=I386_CLANG49 --device-name=LFE335EA8FN484C src/keccak -I./include --simulate --generate-tb=$root_dir/multi-keccak/tb_keccak.c --print-dot "$@" return_value=$? if test $return_value != 0; then exit $return_value diff --git a/examples/panda_bench_altera.sh b/examples/panda_bench_altera.sh index fc19ae33f..2300371cc 100755 --- a/examples/panda_bench_altera.sh +++ b/examples/panda_bench_altera.sh @@ -1,6 +1,6 @@ #!/bin/bash script_dir="$(dirname $(readlink -e $0))" -BATCH_ARGS=("--evaluation") +BATCH_ARGS=("--evaluation" "--compiler=I386_GCC49") OUT_SUFFIX="pb_altera" python3 $script_dir/../etc/scripts/test_panda.py --tool=bambu \ diff --git a/examples/panda_bench_hw_list b/examples/panda_bench_hw_list index e555294d5..120f85ac4 100644 --- a/examples/panda_bench_hw_list +++ b/examples/panda_bench_hw_list @@ -1,11 +1,11 @@ --configuration-name=breakout breakout/main.c --top-fname=main --compiler=I386_CLANG11 -Os --device-name=xc7a100t-1csg324-VVD --backend-sdc-extensions=BENCHMARKS_ROOT/breakout/Nexys4_Master.sdc --clock-period=10 breakout/constraints_STD.xml breakout/IPs.xml --C-no-parse=BENCHMARKS_ROOT/breakout/plot.c,BENCHMARKS_ROOT/breakout/sevensegments_ctrl.c,BENCHMARKS_ROOT/breakout/btn_ctrl.c,BENCHMARKS_ROOT/breakout/get_ticks.c --file-input-data=BENCHMARKS_ROOT/breakout/plot.v,BENCHMARKS_ROOT/breakout/sevensegments_ctrl.v,BENCHMARKS_ROOT/breakout/btn_ctrl.v,BENCHMARKS_ROOT/breakout/get_ticks.v --speculative-sdc-scheduling --enable-function-proxy ---configuration-name=led_example led_example/led_example.c --top-fname=led_example -O3 --device-name=xc7a100t-1csg324-VVD --backend-sdc-extensions=BENCHMARKS_ROOT/led_example/Nexys4_Master.sdc --clock-period=10 led_example/constraints_STD.xml led_example/IPs.xml --C-no-parse=BENCHMARKS_ROOT/led_example/sw_ctrl.c,BENCHMARKS_ROOT/led_example/leds_ctrl.c,BENCHMARKS_ROOT/led_example/btn_ctrl.c,BENCHMARKS_ROOT/led_example/sevensegments_ctrl.c --file-input-data=BENCHMARKS_ROOT/led_example/leds_ctrl.v,BENCHMARKS_ROOT/led_example/sw_ctrl.v,BENCHMARKS_ROOT/led_example/btn_ctrl.v,BENCHMARKS_ROOT/led_example/sevensegments_ctrl.v --enable-function-proxy +--configuration-name=led_example led_example/led_example.c --top-fname=led_example -O3 --device-name=xc7a100t-1csg324-VVD --backend-sdc-extensions=BENCHMARKS_ROOT/led_example/Nexys4_Master.sdc --clock-period=10 led_example/constraints_STD.xml led_example/IPs.xml --C-no-parse=BENCHMARKS_ROOT/led_example/sw_ctrl.c,BENCHMARKS_ROOT/led_example/leds_ctrl.c,BENCHMARKS_ROOT/led_example/btn_ctrl.c,BENCHMARKS_ROOT/led_example/sevensegments_ctrl.c --file-input-data=BENCHMARKS_ROOT/led_example/leds_ctrl.v,BENCHMARKS_ROOT/led_example/sw_ctrl.v,BENCHMARKS_ROOT/led_example/btn_ctrl.v,BENCHMARKS_ROOT/led_example/sevensegments_ctrl.v --enable-function-proxy --compiler=I386_GCC49 --configuration-name=pong pong/main.c --top-fname=main --compiler=I386_CLANG11 -Os --device-name=xc7a100t-1csg324-VVD --backend-sdc-extensions=BENCHMARKS_ROOT/pong/Nexys4_Master.sdc --clock-period=10 pong/constraints_STD.xml pong/IPs.xml --C-no-parse=BENCHMARKS_ROOT/pong/plot.c,BENCHMARKS_ROOT/pong/sevensegments_ctrl.c,BENCHMARKS_ROOT/pong/btn_ctrl.c,BENCHMARKS_ROOT/pong/get_ticks.c --file-input-data=BENCHMARKS_ROOT/pong/plot.v,BENCHMARKS_ROOT/pong/sevensegments_ctrl.v,BENCHMARKS_ROOT/pong/btn_ctrl.v,BENCHMARKS_ROOT/pong/get_ticks.v --speculative-sdc-scheduling --enable-function-proxy ---configuration-name=taste taste/InterfaceView.aadl --top-fname=first_function,second_function +--configuration-name=taste taste/InterfaceView.aadl --top-fname=first_function,second_function --compiler=I386_GCC49 ---configuration-name=VGA VGA/delay.c VGA/vgatest.c --top-fname=main --clock-period=20 -O3 --target-file=BENCHMARKS_ROOT/VGA/DE1-characterization-file.xml --backend-script-extensions=BENCHMARKS_ROOT/VGA/DE1_pin_assignments.qsf --backend-sdc-extensions=BENCHMARKS_ROOT/VGA/DE1_design.sdc VGA/constraints_STD.xml VGA/PLOT_IPs.xml --C-no-parse=BENCHMARKS_ROOT/VGA/plot.c,BENCHMARKS_ROOT/VGA/leds_ctrl.c -DC_SIMULATION --file-input-data=BENCHMARKS_ROOT/VGA/leds_ctrl.v,BENCHMARKS_ROOT/VGA/plot.v --enable-function-proxy +--configuration-name=VGA VGA/delay.c VGA/vgatest.c --top-fname=main --clock-period=20 -O3 --target-file=BENCHMARKS_ROOT/VGA/DE1-characterization-file.xml --backend-script-extensions=BENCHMARKS_ROOT/VGA/DE1_pin_assignments.qsf --backend-sdc-extensions=BENCHMARKS_ROOT/VGA/DE1_design.sdc VGA/constraints_STD.xml VGA/PLOT_IPs.xml --C-no-parse=BENCHMARKS_ROOT/VGA/plot.c,BENCHMARKS_ROOT/VGA/leds_ctrl.c -DC_SIMULATION --file-input-data=BENCHMARKS_ROOT/VGA/leds_ctrl.v,BENCHMARKS_ROOT/VGA/plot.v --enable-function-proxy --compiler=I386_GCC49 ---configuration-name=VGA_Nexys4 VGA_Nexys4/vgatest.c --top-fname=main --device-name=xc7a100t-1csg324-VVD --clock-period=10 -O3 --backend-sdc-extensions=BENCHMARKS_ROOT/VGA_Nexys4/Nexys4_Master.sdc VGA_Nexys4/constraints_STD.xml VGA_Nexys4/IPs.xml --C-no-parse=BENCHMARKS_ROOT/VGA_Nexys4/plot.c,BENCHMARKS_ROOT/VGA_Nexys4/leds_ctrl.c,BENCHMARKS_ROOT/VGA_Nexys4/btn_ctrl.c,BENCHMARKS_ROOT/VGA_Nexys4/sw_ctrl.c,BENCHMARKS_ROOT/VGA_Nexys4/delay.c --file-input-data=BENCHMARKS_ROOT/VGA_Nexys4/plot.v,BENCHMARKS_ROOT/VGA_Nexys4/leds_ctrl.v,BENCHMARKS_ROOT/VGA_Nexys4/btn_ctrl.v,BENCHMARKS_ROOT/VGA_Nexys4/sw_ctrl.v,BENCHMARKS_ROOT/VGA_Nexys4/delay.v -fwhole-program --speculative-sdc-scheduling --enable-function-proxy +--configuration-name=VGA_Nexys4 VGA_Nexys4/vgatest.c --top-fname=main --device-name=xc7a100t-1csg324-VVD --clock-period=10 -O3 --backend-sdc-extensions=BENCHMARKS_ROOT/VGA_Nexys4/Nexys4_Master.sdc VGA_Nexys4/constraints_STD.xml VGA_Nexys4/IPs.xml --C-no-parse=BENCHMARKS_ROOT/VGA_Nexys4/plot.c,BENCHMARKS_ROOT/VGA_Nexys4/leds_ctrl.c,BENCHMARKS_ROOT/VGA_Nexys4/btn_ctrl.c,BENCHMARKS_ROOT/VGA_Nexys4/sw_ctrl.c,BENCHMARKS_ROOT/VGA_Nexys4/delay.c --file-input-data=BENCHMARKS_ROOT/VGA_Nexys4/plot.v,BENCHMARKS_ROOT/VGA_Nexys4/leds_ctrl.v,BENCHMARKS_ROOT/VGA_Nexys4/btn_ctrl.v,BENCHMARKS_ROOT/VGA_Nexys4/sw_ctrl.v,BENCHMARKS_ROOT/VGA_Nexys4/delay.v -fwhole-program --speculative-sdc-scheduling --enable-function-proxy --compiler=I386_GCC49 diff --git a/examples/panda_bench_lattice.sh b/examples/panda_bench_lattice.sh index 34b7974e3..47ede1eef 100755 --- a/examples/panda_bench_lattice.sh +++ b/examples/panda_bench_lattice.sh @@ -1,6 +1,6 @@ #!/bin/bash script_dir="$(dirname $(readlink -e $0))" -BATCH_ARGS=("--evaluation=CYCLES") +BATCH_ARGS=("--evaluation=CYCLES" "--compiler=I386_GCC49") OUT_SUFFIX="pb_lattice" python3 $script_dir/../etc/scripts/test_panda.py --tool=bambu \ diff --git a/examples/panda_bench_nanoxplore.sh b/examples/panda_bench_nanoxplore.sh index 452cb5c47..aca0fe13c 100755 --- a/examples/panda_bench_nanoxplore.sh +++ b/examples/panda_bench_nanoxplore.sh @@ -1,6 +1,6 @@ #!/bin/bash script_dir="$(dirname $(readlink -e $0))" -BATCH_ARGS=("--clock-period=20" "--evaluation") +BATCH_ARGS=("--clock-period=20" "--evaluation" "--compiler=I386_GCC49") OUT_SUFFIX="pb_nanoxplore" python3 $script_dir/../etc/scripts/test_panda.py --tool=bambu \ diff --git a/examples/panda_bench_sim.sh b/examples/panda_bench_sim.sh index 78dbffba7..11bb3eeec 100755 --- a/examples/panda_bench_sim.sh +++ b/examples/panda_bench_sim.sh @@ -1,6 +1,6 @@ #!/bin/bash script_dir="$(dirname $(readlink -e $0))" -BATCH_ARGS=("--simulate") +BATCH_ARGS=("--simulate" "--compiler=I386_GCC49") OUT_SUFFIX="pb_sim" python3 $script_dir/../etc/scripts/test_panda.py --tool=bambu \ diff --git a/examples/panda_bench_sim_list b/examples/panda_bench_sim_list index 12851d98e..6bf39d3a5 100644 --- a/examples/panda_bench_sim_list +++ b/examples/panda_bench_sim_list @@ -5,7 +5,7 @@ --configuration-name=file_simulate file_simulate/module.c --top-fname=check_printf --benchmark-name=MEM_ACC_11 --experimental-setup=BAMBU --generate-tb=BENCHMARKS_ROOT/file_simulate/test.xml --file-input-data=BENCHMARKS_ROOT/file_simulate/test.xml --channels-type=MEM_ACC_11 --configuration-name=file_simulate file_simulate/module.c --top-fname=check_printf --benchmark-name=MEM_ACC_NN --experimental-setup=BAMBU --generate-tb=BENCHMARKS_ROOT/file_simulate/test.xml --file-input-data=BENCHMARKS_ROOT/file_simulate/test.xml --channels-type=MEM_ACC_NN -# --configuration-name=parallel_queries parallel_queries/common/atominIncrement.c parallel_queries/common/data.c parallel_queries/trinityq3/lubm_trinityq3.c --top-fname=search --compiler=I386_GCC49 --std=c99 --experimental-setup=BAMBU -O3 -fno-delete-null-pointer-checks -fopenmp --pragma-parse --mem-delay-read=20 --mem-delay-write=20 --channels-type=MEM_ACC_11 --memory-allocation-policy=NO_BRAM --device-name=xc7vx690t-3ffg1930-VVD --clock-period=10 -DMAX_VERTEX_NUMBER=26455 -DMAX_EDGE_NUMBER=100573 -DNDEBUG --benchmark-name=02W-04CH-2C-04CS -DN_THREADS=2 --num-accelerators=2 --memory-banks-number=4 --channels-number=2 --context_switch=4 -IBENCHMARKS_ROOT/parallel_queries/common/ --generate-tb=BENCHMARKS_ROOT/parallel_queries/trinityq3/test-1.xml +# --configuration-name=parallel_queries parallel_queries/common/atominIncrement.c parallel_queries/common/data.c parallel_queries/trinityq3/lubm_trinityq3.c --top-fname=search --std=c99 --experimental-setup=BAMBU -O3 -fno-delete-null-pointer-checks -fopenmp --pragma-parse --mem-delay-read=20 --mem-delay-write=20 --channels-type=MEM_ACC_11 --memory-allocation-policy=NO_BRAM --device-name=xc7vx690t-3ffg1930-VVD --clock-period=10 -DMAX_VERTEX_NUMBER=26455 -DMAX_EDGE_NUMBER=100573 -DNDEBUG --benchmark-name=02W-04CH-2C-04CS -DN_THREADS=2 --num-accelerators=2 --memory-banks-number=4 --channels-number=2 --context_switch=4 -IBENCHMARKS_ROOT/parallel_queries/common/ --generate-tb=BENCHMARKS_ROOT/parallel_queries/trinityq3/test-1.xml --configuration-name=sha256 sha-256/sha-256.c --top-fname=calc_sha_256 --generate-tb=BENCHMARKS_ROOT/sha-256/test.xml --speculative-sdc-scheduling diff --git a/examples/panda_bench_xilinx_ise.sh b/examples/panda_bench_xilinx_ise.sh index 30587b403..66fec77f8 100755 --- a/examples/panda_bench_xilinx_ise.sh +++ b/examples/panda_bench_xilinx_ise.sh @@ -1,6 +1,6 @@ #!/bin/bash script_dir="$(dirname $(readlink -e $0))" -BATCH_ARGS=("--evaluation") +BATCH_ARGS=("--evaluation" "--compiler=I386_GCC49") OUT_SUFFIX="pb_xise" python3 $script_dir/../etc/scripts/test_panda.py --tool=bambu \ diff --git a/examples/panda_bench_xilinx_vvd_list b/examples/panda_bench_xilinx_vvd_list index 36deb23a5..e9d6c6024 100644 --- a/examples/panda_bench_xilinx_vvd_list +++ b/examples/panda_bench_xilinx_vvd_list @@ -1,19 +1,19 @@ ---configuration-name=ads add_device_simple/module.c --top-fname=main --generate-tb=BENCHMARKS_ROOT/add_device_simple/test.xml --simulator=XSIM --experimental-setup=BAMBU -O2 -m64 --pretty-print=a.c --target-file=BENCHMARKS_ROOT/add_device_simple/xc7z045-2ffg900-VVD.xml - ---configuration-name=arf --benchmark-name=arf_simple arf/module.c --top-fname=arf --generate-tb=BENCHMARKS_ROOT/arf/test.xml - ---configuration-name=ars --benchmark-name=un_zynq arf_res_sharing/module.c --top-fname=arf --generate-tb=BENCHMARKS_ROOT/arf_res_sharing/test.xml --simulator=VERILATOR --experimental-setup=BAMBU --generate-interface=WB4 --clock-period=5 --cprf=0.9 --skip-pipe-parameter=1 ---configuration-name=ars --benchmark-name=un_vx690t arf_res_sharing/module.c --top-fname=arf --generate-tb=BENCHMARKS_ROOT/arf_res_sharing/test.xml --simulator=VERILATOR --experimental-setup=BAMBU --generate-interface=WB4 --clock-period=5 --cprf=0.9 --skip-pipe-parameter=1 --device-name=xc7vx690t,-3,ffg1930,VVD ---configuration-name=ars --benchmark-name=un_vc707 arf_res_sharing/module.c --top-fname=arf --generate-tb=BENCHMARKS_ROOT/arf_res_sharing/test.xml --simulator=VERILATOR --experimental-setup=BAMBU --generate-interface=WB4 --clock-period=5 --cprf=0.9 --skip-pipe-parameter=1 --device-name=xc7vx485t,-2,ffg1761,VVD ---configuration-name=ars --benchmark-name=un_artix7 arf_res_sharing/module.c --top-fname=arf --generate-tb=BENCHMARKS_ROOT/arf_res_sharing/test.xml --simulator=VERILATOR --experimental-setup=BAMBU --generate-interface=WB4 --clock-period=5 --cprf=0.9 --skip-pipe-parameter=1 --device-name=xc7a100t,-1,csg324,VVD ---configuration-name=ars --benchmark-name=un_kintex arf_res_sharing/module.c --top-fname=arf --generate-tb=BENCHMARKS_ROOT/arf_res_sharing/test.xml --simulator=VERILATOR --experimental-setup=BAMBU --generate-interface=WB4 --clock-period=5 --cprf=0.9 --skip-pipe-parameter=1 --device-name=xcku060,-3,ffva1156,VVD ---configuration-name=ars --benchmark-name=co_zynq arf_res_sharing/module.c --top-fname=arf --generate-tb=BENCHMARKS_ROOT/arf_res_sharing/test.xml --simulator=VERILATOR --experimental-setup=BAMBU --generate-interface=WB4 --clock-period=5 --cprf=0.9 --skip-pipe-parameter=1 arf_res_sharing/constraints_STD.xml ---configuration-name=ars --benchmark-name=co_vx690t arf_res_sharing/module.c --top-fname=arf --generate-tb=BENCHMARKS_ROOT/arf_res_sharing/test.xml --simulator=VERILATOR --experimental-setup=BAMBU --generate-interface=WB4 --clock-period=5 --cprf=0.9 --skip-pipe-parameter=1 arf_res_sharing/constraints_STD.xml --device-name=xc7vx690t,-3,ffg1930,VVD ---configuration-name=ars --benchmark-name=co_vc707 arf_res_sharing/module.c --top-fname=arf --generate-tb=BENCHMARKS_ROOT/arf_res_sharing/test.xml --simulator=VERILATOR --experimental-setup=BAMBU --generate-interface=WB4 --clock-period=5 --cprf=0.9 --skip-pipe-parameter=1 arf_res_sharing/constraints_STD.xml --device-name=xc7vx485t,-2,ffg1761,VVD ---configuration-name=ars --benchmark-name=co_artix7 arf_res_sharing/module.c --top-fname=arf --generate-tb=BENCHMARKS_ROOT/arf_res_sharing/test.xml --simulator=VERILATOR --experimental-setup=BAMBU --generate-interface=WB4 --clock-period=5 --cprf=0.9 --skip-pipe-parameter=1 arf_res_sharing/constraints_STD.xml --device-name=xc7a100t,-1,csg324,VVD ---configuration-name=ars --benchmark-name=co_kintex arf_res_sharing/module.c --top-fname=arf --generate-tb=BENCHMARKS_ROOT/arf_res_sharing/test.xml --simulator=VERILATOR --experimental-setup=BAMBU --generate-interface=WB4 --clock-period=5 --cprf=0.9 --skip-pipe-parameter=1 arf_res_sharing/constraints_STD.xml --device-name=xcku060,-3,ffva1156,VVD ---configuration-name=ars --benchmark-name=co_alveo280 arf_res_sharing/module.c --top-fname=arf --generate-tb=BENCHMARKS_ROOT/arf_res_sharing/test.xml --simulator=VERILATOR --experimental-setup=BAMBU --generate-interface=WB4 --clock-period=5 --cprf=0.9 --skip-pipe-parameter=1 arf_res_sharing/constraints_STD.xml --device-name=xcu280-2Lfsvh2892-VVD ---configuration-name=ars --benchmark-name=co_alveo55c arf_res_sharing/module.c --top-fname=arf --generate-tb=BENCHMARKS_ROOT/arf_res_sharing/test.xml --simulator=VERILATOR --experimental-setup=BAMBU --generate-interface=WB4 --clock-period=5 --cprf=0.9 --skip-pipe-parameter=1 arf_res_sharing/constraints_STD.xml --device-name=xcu55c-2Lfsvh2892-VVD +--configuration-name=ads add_device_simple/module.c --top-fname=main --generate-tb=BENCHMARKS_ROOT/add_device_simple/test.xml --simulator=XSIM --experimental-setup=BAMBU -O2 -m64 --pretty-print=a.c --target-file=BENCHMARKS_ROOT/add_device_simple/xc7z045-2ffg900-VVD.xml --compiler=I386_GCC49 + +--configuration-name=arf --benchmark-name=arf_simple arf/module.c --top-fname=arf --generate-tb=BENCHMARKS_ROOT/arf/test.xml --compiler=I386_GCC49 + +--configuration-name=ars --benchmark-name=un_zynq arf_res_sharing/module.c --top-fname=arf --generate-tb=BENCHMARKS_ROOT/arf_res_sharing/test.xml --simulator=VERILATOR --experimental-setup=BAMBU --generate-interface=WB4 --clock-period=5 --cprf=0.9 --skip-pipe-parameter=1 --compiler=I386_GCC49 +--configuration-name=ars --benchmark-name=un_vx690t arf_res_sharing/module.c --top-fname=arf --generate-tb=BENCHMARKS_ROOT/arf_res_sharing/test.xml --simulator=VERILATOR --experimental-setup=BAMBU --generate-interface=WB4 --clock-period=5 --cprf=0.9 --skip-pipe-parameter=1 --device-name=xc7vx690t,-3,ffg1930,VVD --compiler=I386_GCC49 +--configuration-name=ars --benchmark-name=un_vc707 arf_res_sharing/module.c --top-fname=arf --generate-tb=BENCHMARKS_ROOT/arf_res_sharing/test.xml --simulator=VERILATOR --experimental-setup=BAMBU --generate-interface=WB4 --clock-period=5 --cprf=0.9 --skip-pipe-parameter=1 --device-name=xc7vx485t,-2,ffg1761,VVD --compiler=I386_GCC49 +--configuration-name=ars --benchmark-name=un_artix7 arf_res_sharing/module.c --top-fname=arf --generate-tb=BENCHMARKS_ROOT/arf_res_sharing/test.xml --simulator=VERILATOR --experimental-setup=BAMBU --generate-interface=WB4 --clock-period=5 --cprf=0.9 --skip-pipe-parameter=1 --device-name=xc7a100t,-1,csg324,VVD --compiler=I386_GCC49 +--configuration-name=ars --benchmark-name=un_kintex arf_res_sharing/module.c --top-fname=arf --generate-tb=BENCHMARKS_ROOT/arf_res_sharing/test.xml --simulator=VERILATOR --experimental-setup=BAMBU --generate-interface=WB4 --clock-period=5 --cprf=0.9 --skip-pipe-parameter=1 --device-name=xcku060,-3,ffva1156,VVD --compiler=I386_GCC49 +--configuration-name=ars --benchmark-name=co_zynq arf_res_sharing/module.c --top-fname=arf --generate-tb=BENCHMARKS_ROOT/arf_res_sharing/test.xml --simulator=VERILATOR --experimental-setup=BAMBU --generate-interface=WB4 --clock-period=5 --cprf=0.9 --skip-pipe-parameter=1 arf_res_sharing/constraints_STD.xml --compiler=I386_GCC49 +--configuration-name=ars --benchmark-name=co_vx690t arf_res_sharing/module.c --top-fname=arf --generate-tb=BENCHMARKS_ROOT/arf_res_sharing/test.xml --simulator=VERILATOR --experimental-setup=BAMBU --generate-interface=WB4 --clock-period=5 --cprf=0.9 --skip-pipe-parameter=1 arf_res_sharing/constraints_STD.xml --device-name=xc7vx690t,-3,ffg1930,VVD --compiler=I386_GCC49 +--configuration-name=ars --benchmark-name=co_vc707 arf_res_sharing/module.c --top-fname=arf --generate-tb=BENCHMARKS_ROOT/arf_res_sharing/test.xml --simulator=VERILATOR --experimental-setup=BAMBU --generate-interface=WB4 --clock-period=5 --cprf=0.9 --skip-pipe-parameter=1 arf_res_sharing/constraints_STD.xml --device-name=xc7vx485t,-2,ffg1761,VVD --compiler=I386_GCC49 +--configuration-name=ars --benchmark-name=co_artix7 arf_res_sharing/module.c --top-fname=arf --generate-tb=BENCHMARKS_ROOT/arf_res_sharing/test.xml --simulator=VERILATOR --experimental-setup=BAMBU --generate-interface=WB4 --clock-period=5 --cprf=0.9 --skip-pipe-parameter=1 arf_res_sharing/constraints_STD.xml --device-name=xc7a100t,-1,csg324,VVD --compiler=I386_GCC49 +--configuration-name=ars --benchmark-name=co_kintex arf_res_sharing/module.c --top-fname=arf --generate-tb=BENCHMARKS_ROOT/arf_res_sharing/test.xml --simulator=VERILATOR --experimental-setup=BAMBU --generate-interface=WB4 --clock-period=5 --cprf=0.9 --skip-pipe-parameter=1 arf_res_sharing/constraints_STD.xml --device-name=xcku060,-3,ffva1156,VVD --compiler=I386_GCC49 +--configuration-name=ars --benchmark-name=co_alveo280 arf_res_sharing/module.c --top-fname=arf --generate-tb=BENCHMARKS_ROOT/arf_res_sharing/test.xml --simulator=VERILATOR --experimental-setup=BAMBU --generate-interface=WB4 --clock-period=5 --cprf=0.9 --skip-pipe-parameter=1 arf_res_sharing/constraints_STD.xml --device-name=xcu280-2Lfsvh2892-VVD --compiler=I386_GCC49 +--configuration-name=ars --benchmark-name=co_alveo55c arf_res_sharing/module.c --top-fname=arf --generate-tb=BENCHMARKS_ROOT/arf_res_sharing/test.xml --simulator=VERILATOR --experimental-setup=BAMBU --generate-interface=WB4 --clock-period=5 --cprf=0.9 --skip-pipe-parameter=1 arf_res_sharing/constraints_STD.xml --device-name=xcu55c-2Lfsvh2892-VVD --compiler=I386_GCC49 --configuration-name=atan --benchmark-name=bit cpp_examples/Xilinx_Examples/Math/atan2_cordic/cordic_atan2.cpp --generate-tb=BENCHMARKS_ROOT/cpp_examples/Xilinx_Examples/Math/atan2_cordic/cordic_test.cpp -DTEST_COUNT=200 -DCUSTOM_VERIFICATION --file-input-data=BENCHMARKS_ROOT/cpp_examples/Xilinx_Examples/Math/atan2_cordic/input_data.txt,BENCHMARKS_ROOT/cpp_examples/Xilinx_Examples/Math/atan2_cordic/ref_results.txt --compiler=I386_CLANG6 --device-name=xc7vx690t-3ffg1930-VVD --clock-period=10 --generate-interface=INFER --top-fname=top_atan2 -DDB_CORDIC -DBIT_ACCURATE --configuration-name=atan --benchmark-name=base cpp_examples/Xilinx_Examples/Math/atan2_cordic/cordic_atan2.cpp --generate-tb=BENCHMARKS_ROOT/cpp_examples/Xilinx_Examples/Math/atan2_cordic/cordic_test.cpp -DTEST_COUNT=200 -DCUSTOM_VERIFICATION --file-input-data=BENCHMARKS_ROOT/cpp_examples/Xilinx_Examples/Math/atan2_cordic/input_data.txt,BENCHMARKS_ROOT/cpp_examples/Xilinx_Examples/Math/atan2_cordic/ref_results.txt --compiler=I386_CLANG6 --device-name=xc7vx690t-3ffg1930-VVD --clock-period=10 --generate-interface=INFER --top-fname=top_atan2 -DDB_CORDIC @@ -25,13 +25,13 @@ --configuration-name=sda --benchmark-name=no-unroll cpp_examples/Xilinx_Examples/Math/squared_difference_accumulate/src/diff_sq_acc.cpp --generate-tb=BENCHMARKS_ROOT/cpp_examples/Xilinx_Examples/Math/squared_difference_accumulate/tb/diff_sq_acc_tb.cpp --compiler=I386_CLANG6 --device-name=xc7vx690t-3ffg1930-VVD --clock-period=10 --generate-interface=INFER --top-fname=diff_sq_acc --configuration-name=gcd --benchmark-name=base cpp_examples/gcd_example/gcd.cc --compiler=I386_GCC7 --generate-tb=BENCHMARKS_ROOT/cpp_examples/gcd_example/test.xml --discrepancy --top-fname=gcd --hls-div=nr1 ---configuration-name=fft --benchmark-name=x_no_main fft_example/fft_float.c --top-fname=FFT --generate-tb=BENCHMARKS_ROOT/fft_example/test_no_main.xml --experimental-setup=BAMBU --device-name=xc7z020,-1,clg484,VVD -lm -Os -ffast-math --libm-std-rounding --generate-interface=WB4 ---configuration-name=fft --benchmark-name=x_main fft_example/fft_float.c --top-fname=main --generate-tb=BENCHMARKS_ROOT/fft_example/test.xml --experimental-setup=BAMBU --device-name=xc7z020,-1,clg484,VVD -lm -Os -ffast-math --libm-std-rounding -fwhole-program +--configuration-name=fft --benchmark-name=x_no_main fft_example/fft_float.c --top-fname=FFT --generate-tb=BENCHMARKS_ROOT/fft_example/test_no_main.xml --experimental-setup=BAMBU --device-name=xc7z020,-1,clg484,VVD -lm -Os -ffast-math --libm-std-rounding --generate-interface=WB4 --compiler=I386_GCC49 +--configuration-name=fft --benchmark-name=x_main fft_example/fft_float.c --top-fname=main --generate-tb=BENCHMARKS_ROOT/fft_example/test.xml --experimental-setup=BAMBU --device-name=xc7z020,-1,clg484,VVD -lm -Os -ffast-math --libm-std-rounding -fwhole-program --compiler=I386_GCC49 ---configuration-name=fortran --benchmark-name=copy fortran/euclid.copy.f -fno-underscoring --top-fname=ngcd --generate-tb=BENCHMARKS_ROOT/fortran/test.copy.xml --speculative-sdc-scheduling --pretty-print=a.c ---configuration-name=fortran --benchmark-name=base fortran/euclid.f -fno-underscoring --top-fname=ngcd --generate-tb=BENCHMARKS_ROOT/fortran/test.xml --speculative-sdc-scheduling --pretty-print=a.c +--configuration-name=fortran --benchmark-name=copy fortran/euclid.copy.f -fno-underscoring --top-fname=ngcd --generate-tb=BENCHMARKS_ROOT/fortran/test.copy.xml --speculative-sdc-scheduling --pretty-print=a.c --compiler=I386_GCC49 +--configuration-name=fortran --benchmark-name=base fortran/euclid.f -fno-underscoring --top-fname=ngcd --generate-tb=BENCHMARKS_ROOT/fortran/test.xml --speculative-sdc-scheduling --pretty-print=a.c --compiler=I386_GCC49 ---configuration-name=funcp function_pointers/qsort/glibc/test.c function_pointers/qsort/glibc/less.c function_pointers/qsort/glibc/qsort.c --generate-tb=BENCHMARKS_ROOT/function_pointers/qsort/tb.c --experimental-setup=BAMBU --device-name=xc7z020-1clg484-VVD -Os --top-fname=test +--configuration-name=funcp function_pointers/qsort/glibc/test.c function_pointers/qsort/glibc/less.c function_pointers/qsort/glibc/qsort.c --generate-tb=BENCHMARKS_ROOT/function_pointers/qsort/tb.c --experimental-setup=BAMBU --device-name=xc7z020-1clg484-VVD -Os --top-fname=test --compiler=I386_GCC49 --configuration-name=IPint IP_integration/top.c --generate-tb=BENCHMARKS_ROOT/IP_integration/main_test.c --experimental-setup=BAMBU --C-no-parse=BENCHMARKS_ROOT/IP_integration/module1.c,BENCHMARKS_ROOT/IP_integration/module2.c,BENCHMARKS_ROOT/IP_integration/printer1.c,BENCHMARKS_ROOT/IP_integration/printer2.c --file-input-data=BENCHMARKS_ROOT/IP_integration/module1.v,BENCHMARKS_ROOT/IP_integration/module2.v,BENCHMARKS_ROOT/IP_integration/printer1.v,BENCHMARKS_ROOT/IP_integration/printer2.v IP_integration/module_lib.xml --top-fname=my_ip IP_integration/constraints_STD.xml --memory-allocation-policy=ALL_BRAM -O3 --enable-function-proxy From d3c975636c4a6cc7c734e5f77886a72393c8b92b Mon Sep 17 00:00:00 2001 From: Fabrizio Ferrandi Date: Fri, 12 Apr 2024 21:49:36 +0200 Subject: [PATCH 10/13] Fixed an issue with keccak example. --- examples/crypto_designs/multi-keccak/configure.ac | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/examples/crypto_designs/multi-keccak/configure.ac b/examples/crypto_designs/multi-keccak/configure.ac index 62593409a..809d1aa84 100644 --- a/examples/crypto_designs/multi-keccak/configure.ac +++ b/examples/crypto_designs/multi-keccak/configure.ac @@ -8,6 +8,6 @@ m4_ifdef([AM_SILENT_RULES], [AM_SILENT_RULES([yes])]) LT_INIT([disable-shared]) AC_PROG_CC AC_PROG_INSTALL -CFLAGS=' -O3' +CFLAGS=' -O3 --compiler=I386_GCC49' CC=tree-panda-gcc AC_OUTPUT(Makefile include/Makefile src/Makefile src/chi/Makefile src/iota/Makefile src/pi/Makefile src/rho/Makefile src/theta/Makefile) From bfe544089205add47a30c53fcd7f38ece7996052 Mon Sep 17 00:00:00 2001 From: Fabrizio Ferrandi Date: Sat, 13 Apr 2024 09:21:06 +0200 Subject: [PATCH 11/13] Code refactoring. --- etc/clang_plugin/plugin_ASTAnalyzer.cpp | 15 +++++++-------- examples/crypto_designs/multi.sh | 2 +- src/HLS/binding/module/fu_binding.cpp | 7 +------ src/HLS/module_allocation/allocation.cpp | 7 +------ src/circuit/structural_objects.cpp | 6 ++++++ src/circuit/structural_objects.hpp | 6 ++++++ 6 files changed, 22 insertions(+), 21 deletions(-) diff --git a/etc/clang_plugin/plugin_ASTAnalyzer.cpp b/etc/clang_plugin/plugin_ASTAnalyzer.cpp index f3945993f..0d6d5e78f 100644 --- a/etc/clang_plugin/plugin_ASTAnalyzer.cpp +++ b/etc/clang_plugin/plugin_ASTAnalyzer.cpp @@ -849,7 +849,6 @@ class DataflowHLSPragmaHandler : public HLSPragmaAnalyzer, public HLSPragmaParse for(auto& attr : p.attrs) { ReportError(attr.first.loc, "Unexpected attribute"); - return; } GetFuncAttr(FD).attrs.emplace(key_loc_t("dataflow_top", p.loc), "1"); } @@ -934,7 +933,7 @@ class CacheHLSPragmaHandler : public HLSPragmaAnalyzer, public HLSPragmaParser if(bus_size < 32 || bus_size > 1024 || (bus_size & (bus_size - 1)) != 0) { ReportError(attr.first.loc, "Invalid cache bus size"); - return; + continue; } } else if(iequals(attr.first.id, "ways")) @@ -942,7 +941,7 @@ class CacheHLSPragmaHandler : public HLSPragmaAnalyzer, public HLSPragmaParser if(std::stoi(attr.second) <= 0) { ReportError(attr.first.loc, "Invalid cache way count"); - return; + continue; } } else if(iequals(attr.first.id, "line_count")) @@ -950,7 +949,7 @@ class CacheHLSPragmaHandler : public HLSPragmaAnalyzer, public HLSPragmaParser if(std::stoi(attr.second) <= 0) { ReportError(attr.first.loc, "Invalid cache line count"); - return; + continue; } } else if(iequals(attr.first.id, "line_size")) @@ -958,7 +957,7 @@ class CacheHLSPragmaHandler : public HLSPragmaAnalyzer, public HLSPragmaParser if(std::stoi(attr.second) <= 0) { ReportError(attr.first.loc, "Invalid cache line size"); - return; + continue; } } else if(iequals(attr.first.id, "num_write_outstanding")) @@ -966,7 +965,7 @@ class CacheHLSPragmaHandler : public HLSPragmaAnalyzer, public HLSPragmaParser if(std::stoi(attr.second) <= 0) { ReportError(attr.first.loc, "Invalid number of outstanding write operations"); - return; + continue; } } else if(iequals(attr.first.id, "rep_policy")) @@ -974,7 +973,7 @@ class CacheHLSPragmaHandler : public HLSPragmaAnalyzer, public HLSPragmaParser if(attr.second != "lru" && attr.second != "tree") { ReportError(attr.first.loc, "Invalid cache replacement policy"); - return; + continue; } } else if(iequals(attr.first.id, "write_policy")) @@ -982,7 +981,7 @@ class CacheHLSPragmaHandler : public HLSPragmaAnalyzer, public HLSPragmaParser if(attr.second != "wb" && attr.second != "wt") { ReportError(attr.first.loc, "Invalid cache write policy"); - return; + continue; } } else diff --git a/examples/crypto_designs/multi.sh b/examples/crypto_designs/multi.sh index e4d2170ef..c1cf9ee70 100755 --- a/examples/crypto_designs/multi.sh +++ b/examples/crypto_designs/multi.sh @@ -25,7 +25,7 @@ return_value=$? if test $return_value != 0; then exit $return_value fi -timeout 2h bambu --simulator=MODELSIM --use-raw --top-fname=keccak_coproc --channels-type=MEM_ACC_11 --compiler=I386_CLANG49 --device-name=LFE335EA8FN484C src/keccak -I./include --simulate --generate-tb=$root_dir/multi-keccak/tb_keccak.c --print-dot "$@" +timeout 2h bambu --simulator=MODELSIM --use-raw --top-fname=keccak_coproc --channels-type=MEM_ACC_11 --compiler=I386_GCC49 --device-name=LFE335EA8FN484C src/keccak -I./include --simulate --generate-tb=$root_dir/multi-keccak/tb_keccak.c --print-dot "$@" return_value=$? if test $return_value != 0; then exit $return_value diff --git a/src/HLS/binding/module/fu_binding.cpp b/src/HLS/binding/module/fu_binding.cpp index abb2ea72f..77049eb2b 100644 --- a/src/HLS/binding/module/fu_binding.cpp +++ b/src/HLS/binding/module/fu_binding.cpp @@ -1202,12 +1202,7 @@ void fu_binding::add_to_SM(const HLS_managerRef HLSMgr, const hlsRef HLS, struct technology_nodeRef fuObj = TechMan->get_fu(fu_name, UPlibrary); const auto structManager_obj = GetPointer(fuObj)->CM; THROW_ASSERT(structManager_obj, "unexpected condition"); - const auto has_to_be_generated = GetPointer(structManager_obj->get_circ()) - ->get_NP_functionality() - ->exist_NP_functionality(NP_functionality::VERILOG_GENERATOR) || - GetPointer(structManager_obj->get_circ()) - ->get_NP_functionality() - ->exist_NP_functionality(NP_functionality::VHDL_GENERATOR); + const auto has_to_be_generated = GetPointer(structManager_obj->get_circ())->has_to_be_generated(); if(has_to_be_generated) { INDENT_DBG_MEX(DEBUG_LEVEL_VERY_PEDANTIC, debug_level, "Unit has to be specialized."); diff --git a/src/HLS/module_allocation/allocation.cpp b/src/HLS/module_allocation/allocation.cpp index 917e9311d..622b35880 100644 --- a/src/HLS/module_allocation/allocation.cpp +++ b/src/HLS/module_allocation/allocation.cpp @@ -2178,12 +2178,7 @@ DesignFlowStep_Status allocation::InternalExec() std::string specialized_fuName = ""; const auto has_to_be_generated = - structManager_obj && (GetPointer(structManager_obj->get_circ()) - ->get_NP_functionality() - ->exist_NP_functionality(NP_functionality::VERILOG_GENERATOR) || - GetPointer(structManager_obj->get_circ()) - ->get_NP_functionality() - ->exist_NP_functionality(NP_functionality::VHDL_GENERATOR)); + structManager_obj && GetPointer(structManager_obj->get_circ())->has_to_be_generated(); if(has_to_be_generated) { INDENT_DBG_MEX(DEBUG_LEVEL_VERY_PEDANTIC, debug_level, "Unit has to be specialized."); diff --git a/src/circuit/structural_objects.cpp b/src/circuit/structural_objects.cpp index 90b5b4710..496d0c093 100644 --- a/src/circuit/structural_objects.cpp +++ b/src/circuit/structural_objects.cpp @@ -3318,6 +3318,12 @@ const NP_functionalityRef& module::get_NP_functionality() const return NP_descriptions; } +bool module::has_to_be_generated() const +{ + return get_NP_functionality()->exist_NP_functionality(NP_functionality::VERILOG_GENERATOR) || + get_NP_functionality()->exist_NP_functionality(NP_functionality::VHDL_GENERATOR); +} + void module::get_NP_library_parameters( structural_objectRef _owner, std::vector>& computed_parameters) const { diff --git a/src/circuit/structural_objects.hpp b/src/circuit/structural_objects.hpp index 302c5636b..3b6107208 100644 --- a/src/circuit/structural_objects.hpp +++ b/src/circuit/structural_objects.hpp @@ -2032,6 +2032,12 @@ class module : public structural_object */ const NP_functionalityRef& get_NP_functionality() const; + /** + * @brief has_to_be_generated + * @return true in case the functionality has to be generated + */ + bool has_to_be_generated() const; + /** * Return the list of object that can be parametrized. * This function is usually used by the backend. From 9a4e678f29d195b5289286589a2ad4ac030ce21d Mon Sep 17 00:00:00 2001 From: Fabrizio Ferrandi Date: Sat, 13 Apr 2024 09:22:48 +0200 Subject: [PATCH 12/13] Fixed a problem with databus sizing. --- etc/lib/technology/NC_MEM_IPs.xml | 32 +++++++++++++++++++------------ 1 file changed, 20 insertions(+), 12 deletions(-) diff --git a/etc/lib/technology/NC_MEM_IPs.xml b/etc/lib/technology/NC_MEM_IPs.xml index 38e72cbaf..f731699d9 100644 --- a/etc/lib/technology/NC_MEM_IPs.xml +++ b/etc/lib/technology/NC_MEM_IPs.xml @@ -3058,12 +3058,16 @@ function [n_byte_on_databus*2-1:0] CONV; input [n_byte_on_databus*2-1:0] po2; begin case (po2) - 1:CONV=(1<<1)-1; - 2:CONV=(1<<2)-1; - 4:CONV=(1<<4)-1; - 8:CONV=(1<<8)-1; - 16:CONV=(1<<16)-1; - 32:CONV=(1<<32)-1; + 1:CONV=({{n_byte_on_databus*2-1{1'b0}},1'b1}<<1)-1; + 2:CONV=({{n_byte_on_databus*2-1{1'b0}},1'b1}<<2)-1; + 4:CONV=({{n_byte_on_databus*2-1{1'b0}},1'b1}<<4)-1; + 8:CONV=({{n_byte_on_databus*2-1{1'b0}},1'b1}<<8)-1; + 16:CONV=({{n_byte_on_databus*2-1{1'b0}},1'b1}<<16)-1; + 32:CONV=({{n_byte_on_databus*2-1{1'b0}},1'b1}<<32)-1; + 64:CONV=({{n_byte_on_databus*2-1{1'b0}},1'b1}<<64)-1; + 128:CONV=({{n_byte_on_databus*2-1{1'b0}},1'b1}<<128)-1; + 256:CONV=({{n_byte_on_databus*2-1{1'b0}},1'b1}<<256)-1; + 512:CONV=({{n_byte_on_databus*2-1{1'b0}},1'b1}<<512)-1; default:CONV=-1; endcase end @@ -3719,12 +3723,16 @@ function [n_byte_on_databus*max_n_writes-1:0] CONV; input [n_byte_on_databus*max_n_writes-1:0] po2; begin case (po2) - 1:CONV=(1<<1)-1; - 2:CONV=(1<<2)-1; - 4:CONV=(1<<4)-1; - 8:CONV=(1<<8)-1; - 16:CONV=(1<<16)-1; - 32:CONV=(1<<32)-1; + 1:CONV=({{n_byte_on_databus*2-1{1'b0}},1'b1}<<1)-1; + 2:CONV=({{n_byte_on_databus*2-1{1'b0}},1'b1}<<2)-1; + 4:CONV=({{n_byte_on_databus*2-1{1'b0}},1'b1}<<4)-1; + 8:CONV=({{n_byte_on_databus*2-1{1'b0}},1'b1}<<8)-1; + 16:CONV=({{n_byte_on_databus*2-1{1'b0}},1'b1}<<16)-1; + 32:CONV=({{n_byte_on_databus*2-1{1'b0}},1'b1}<<32)-1; + 64:CONV=({{n_byte_on_databus*2-1{1'b0}},1'b1}<<64)-1; + 128:CONV=({{n_byte_on_databus*2-1{1'b0}},1'b1}<<128)-1; + 256:CONV=({{n_byte_on_databus*2-1{1'b0}},1'b1}<<256)-1; + 512:CONV=({{n_byte_on_databus*2-1{1'b0}},1'b1}<<512)-1; default:CONV=-1; endcase end From 0ce1761c2a73e5f93e5de775e7e8a278ded7ba02 Mon Sep 17 00:00:00 2001 From: Fabrizio Ferrandi Date: Sat, 13 Apr 2024 09:23:56 +0200 Subject: [PATCH 13/13] Fixed a problem with XSIM code understanding. --- etc/lib/technology/NC_MEM_IPs.xml | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) diff --git a/etc/lib/technology/NC_MEM_IPs.xml b/etc/lib/technology/NC_MEM_IPs.xml index f731699d9..1fb917181 100644 --- a/etc/lib/technology/NC_MEM_IPs.xml +++ b/etc/lib/technology/NC_MEM_IPs.xml @@ -13413,10 +13413,16 @@ endgenerate"/> wire [(n_byte_on_databus/2)*8-1:0] dina; wire [(n_byte_on_databus/2)*8-1:0] dinb; wire [n_byte_on_databus*8-1:0] din; +wire [n_byte_on_databus/2-1:0] be0; +wire [n_byte_on_databus/2-1:0] be1; +wire [n_byte_on_databus-1:0] beTot; assign dina = din_value_aggregated_swapped[memory_offset+:(n_byte_on_databus/2)*8]; assign dinb = din_value_aggregated_swapped[2*BRAM_BITSIZE+memory_offset+:(n_byte_on_databus/2)*8]; assign din = {dinb,dina}; +assign be0 = be_swapped[n_byte_on_databus_offset+:n_byte_on_databus/2]; +assign be1 = be_swapped[n_byte_on_databus+n_byte_on_databus_offset+:n_byte_on_databus/2]; +assign beTot = {be1,be0}; generate if(n_elements == 1) @@ -13440,7 +13446,7 @@ begin .bram_write(bram_write), .memory_addr_a(memory_addr_a), .din_value_aggregated(din), - .be({be_swapped[n_byte_on_databus+n_byte_on_databus_offset+:n_byte_on_databus/2],be_swapped[n_byte_on_databus_offset+:n_byte_on_databus/2]}), + .be(beTot), .dout_a(dout_a)); end else @@ -13466,8 +13472,8 @@ begin .memory_addr_b(memory_addr_a[2*BITSIZE_memory_addr_a-1:BITSIZE_memory_addr_a]), .din_value_aggregated_a(dina), .din_value_aggregated_b(dinb), - .be_a(be_swapped[n_byte_on_databus_offset+:n_byte_on_databus/2]), - .be_b(be_swapped[n_byte_on_databus+n_byte_on_databus_offset+:n_byte_on_databus/2]), + .be_a(be0), + .be_b(be1), .dout_a(dout_a[BRAM_BITSIZE-1:0]), .dout_b(dout_a[2*BRAM_BITSIZE-1:BRAM_BITSIZE]) );