16 return std::make_unique<DataflowPlugin>();
21 return std::string(
"dataflow");
26 return std::string(
"0.3");
31 return "Dataflow analysis tool DANA to recover word-level structures such as registers from gate-level netlists.";
49 description.
add(
"--dataflow",
"execute the dataflow plugin");
51 description.
add(
"--path",
"specify output path", {
""});
53 description.
add(
"--sizes",
"(optional) specify sizes to be prioritized", {
""});
55 description.
add(
"--bad_group_size",
"(optional) specify the bad group size", {
""});
70 if (
args.is_option_set(
"--path"))
72 if (
args.get_parameter(
"--path").back() ==
'/')
73 path =
args.get_parameter(
"--path");
75 path =
args.get_parameter(
"--path") +
"/";
79 log_error(
"dataflow",
"path parameter not set");
82 if (
args.is_option_set(
"--sizes"))
84 std::istringstream f(
args.get_parameter(
"--sizes"));
86 while (std::getline(f, s,
','))
92 if (
args.is_option_set(
"--bad_group_size"))
94 std::istringstream f(
args.get_parameter(
"--bad_group_size"));
96 while (std::getline(f, s,
','))
103 if (grouping_res.is_error())
105 log_error(
"dataflow",
"dataflow analysis failed:\n{}", grouping_res.get_error().get());
111 auto grouping = grouping_res.get();
112 if (
const auto res = grouping.write_dot(path); res.is_error())
114 log_error(
"dataflow",
"could not write .dot file:\n{}", res.get_error().get());
116 if (
const auto res = grouping.write_txt(path); res.is_error())
118 log_error(
"dataflow",
"could not write .txt file:\n{}", res.get_error().get());
127 std::vector<PluginParameter> retval;
143 if (par.get_tagname() ==
"sizes")
145 std::istringstream f(par.get_value());
147 while (std::getline(f, s,
','))
149 m_expected_sizes.emplace_back(std::stoi(s));
152 else if (par.get_tagname() ==
"min_group_size")
154 m_min_group_size = atoi(par.get_value().c_str());
156 else if (par.get_tagname() ==
"write_txt")
158 m_write_txt = (par.get_value() ==
"true");
160 else if (par.get_tagname() ==
"write_dot")
162 m_write_dot = (par.get_value() ==
"true");
164 else if (par.get_tagname() ==
"output")
166 m_output_path = par.get_value();
168 else if (par.get_tagname() ==
"create_modules")
170 m_create_modules = (par.get_value() ==
"true");
172 else if (par.get_tagname() ==
"register_stage_identification")
174 m_enable_stages = (par.get_value() ==
"true");
176 else if (par.get_tagname() ==
"exec")
178 m_button_clicked = (par.get_value() ==
"clicked");
187 if (!m_button_clicked)
191 log_warning(
"dataflow",
"Error setting paramater: no netlist loaded.");
209 if (grouping_res.is_error())
211 log_error(
"dataflow",
"dataflow analysis failed:\n{}", grouping_res.get_error().get());
214 auto grouping = grouping_res.get();
215 std::filesystem::path dot_graph_written_to_path;
219 if (
const auto res = grouping.write_dot(m_output_path); res.is_error())
221 log_error(
"dataflow",
"could not write .dot file:\n{}", res.get_error().get());
225 dot_graph_written_to_path = res.get();
231 if (
const auto res = grouping.write_txt(m_output_path); res.is_error())
233 log_error(
"dataflow",
"could not write .txt file:\n{}", res.get_error().get());
237 if (m_create_modules)
239 if (
const auto res = grouping.create_modules(); res.is_error())
241 log_error(
"dataflow",
"could not create modules:\n{}", res.get_error().get());
246 if (!dot_graph_written_to_path.empty())
248 grouping.open_dot_in_viewer(dot_graph_written_to_path);
std::vector< AbstractExtensionInterface * > m_extensions
virtual bool handle_cli_call(Netlist *netlist, ProgramArguments &args) override
virtual ProgramOptions get_cli_options() const override
DataflowPlugin()
Constructor for DataflowPlugin.
std::string get_name() const override
Get the name of the plugin.
std::set< std::string > get_dependencies() const override
Get the plugin dependencies.
std::string get_version() const override
Get the version of the plugin.
std::string get_description() const override
Get a short description of the plugin.
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 plugin on the given netlist.
virtual void register_progress_indicator(std::function< void(int, const std::string &)> pif) override
std::vector< PluginParameter > get_parameter() const override
Get a vector of configurable parameters.
void set_parameter(const std::vector< PluginParameter > ¶ms) override
Set values for a vector of configurable parameters.
static std::function< void(int, const std::string &)> s_progress_indicator_function
bool add(const std::string &flag, const std::string &description, const std::initializer_list< std::string > ¶meters={})
#define log_error(channel,...)
#define log_warning(channel,...)
hal::Result< dataflow::Result > analyze(const Configuration &config)
Analyze the gate-level netlist to identify word-level structures such as registers.
std::unique_ptr< BasePluginInterface > create_plugin_instance()
This file contains the class that holds all information of a dataflow analysis grouping.
Configuration of a dataflow analysis run.
std::vector< u32 > expected_sizes
Expected group sizes. Groups of these sizes will be prioritized. Defaults to an empty vector.
Configuration & with_gate_types(const std::set< const GateType * > &types, bool overwrite=false)
Add the gate types to the set of gate types to be grouped by dataflow analysis.
Configuration & with_control_pin_types(const std::set< PinType > &types, bool overwrite=false)
Set the pin types of the pins to be considered control pins by dataflow analysis.
Configuration & with_stage_identification(bool enable=true)
Enable stage identification as part of dataflow analysis.
u32 min_group_size
Minimum size of a group. Smaller groups will be penalized during analysis. Defaults to 8.
Configuration & with_expected_sizes(const std::vector< u32 > &sizes)
Set the expected group sizes. Groups of these sizes will be prioritized.
Configuration & with_min_group_size(u32 size)
Set the minimum size of a group. Smaller groups will be penalized during analysis.