19 i32 new_id_counter = -1;
24 group_is_known =
false;
25 for (
const auto& gates : groups)
27 for (
const auto*
g : gates)
31 group_is_known =
true;
42 u32 new_group_id = (
u32)(++new_id_counter);
54 for (
const auto& gates : groups)
61 u32 new_group_id = (
u32)(++new_id_counter);
66 for (
const auto&
g : gates)
68 auto gid =
g->get_id();
82 const std::set<std::set<u32>>& Grouping::get_comparison_data()
const
84 if (cache.comparison_cache.empty())
88 cache.comparison_cache.emplace(it.second.begin(), it.second.end());
91 return cache.comparison_cache;
101 return get_comparison_data() == other.get_comparison_data();
106 return !(*
this == other);
111 std::map<PinType, std::unordered_set<u32>> res;
117 res.insert(it->second.begin(), it->second.end());
124 std::unordered_set<u32> Grouping::get_signals_of_group(
u32 id,
const std::unordered_map<
u32, std::unordered_set<u32>>& signals)
const
126 std::unordered_set<u32> res;
130 if (
auto it = signals.find(gate); it != signals.end())
132 res.insert(it->second.begin(), it->second.end());
141 std::vector<u32> intersect;
148 auto gate_rs = std::set<u32>(it->second.begin(), it->second.end());
149 if (intersect.empty())
151 intersect.insert(intersect.end(), gate_rs.begin(), gate_rs.end());
155 auto end_it = std::set_intersection(intersect.begin(), intersect.end(), gate_rs.begin(), gate_rs.end(), intersect.begin());
156 intersect.erase(end_it, intersect.end());
159 if (intersect.empty())
166 intersect.push_back(INT32_MAX);
170 return std::set<u32>(intersect.begin(), intersect.end());
176 std::shared_lock lock(cache.mutex);
177 if (
auto it = cache.suc_cache.find(group_id); it != cache.suc_cache.end())
182 std::unique_lock lock(cache.mutex);
185 if (
auto it = cache.suc_cache.find(group_id); it != cache.suc_cache.end())
190 std::unordered_set<u32> successors;
199 cache.suc_cache.emplace(group_id, successors);
207 std::shared_lock lock(cache.mutex);
208 if (
auto it = cache.pred_cache.find(group_id); it != cache.pred_cache.end())
213 std::unique_lock lock(cache.mutex);
216 if (
auto it = cache.pred_cache.find(group_id); it != cache.pred_cache.end())
221 std::unordered_set<u32> predecessors;
230 cache.pred_cache.emplace(group_id, predecessors);
238 std::shared_lock lock(cache.mutex);
239 if (
auto it = cache.suc_known_group_cache.find(group_id); it != cache.suc_known_group_cache.end())
244 std::unique_lock lock(cache.mutex);
247 if (
auto it = cache.suc_known_group_cache.find(group_id); it != cache.suc_known_group_cache.end())
252 std::unordered_set<u32> successors;
257 successors.insert(known_group_id);
261 cache.suc_known_group_cache.emplace(group_id, successors);
269 std::shared_lock lock(cache.mutex);
270 if (
auto it = cache.pred_known_group_cache.find(group_id); it != cache.pred_known_group_cache.end())
275 std::unique_lock lock(cache.mutex);
278 if (
auto it = cache.pred_known_group_cache.find(group_id); it != cache.pred_known_group_cache.end())
283 std::unordered_set<u32> predecessors;
288 predecessors.insert(known_group_id);
292 cache.pred_known_group_cache.emplace(group_id, predecessors);
303 if (enforce_type_consistency
305 != this->netlist_abstr.nl->get_gate_by_id(*
gates_of_group.at(group_2_id).begin())->get_type()))
314 bool merged_allowed_register_stage =
false;
319 if (register_stages_group_2.find(stage) != register_stages_group_2.end())
321 merged_allowed_register_stage =
true;
325 return merged_allowed_register_stage;
GateType * get_type() const
Gate * get_gate_by_id(const u32 gate_id) const
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.
Grouping used during dataflow analysis.
std::unordered_map< u32, std::vector< u32 > > group_control_fingerprint_map
std::unordered_map< u32, std::unordered_set< u32 > > gates_of_group
std::unordered_map< u32, u32 > parent_group_of_gate
std::unordered_set< u32 > get_known_predecessor_groups_of_group(u32 group_id) const
Get the known predecessor groups of a group.
const NetlistAbstraction & netlist_abstr
bool operator!=(const Grouping &other) const
Check two groupings for inequality.
std::unordered_set< u32 > get_predecessor_groups_of_group(u32 group_id) const
Get the predecessor groups of a group.
std::unordered_set< u32 > get_known_successor_groups_of_group(u32 group_id) const
Get the known successor groups of a group.
Grouping(const NetlistAbstraction &na)
Construct a new (empty) grouping from a netlist abstraction.
bool are_groups_allowed_to_merge(u32 group_1_id, u32 group_2_id, bool enforce_type_consistency) const
Check if two groups are allowed to be merged.
bool operator==(const Grouping &other) const
Check two groupings for equality.
std::unordered_set< u32 > get_successor_groups_of_group(u32 group_id) const
Get the successor groups of a group.
std::map< PinType, std::unordered_set< u32 > > get_control_signals_of_group(u32 group_id) const
Get the control signals of a group as a map from the control pin type to the connected net IDs.
std::set< u32 > get_register_stage_intersect_of_group(u32 group_id) const
Get the intersection of the register stages of all gates of the group.
std::map< u32, bool > operations_on_group_allowed
bool is_group_allowed_to_split(u32 group_id) const
Check if the group is allowed to be split.
The abstraction of the netlist that only contains gates of a specified type, e.g.,...
std::unordered_map< u32, std::vector< u32 > > gate_to_fingerprint
std::unordered_map< u32, std::unordered_set< u32 > > gate_to_predecessors
std::unordered_map< u32, std::map< PinType, std::unordered_set< u32 > > > gate_to_control_signals
std::unordered_map< u32, std::unordered_set< u32 > > gate_to_register_stages
std::unordered_map< u32, std::unordered_set< u32 > > gate_to_successors
std::vector< Gate * > target_gates
std::unordered_map< u32, std::unordered_set< u32 > > gate_to_known_successor_groups
std::unordered_map< u32, std::unordered_set< u32 > > gate_to_known_predecessor_groups