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", {
""});
67 if (
args.is_option_set(
"--path"))
69 if (
args.get_parameter(
"--path").back() ==
'/')
70 path =
args.get_parameter(
"--path");
72 path =
args.get_parameter(
"--path") +
"/";
76 log_error(
"dataflow",
"path parameter not set");
79 if (
args.is_option_set(
"--sizes"))
81 std::istringstream f(
args.get_parameter(
"--sizes"));
83 while (std::getline(f, s,
','))
89 if (
args.is_option_set(
"--bad_group_size"))
91 std::istringstream f(
args.get_parameter(
"--bad_group_size"));
93 while (std::getline(f, s,
','))
100 if (grouping_res.is_error())
102 log_error(
"dataflow",
"dataflow analysis failed:\n{}", grouping_res.get_error().get());
111 std::vector<PluginParameter> retval;
127 if (par.get_tagname() ==
"sizes")
129 std::istringstream f(par.get_value());
131 while (std::getline(f, s,
','))
133 m_expected_sizes.emplace_back(std::stoi(s));
136 else if (par.get_tagname() ==
"min_group_size")
138 m_min_group_size = atoi(par.get_value().c_str());
140 else if (par.get_tagname() ==
"write_txt")
142 m_write_txt = (par.get_value() ==
"true");
144 else if (par.get_tagname() ==
"write_dot")
146 m_write_dot = (par.get_value() ==
"true");
148 else if (par.get_tagname() ==
"output")
150 m_output_path = par.get_value();
152 else if (par.get_tagname() ==
"create_modules")
154 m_create_modules = (par.get_value() ==
"true");
156 else if (par.get_tagname() ==
"register_stage_identification")
158 m_enable_stages = (par.get_value() ==
"true");
160 else if (par.get_tagname() ==
"exec")
162 m_button_clicked = (par.get_value() ==
"clicked");
171 if (!m_button_clicked)
175 log_warning(
"dataflow",
"Error setting paramater: no netlist loaded.");
193 if (grouping_res.is_error())
195 log_error(
"dataflow",
"dataflow analysis failed:\n{}", grouping_res.get_error().get());
198 auto grouping = grouping_res.get();
202 if (
const auto res = grouping.write_dot(m_output_path); res.is_error())
204 log_error(
"dataflow",
"could not write .dot file:\n{}", res.get_error().get());
210 if (
const auto res = grouping.write_txt(m_output_path); res.is_error())
212 log_error(
"dataflow",
"could not write .txt file:\n{}", res.get_error().get());
216 if (m_create_modules)
218 if (
const auto res = grouping.create_modules(); res.is_error())
220 log_error(
"dataflow",
"could not create modules:\n{}", res.get_error().get());
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_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.