HAL  v4.5.0-124-g47ab54673
The Hardware Analyzer - a comprehensive reverse engineering and manipulation framework for gate-level netlists.
dataflow.cpp
Go to the documentation of this file.
2 
8 
9 namespace hal
10 {
11  namespace dataflow
12  {
14  {
15  if (config.netlist == nullptr)
16  {
17  return ERR("netlist is a nullptr");
18  }
19 
20  if (config.gate_types.empty())
21  {
22  return ERR("no gate types specified");
23  }
24 
25  if (config.control_pin_types.empty())
26  {
27  return ERR("no control pin types specified");
28  }
29 
30  // the analysis reports its progress to the GUI from here on, so it also has to dismiss the progress
31  // indicator again once it is done, no matter whether it was invoked from the GUI or from a script
32  const user_feedback::ProgressScope progress("dataflow analysis …");
33 
34  // set up dataflow analysis
35  double total_time = 0;
36  auto begin_time = std::chrono::high_resolution_clock::now();
37 
39  proc_config.pass_layers = 2;
40  proc_config.num_threads = std::thread::hardware_concurrency();
42  proc_config.has_known_groups = !config.known_net_groups.empty();
43 
45 
47  eval_config.prioritized_sizes = config.expected_sizes;
48  eval_config.min_group_size = config.min_group_size;
49 
50  if (!eval_config.prioritized_sizes.empty())
51  {
52  log_info("dataflow", "will prioritize sizes {}", utils::join(", ", config.expected_sizes));
53  }
54 
55  std::shared_ptr<dataflow::Grouping> initial_grouping = nullptr;
56  auto netlist_abstr = dataflow::pre_processing::run(config, initial_grouping);
57  std::shared_ptr<dataflow::Grouping> final_grouping = nullptr;
58 
59  u32 iteration = 0;
60  while (true)
61  {
62  log_info("dataflow", "iteration {}", iteration);
63 
64  // main dataflow analysis
65  auto processing_result = dataflow::processing::run(proc_config, initial_grouping);
66  auto eval_result = dataflow::evaluation::run(eval_config, eval_ctx, initial_grouping, processing_result);
67 
68  // end of analysis(?)
69  if (eval_result.is_final_result)
70  {
71  log_info("dataflow", "got final result");
72  final_grouping = eval_result.merged_result;
73  break;
74  }
75 
76  initial_grouping = eval_result.merged_result;
77 
78  iteration++;
79  }
80 
82 
83  total_time = (double)std::chrono::duration_cast<std::chrono::milliseconds>(std::chrono::high_resolution_clock::now() - begin_time).count() / 1000;
84 
85  log_info("dataflow", "dataflow processing finished in {:3.2f}s", total_time);
86 
87  return OK(dataflow::Result(config.netlist, *final_grouping));
88  }
89  } // namespace dataflow
90 } // namespace hal
Result of a dataflow analysis run.
Definition: result.h:60
This file contains the function that analyses the dataflow of a gate-level netlist.
uint32_t u32
Definition: defines.h:41
#define log_info(channel,...)
Definition: log.h:70
#define ERR(message)
Definition: result.h:60
#define OK(...)
Definition: result.h:56
evaluation::Result run(const Configuration &config, Context &ctx, const std::shared_ptr< Grouping > &initial_grouping, const processing::Result &result)
Definition: evaluation.cpp:278
NetlistAbstraction run(const dataflow::Configuration &config, std::shared_ptr< dataflow::Grouping > &initial_grouping)
processing::Result run(const processing::Configuration &config, const std::shared_ptr< Grouping > &initial_grouping)
Definition: processing.cpp:156
hal::Result< dataflow::Result > analyze(const Configuration &config)
Analyze the gate-level netlist to identify word-level structures such as registers.
Definition: dataflow.cpp:13
std::string join(const std::string &joiner, const Iterator &begin, const Iterator &end, const Transform &transform)
Definition: utils.h:414
Definition: defines.h:45
Configuration of a dataflow analysis run.
Definition: configuration.h:61
std::vector< std::vector< Net * > > known_net_groups
Groups of nets that have been identified as word-level datapathes beforehand. Defaults to an empty ve...
Definition: configuration.h:92
std::vector< u32 > expected_sizes
Expected group sizes. Groups of these sizes will be prioritized. Defaults to an empty vector.
Definition: configuration.h:82
std::set< const GateType * > gate_types
The gate types to be grouped by dataflow analysis. Defaults to an empty set.
Definition: configuration.h:97
std::set< PinType > control_pin_types
The pin types of the pins to be considered control pins. Defaults to an empty set.
bool enforce_type_consistency
Enforce gate type consistency inside of a group. Defaults to false.
u32 min_group_size
Minimum size of a group. Smaller groups will be penalized during analysis. Defaults to 8.
Definition: configuration.h:77
Netlist * netlist
The netlist to be analyzed.
Definition: configuration.h:72