Skip to content

Commit

Permalink
Code refactoring.
Browse files Browse the repository at this point in the history
  • Loading branch information
fabrizioferrandi committed Apr 13, 2024
1 parent d3c9756 commit bfe5440
Show file tree
Hide file tree
Showing 6 changed files with 22 additions and 21 deletions.
15 changes: 7 additions & 8 deletions etc/clang_plugin/plugin_ASTAnalyzer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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");
}
Expand Down Expand Up @@ -934,55 +933,55 @@ 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"))
{
if(std::stoi(attr.second) <= 0)
{
ReportError(attr.first.loc, "Invalid cache way count");
return;
continue;
}
}
else if(iequals(attr.first.id, "line_count"))
{
if(std::stoi(attr.second) <= 0)
{
ReportError(attr.first.loc, "Invalid cache line count");
return;
continue;
}
}
else if(iequals(attr.first.id, "line_size"))
{
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"))
{
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"))
{
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"))
{
if(attr.second != "wb" && attr.second != "wt")
{
ReportError(attr.first.loc, "Invalid cache write policy");
return;
continue;
}
}
else
Expand Down
2 changes: 1 addition & 1 deletion examples/crypto_designs/multi.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
7 changes: 1 addition & 6 deletions src/HLS/binding/module/fu_binding.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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<functional_unit>(fuObj)->CM;
THROW_ASSERT(structManager_obj, "unexpected condition");
const auto has_to_be_generated = GetPointer<module>(structManager_obj->get_circ())
->get_NP_functionality()
->exist_NP_functionality(NP_functionality::VERILOG_GENERATOR) ||
GetPointer<module>(structManager_obj->get_circ())
->get_NP_functionality()
->exist_NP_functionality(NP_functionality::VHDL_GENERATOR);
const auto has_to_be_generated = GetPointer<module>(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.");
Expand Down
7 changes: 1 addition & 6 deletions src/HLS/module_allocation/allocation.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2178,12 +2178,7 @@ DesignFlowStep_Status allocation::InternalExec()
std::string specialized_fuName = "";

const auto has_to_be_generated =
structManager_obj && (GetPointer<module>(structManager_obj->get_circ())
->get_NP_functionality()
->exist_NP_functionality(NP_functionality::VERILOG_GENERATOR) ||
GetPointer<module>(structManager_obj->get_circ())
->get_NP_functionality()
->exist_NP_functionality(NP_functionality::VHDL_GENERATOR));
structManager_obj && GetPointer<module>(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.");
Expand Down
6 changes: 6 additions & 0 deletions src/circuit/structural_objects.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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<std::pair<std::string, structural_objectRef>>& computed_parameters) const
{
Expand Down
6 changes: 6 additions & 0 deletions src/circuit/structural_objects.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down

0 comments on commit bfe5440

Please sign in to comment.