15 namespace remove_duplicates
21 auto new_state = std::make_shared<Grouping>(
state->netlist_abstr);
23 std::map<u32, std::unordered_set<u32>> size_group_map;
24 for (
const auto& [group_id, gates] :
state->gates_of_group)
26 size_group_map[gates.size()].insert(group_id);
30 std::unordered_set<u32> merged_gates;
31 if (delete_from_smaller)
34 for (
auto it = size_group_map.rbegin(); it != size_group_map.rend(); it++)
37 for (
const auto& group_id : it->second)
39 std::unordered_set<u32> new_group;
41 for (
auto gate_id :
state->gates_of_group.at(group_id))
43 if (merged_gates.find(gate_id) == merged_gates.end())
45 new_group.insert(gate_id);
46 merged_gates.insert(gate_id);
50 if (new_group.size() > 0)
52 u32 new_group_id = ++id_counter;
54 new_state->group_control_fingerprint_map[new_group_id] = new_state->netlist_abstr.gate_to_fingerprint.at(*new_group.begin());
55 new_state->operations_on_group_allowed[new_group_id] =
state->operations_on_group_allowed.at(group_id);
56 new_state->gates_of_group[new_group_id].insert(new_group.begin(), new_group.end());
57 for (
const auto& sg : new_group)
59 new_state->parent_group_of_gate[sg] = new_group_id;
68 for (
auto it = size_group_map.begin(); it != size_group_map.end(); it++)
77 for (
const auto& group_id : it->second)
79 std::unordered_set<u32> new_group;
81 for (
auto gate_id :
state->gates_of_group.at(group_id))
83 if (merged_gates.find(gate_id) == merged_gates.end())
85 new_group.insert(gate_id);
86 merged_gates.insert(gate_id);
90 if (new_group.size() > 0)
92 u32 new_group_id = ++id_counter;
94 new_state->group_control_fingerprint_map[new_group_id] = new_state->netlist_abstr.gate_to_fingerprint.at(*new_group.begin());
95 new_state->operations_on_group_allowed[new_group_id] =
state->operations_on_group_allowed[group_id];
97 new_state->gates_of_group[new_group_id].insert(new_group.begin(), new_group.end());
98 for (
const auto& sg : new_group)
100 new_state->parent_group_of_gate[sg] = new_group_id;
107 for (
auto gate :
state->netlist_abstr.target_gates)
109 u32 gate_id = gate->get_id();
110 if (merged_gates.find(gate_id) == merged_gates.end())
112 u32 new_group_id = ++id_counter;
114 new_state->group_control_fingerprint_map[new_group_id] = new_state->netlist_abstr.gate_to_fingerprint.at(gate_id);
115 new_state->operations_on_group_allowed[new_group_id] =
state->operations_on_group_allowed[
state->parent_group_of_gate[gate_id]];
117 new_state->gates_of_group[new_group_id].insert(gate_id);
118 new_state->parent_group_of_gate[gate_id] = new_group_id;
std::shared_ptr< Grouping > process(const processing::Configuration &config, const std::shared_ptr< Grouping > &state, bool delete_from_smaller)
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.