@@ -16,10 +16,13 @@ namespace hal
16
16
const auto nl_trav_dec = NetlistTraversalDecorator (*netlist);
17
17
18
18
// transform gates into set to check fast if a gate is part of abstraction
19
- const auto gates_set = utils::to_unordered_set (gates);
20
- const auto & included_gates = include_all_netlist_gates ? netlist->get_gates () : gates;
19
+ const auto target_gates_set = utils::to_unordered_set (gates);
20
+ const auto & included_gates = include_all_netlist_gates ? netlist->get_gates () : gates;
21
+
22
+ auto new_abstraction = std::shared_ptr<NetlistAbstraction>(new NetlistAbstraction ());
23
+ new_abstraction->m_target_gates = gates;
24
+ // new_abstraction->m_included_gates = included_gates;
21
25
22
- auto new_abstraction = std::shared_ptr<NetlistAbstraction>(new NetlistAbstraction ());
23
26
const u32 approximated_endpoint_count = included_gates.size () * 8 ;
24
27
new_abstraction->m_successors .reserve (approximated_endpoint_count);
25
28
new_abstraction->m_predecessors .reserve (approximated_endpoint_count);
@@ -38,7 +41,7 @@ namespace hal
38
41
const auto successors = nl_trav_dec.get_next_matching_endpoints (
39
42
ep_out,
40
43
true ,
41
- [gates_set ](const auto & ep) { return ep->is_destination_pin () && gates_set .find (ep->get_gate ()) != gates_set .end (); },
44
+ [target_gates_set ](const auto & ep) { return ep->is_destination_pin () && target_gates_set .find (ep->get_gate ()) != target_gates_set .end (); },
42
45
false ,
43
46
exit_endpoint_filter,
44
47
entry_endpoint_filter);
@@ -80,8 +83,8 @@ namespace hal
80
83
{
81
84
new_abstraction->m_predecessors .insert ({ep_in, {}});
82
85
83
- const auto predecessors =
84
- nl_trav_dec. get_next_matching_endpoints ( ep_in, false , [gates_set ](const auto & ep) { return ep->is_source_pin () && gates_set .find (ep->get_gate ()) != gates_set .end (); });
86
+ const auto predecessors = nl_trav_dec. get_next_matching_endpoints (
87
+ ep_in, false , [target_gates_set ](const auto & ep) { return ep->is_source_pin () && target_gates_set .find (ep->get_gate ()) != target_gates_set .end (); });
85
88
86
89
if (predecessors.is_error ())
87
90
{
@@ -118,6 +121,11 @@ namespace hal
118
121
return OK (new_abstraction);
119
122
}
120
123
124
+ const std::vector<Gate*>& NetlistAbstraction::get_target_gates () const
125
+ {
126
+ return m_target_gates;
127
+ }
128
+
121
129
Result<std::vector<Endpoint*>> NetlistAbstraction::get_predecessors (const Gate* gate) const
122
130
{
123
131
std::vector<Endpoint*> predecessors;
@@ -277,6 +285,30 @@ namespace hal
277
285
return OK (it->second );
278
286
}
279
287
288
+ Result<std::vector<Net*>> NetlistAbstraction::get_global_input_predecessors (const Gate* gate) const
289
+ {
290
+ std::vector<Net*> global_input_predecessors;
291
+ for (auto * ep : gate->get_fan_out_endpoints ())
292
+ {
293
+ const auto new_global_input_predecessors = get_global_input_predecessors (ep);
294
+ if (new_global_input_predecessors.is_error ())
295
+ {
296
+ return ERR_APPEND (new_global_input_predecessors.get_error (),
297
+ " failed to get global input predecessors of gate " + gate->get_name () + " with ID " + std::to_string (gate->get_id ()) + " in netlist abstraction" );
298
+ }
299
+
300
+ for (auto * pred_net : new_global_input_predecessors.get ())
301
+ {
302
+ global_input_predecessors.push_back (pred_net);
303
+ }
304
+ }
305
+
306
+ std::sort (global_input_predecessors.begin (), global_input_predecessors.end ());
307
+ global_input_predecessors.erase (std::unique (global_input_predecessors.begin (), global_input_predecessors.end ()), global_input_predecessors.end ());
308
+
309
+ return OK (global_input_predecessors);
310
+ }
311
+
280
312
Result<std::vector<Net*>> NetlistAbstraction::get_global_output_successors (const Endpoint* endpoint) const
281
313
{
282
314
const auto it = m_global_output_successors.find (endpoint);
@@ -288,6 +320,30 @@ namespace hal
288
320
return OK (it->second );
289
321
}
290
322
323
+ Result<std::vector<Net*>> NetlistAbstraction::get_global_output_successors (const Gate* gate) const
324
+ {
325
+ std::vector<Net*> global_output_successors;
326
+ for (auto * ep : gate->get_fan_out_endpoints ())
327
+ {
328
+ const auto new_global_output_successors = get_global_output_successors (ep);
329
+ if (new_global_output_successors.is_error ())
330
+ {
331
+ return ERR_APPEND (new_global_output_successors.get_error (),
332
+ " failed to get global output successors of gate " + gate->get_name () + " with ID " + std::to_string (gate->get_id ()) + " in netlist abstraction" );
333
+ }
334
+
335
+ for (auto * succ_net : new_global_output_successors.get ())
336
+ {
337
+ global_output_successors.push_back (succ_net);
338
+ }
339
+ }
340
+
341
+ std::sort (global_output_successors.begin (), global_output_successors.end ());
342
+ global_output_successors.erase (std::unique (global_output_successors.begin (), global_output_successors.end ()), global_output_successors.end ());
343
+
344
+ return OK (global_output_successors);
345
+ }
346
+
291
347
NetlistAbstractionDecorator::NetlistAbstractionDecorator (const hal::NetlistAbstraction& abstraction) : m_abstraction(abstraction){};
292
348
293
349
Result<std::optional<u32 >> NetlistAbstractionDecorator::get_shortest_path_distance_internal (const std::vector<Endpoint*>& start,
0 commit comments