HAL
dataflow.cpp
Go to the documentation of this file.
2 
7 
8 namespace hal
9 {
10  namespace dataflow
11  {
13  {
14  if (config.netlist == nullptr)
15  {
16  return ERR("netlist is a nullptr");
17  }
18 
19  if (config.gate_types.empty())
20  {
21  return ERR("no gate types specified");
22  }
23 
24  if (config.control_pin_types.empty())
25  {
26  return ERR("no control pin types specified");
27  }
28 
29  // set up dataflow analysis
30  double total_time = 0;
31  auto begin_time = std::chrono::high_resolution_clock::now();
32 
34  proc_config.pass_layers = 2;
35  proc_config.num_threads = std::thread::hardware_concurrency();
37  proc_config.has_known_groups = !config.known_net_groups.empty();
38 
40 
42  eval_config.prioritized_sizes = config.expected_sizes;
43  eval_config.min_group_size = config.min_group_size;
44 
45  if (!eval_config.prioritized_sizes.empty())
46  {
47  log_info("dataflow", "will prioritize sizes {}", utils::join(", ", config.expected_sizes));
48  }
49 
50  std::shared_ptr<dataflow::Grouping> initial_grouping = nullptr;
51  auto netlist_abstr = dataflow::pre_processing::run(config, initial_grouping);
52  std::shared_ptr<dataflow::Grouping> final_grouping = nullptr;
53 
54  u32 iteration = 0;
55  while (true)
56  {
57  log_info("dataflow", "iteration {}", iteration);
58 
59  // main dataflow analysis
60  auto processing_result = dataflow::processing::run(proc_config, initial_grouping);
61  auto eval_result = dataflow::evaluation::run(eval_config, eval_ctx, initial_grouping, processing_result);
62 
63  // end of analysis(?)
64  if (eval_result.is_final_result)
65  {
66  log_info("dataflow", "got final result");
67  final_grouping = eval_result.merged_result;
68  break;
69  }
70 
71  initial_grouping = eval_result.merged_result;
72 
73  iteration++;
74  }
75 
77 
78  total_time = (double)std::chrono::duration_cast<std::chrono::milliseconds>(std::chrono::high_resolution_clock::now() - begin_time).count() / 1000;
79 
80  log_info("dataflow", "dataflow processing finished in {:3.2f}s", total_time);
81 
82  return OK(dataflow::Result(config.netlist, *final_grouping));
83  }
84  } // namespace dataflow
85 } // namespace hal
Result of a dataflow analysis run.
Definition: result.h:57
This file contains the function that analyses the dataflow of a gate-level netlist.
#define log_info(channel,...)
Definition: log.h:70
#define ERR(message)
Definition: result.h:53
#define OK(...)
Definition: result.h:49
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:147
hal::Result< dataflow::Result > analyze(const Configuration &config)
Analyze the gate-level netlist to identify word-level structures such as registers.
Definition: dataflow.cpp:12
CORE_API std::string join(const std::string &joiner, const Iterator &begin, const Iterator &end, const Transform &transform)
Definition: utils.h:412
quint32 u32
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