9 #include <unordered_set>
20 return std::make_unique<NetlistPreprocessingPlugin>();
25 return std::string(
"netlist_preprocessing");
30 return std::string(
"0.2");
35 return "A collection of tools to preprocess a netlist and prepare it for further analysis.";
40 std::set<std::string> retval;
41 retval.insert(
"resynthesis");
42 retval.insert(
"z3_utils");
52 std::vector<Gate*> gates_from_selection(
Netlist* nl,
const std::vector<u32>& mods,
const std::vector<u32>& gats)
54 std::vector<Gate*> res;
55 std::unordered_set<Gate*> seen;
57 const auto collect = [&res, &seen](
Gate* g) {
58 if (g !=
nullptr && seen.insert(g).second)
73 for (Gate* g : m->get_gates(
nullptr,
true))
86 std::vector<ContextMenuContribution> retval;
88 const auto add = [
this, &retval](
const std::string& tag,
const std::string& entry) {
93 retval.push_back(cmc);
97 if (!mods.empty() || !gats.empty())
99 add(
"remove_buffers_selection",
"Remove buffers from selection");
100 add(
"unify_ff_outputs_selection",
"Unify flip-flop outputs of selection");
104 add(
"remove_buffers_netlist",
"Remove buffers from netlist");
105 add(
"unify_ff_outputs_netlist",
"Unify flip-flop outputs of netlist");
115 log_warning(
"netlist_preprocessing",
"cannot run preprocessing: no netlist loaded.");
124 std::vector<Gate*> scope;
125 if (tag ==
"remove_buffers_selection" || tag ==
"unify_ff_outputs_selection")
127 scope = gates_from_selection(nl, mods, gats);
130 log_warning(
"netlist_preprocessing",
"cannot run preprocessing on the selection: no gates selected.");
135 if (tag ==
"remove_buffers_selection" || tag ==
"remove_buffers_netlist")
139 log_error(
"netlist_preprocessing",
"failed to remove buffers: {}", res.get_error().get());
142 else if (tag ==
"unify_ff_outputs_selection" || tag ==
"unify_ff_outputs_netlist")
146 log_error(
"netlist_preprocessing",
"failed to unify flip-flop outputs: {}", res.get_error().get());
150 log_info(
"netlist_preprocessing",
"rerouted {} 'neg_state' outputs.", res.get());
155 log_warning(
"netlist_preprocessing",
"unknown context menu tag '{}'.", tag);
std::vector< AbstractExtensionInterface * > m_extensions
GUI extension interface for the netlist preprocessing plugin.
std::vector< ContextMenuContribution > get_context_contribution(const Netlist *nl, const std::vector< u32 > &mods, const std::vector< u32 > &gats, const std::vector< u32 > &nets) override
Get the context menu entries contributed for the given selection.
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 the context menu entry identified by the given tag.
Gate * get_gate_by_id(const u32 gate_id) const
Module * get_module_by_id(u32 module_id) const
std::string get_name() const override
Get the name of the plugin.
std::string get_description() const override
Get a short description of the plugin.
std::string get_version() const override
Get the version of the plugin.
std::set< std::string > get_dependencies() const override
Get the plugin dependencies.
NetlistPreprocessingPlugin()
Constructor for NetlistPreprocessingPlugin that registers the GUI extension.
Suppresses layout updates of the GUI for as long as the object exists.
#define log_error(channel,...)
#define log_info(channel,...)
#define log_warning(channel,...)
Result< u32 > remove_buffers(Netlist *nl, const std::vector< Gate * > &gates={})
Result< u32 > unify_ff_outputs(Netlist *nl, const std::vector< Gate * > &ffs={}, GateType *inverter_type=nullptr)
std::unique_ptr< BasePluginInterface > create_plugin_instance()
This file contains a helper that suppresses layout updates of the GUI.
This file contains all functions related to the HAL plugin API.