HAL
split_by_successors_predecessors.cpp
Go to the documentation of this file.
2 
6 
7 #include <map>
8 #include <set>
9 
10 namespace hal
11 {
12  namespace dataflow
13  {
14  namespace split_by_successors_predecessors
15  {
16  std::shared_ptr<Grouping> process(const processing::Configuration& config, const std::shared_ptr<Grouping>& state, bool successors)
17  {
18  auto new_state = std::make_shared<Grouping>(state->netlist_abstr);
19 
20  u32 id_counter = -1;
21  for (const auto& [group_id, gates] : state->gates_of_group)
22  {
23  if (!state->is_group_allowed_to_split(group_id))
24  {
25  u32 new_group_id = ++id_counter;
26 
27  new_state->group_control_fingerprint_map[new_group_id] = state->netlist_abstr.gate_to_fingerprint.at(*gates.begin());
28  new_state->operations_on_group_allowed[new_group_id] = state->operations_on_group_allowed.at(group_id);
29 
30  new_state->gates_of_group[new_group_id].insert(gates.begin(), gates.end());
31  for (const auto& sg : gates)
32  {
33  new_state->parent_group_of_gate[sg] = new_group_id;
34  }
35  }
36  else
37  {
38  std::map<std::set<u32>, std::unordered_set<u32>> characteristics_map;
39  for (auto gate : gates)
40  {
41  std::set<u32> characteristics_of_gate;
42  if (successors)
43  {
44  for (auto gate_successors : state->netlist_abstr.gate_to_successors.at(gate))
45  {
46  characteristics_of_gate.insert(state->parent_group_of_gate.at(gate_successors));
47  }
48  }
49  else
50  {
51  for (auto gate_predecessors : state->netlist_abstr.gate_to_predecessors.at(gate))
52  {
53  characteristics_of_gate.insert(state->parent_group_of_gate.at(gate_predecessors));
54  }
55  }
56  characteristics_map[characteristics_of_gate].insert(gate);
57  }
58 
59  /* merge gates */
60  for (auto gates_to_merge : characteristics_map)
61  {
62  u32 new_group_id = ++id_counter;
63 
64  new_state->group_control_fingerprint_map[new_group_id] = new_state->netlist_abstr.gate_to_fingerprint.at(*gates_to_merge.second.begin());
65  new_state->operations_on_group_allowed[new_group_id] = state->operations_on_group_allowed.at(group_id);
66 
67  new_state->gates_of_group[new_group_id].insert(gates_to_merge.second.begin(), gates_to_merge.second.end());
68  for (const auto& sg : gates_to_merge.second)
69  {
70  new_state->parent_group_of_gate[sg] = new_group_id;
71  }
72  }
73  }
74  }
75 
76  return new_state;
77  }
78 
79  } // namespace split_by_successors_predecessors
80  } // namespace dataflow
81 } // namespace hal
std::shared_ptr< Grouping > process(const processing::Configuration &config, const std::shared_ptr< Grouping > &state, bool successors)
quint32 u32
This file contains the struct that holds all information on the netlist abstraction used for dataflow...
This file contains the class that holds all information of a dataflow analysis grouping.