23 return std::make_unique<ModuleIdentificationPlugin>();
28 return std::string(
"module_identification");
33 return std::string(
"0.1");
38 return std::string(
"Plugin for module classification against a library of predefined types.");
43 std::set<std::string> retval;
44 retval.insert(
"boolean_influence");
45 retval.insert(
"z3_utils");
56 if (par.get_tagname() ==
"general_config/max_thread_count")
58 m_max_thread_count = atoi(par.get_value().c_str());
60 else if (par.get_tagname() ==
"general_config/max_control_signals")
62 m_max_control_signals = atoi(par.get_value().c_str());
64 else if (par.get_tagname() ==
"general_config/check_selector")
66 if (par.get_value() ==
"whole netlist")
70 else if (par.get_value() ==
"selected gates")
74 else if (par.get_value() ==
"selected modules")
80 log_error(
"module_identification",
"check selector returned not valid result");
83 else if (par.get_tagname() ==
"general_config/multi_selector")
85 if (par.get_value() ==
"time_priority")
89 else if (par.get_value() ==
"memory_priority")
95 log_error(
"module_identification",
"check selector returned not valid result");
98 else if (par.get_tagname() ==
"exec")
100 m_button_clicked = (par.get_value() ==
"clicked");
106 if (par.get_tagname() == (
"to_check_types/" +
enum_to_string(cur_type)))
108 if (par.get_value() ==
"true")
110 if (std::find(m_types_to_check.begin(), m_types_to_check.end(), cur_type) == m_types_to_check.end())
112 m_types_to_check.push_back(cur_type);
117 auto type_it = std::find(m_types_to_check.begin(), m_types_to_check.end(), cur_type);
118 if (type_it != m_types_to_check.end())
120 m_types_to_check.erase(type_it);
131 std::vector<PluginParameter> retval;
147 std::transform(type_name.begin(), type_name.end(), type_name.begin(), [](
unsigned char c) { return std::tolower(c); });
158 if (tag ==
"Module Identification")
160 m_max_thread_count = 1;
161 m_max_control_signals = 4;
162 m_check_selector = 1;
163 m_do_multithreading =
false;
165 else if (tag ==
"exec_nl")
167 m_max_thread_count = 1;
168 m_max_control_signals = 4;
169 m_check_selector = 0;
170 m_do_multithreading =
false;
172 else if (tag ==
"exec_module")
174 m_max_thread_count = 1;
175 m_max_control_signals = 4;
176 m_check_selector = 2;
177 m_do_multithreading =
false;
181 if (!m_button_clicked)
186 types_to_check = m_types_to_check;
191 log_warning(
"module_identification",
"Error setting paramater: no netlist loaded.");
209 if (m_check_selector == 0)
212 if (execution_res.is_error())
214 log_error(
"module_identification",
"{}", execution_res.get_error().get());
218 const auto& creation_res = execution_res.get().create_modules_in_netlist();
219 if (creation_res.is_error())
221 log_error(
"module_identification",
"{}", creation_res.get_error().get());
224 else if (m_check_selector == 1)
226 std::vector<Gate*> gates;
227 for (
u32 gate_id : gate_ids)
232 if (execution_res.is_error())
234 log_error(
"module_identification",
"{}", execution_res.get_error().get());
238 const auto& creation_res = execution_res.get().create_modules_in_netlist();
239 if (creation_res.is_error())
241 log_error(
"module_identification",
"{}", creation_res.get_error().get());
246 for (
u32 module_id : module_ids)
249 const std::vector<Gate*> gates = cur_module->
get_gates();
251 if (execution_res.is_error())
253 log_error(
"module_identification",
"{}", execution_res.get_error().get());
257 const auto& creation_res = execution_res.get().create_modules_in_netlist();
258 if (creation_res.is_error())
260 log_error(
"module_identification",
"{}", creation_res.get_error().get());
280 std::vector<ContextMenuContribution> retval;
282 context.mContributer =
this;
283 context.mTagname =
"Module Identification";
284 context.mEntry =
"Run module identification on selected gates";
285 retval.push_back(context);
287 context2.mContributer =
this;
288 context2.mTagname =
"exec_module";
289 context2.mEntry =
"Run module identification on selected modules";
290 retval.push_back(context2);
292 context3.mContributer =
this;
293 context3.mTagname =
"exec_nl";
294 context3.mEntry =
"Run module identification on netlist";
295 retval.push_back(context3);
std::vector< AbstractExtensionInterface * > m_extensions
GUI extension interface for the module identification plugin.
virtual void register_progress_indicator(std::function< void(int, const std::string &)> pif) override
Register function to indicate work progress when busy.
std::vector< ContextMenuContribution > get_context_contribution(const Netlist *nl, const std::vector< u32 > &mods, const std::vector< u32 > &gats, const std::vector< u32 > &nets)
Get context menu contributions based on the current netlist and selection.
void set_parameter(const std::vector< PluginParameter > ¶ms) override
Set configurable parameters to values.
static std::function< void(int, const std::string &)> s_progress_indicator_function
Static progress indicator function.
void execute_function(std::string tag, Netlist *nl, const std::vector< u32 > &mods, const std::vector< u32 > &gats, const std::vector< u32 > &nets) override
Execute a function with a specific tag on a netlist.
std::vector< PluginParameter > get_parameter() const override
Get list of configurable parameters.
const std::vector< Gate * > & get_gates() const
std::set< std::string > get_dependencies() const override
Get the plugin dependencies.
ModuleIdentificationPlugin()
Constructor for ModuleIdentificationPlugin.
std::string get_description() const override
Get a short description of the plugin.
std::string get_name() const override
Get the name of the plugin.
std::string get_version() const override
Get the version of the plugin.
Gate * get_gate_by_id(const u32 gate_id) const
Module * get_module_by_id(u32 module_id) const
#define log_error(channel,...)
#define log_warning(channel,...)
This file contains the struct Configuration for module identification analysis.
This file contains the function declarations for the Module Identification plugin in hal.
const std::vector< CandidateType > all_checkable_candidate_types
A list of all candidate types that are selectable to be checked.
hal::Result< Result > execute(const Configuration &config)
Perform a full run of the module identification process on the given netlist with the provided config...
hal::Result< Result > execute_on_gates(const std::vector< Gate * > &gates, const Configuration &config)
Perform a module identification run on the specified gates with the provided configuration.
CandidateType
Enumeration of the different candidate types for module identification.
@ time_priority
Prioritize time efficiency in multithreading.
@ memory_priority
Prioritize memory efficiency in multithreading.
std::unique_ptr< BasePluginInterface > create_plugin_instance()
std::string enum_to_string(T e)
This file contains the structures and functions related to module identification results.
Configuration for the module identification analysis.
Configuration & with_multithreading_priority(const MultithreadingPriority &priority)
Set the multithreading priority type.
Configuration & with_types_to_check(const std::vector< module_identification::CandidateType > &types_to_check)
Set the candidate types to be checked.
Configuration & with_max_control_signals(const u32 &max_control_signals)
Set the maximum number of control signals to be tested.
Configuration & with_max_thread_count(const u32 &max_thread_count)
Set the maximum number of threads.