Skip to content

Commit 6b86790

Browse files
committed
remove old get_next_gates
1 parent 137c38a commit 6b86790

File tree

3 files changed

+24
-263
lines changed

3 files changed

+24
-263
lines changed

include/hal_core/netlist/decorators/netlist_traversal_decorator.h

Lines changed: 10 additions & 46 deletions
Original file line numberDiff line numberDiff line change
@@ -46,42 +46,6 @@ namespace hal
4646
*/
4747
NetlistTraversalDecorator(const Netlist& netlist);
4848

49-
/**
50-
* TODO deprecate
51-
* Starting from the given net, get the successor/predecessor gates for which the filter evaluates to `true`.
52-
* Does not continue traversal beyond gates fulfilling the filter condition, i.e., only the first layer of successors/predecessors is returned.
53-
*
54-
* @param[in] cache - Gate cache to speed up traversal for parts of the netlist that have been traversed before.
55-
* @param[in] net - Start net.
56-
* @param[in] successors - Set `true` to get successors, set `false` to get predecessors.
57-
* @param[in] filter - Filter condition that must be met for the target gates.
58-
* @param[in] forbidden_pins - Types of pins through which propagation shall not continue. Defaults to en empty set.
59-
* @returns The next gates fulfilling the filter condition.
60-
*/
61-
Result<std::unordered_set<Gate*>> get_next_gates(std::unordered_map<const Net*, std::unordered_set<Gate*>>& cache,
62-
const Net* net,
63-
bool successors,
64-
const std::function<bool(const Gate*)>& filter,
65-
const std::set<PinType>& forbidden_pins = {}) const;
66-
67-
/**
68-
* TODO deprecate
69-
* Starting from the given gate, get the successor/predecessor gates for which the filter evaluates to `true`.
70-
* Does not continue traversal beyond gates fulfilling the filter condition, i.e., only the first layer of successors/predecessors is returned.
71-
*
72-
* @param[in] cache - Gate cache to speed up traversal for parts of the netlist that have been traversed before.
73-
* @param[in] gate - Start gate.
74-
* @param[in] successors - Set `true` to get successors, set `false` to get predecessors.
75-
* @param[in] filter - Filter condition that must be met for the target gates.
76-
* @param[in] forbidden_pins - Types of pins through which propagation shall not continue. Defaults to en empty set.
77-
* @returns The next gates fulfilling the filter condition.
78-
*/
79-
Result<std::unordered_set<Gate*>> get_next_gates(std::unordered_map<const Net*, std::unordered_set<Gate*>>& cache,
80-
const Gate* gate,
81-
bool successors,
82-
const std::function<bool(const Gate*)>& filter,
83-
const std::set<PinType>& forbidden_pins = {}) const;
84-
8549
/**
8650
* Starting from the given net, traverse the netlist and return only the successor/predecessor gates for which the `target_gate_filter` evaluates to `true`.
8751
* Stop traversal if (1) the `target_gate_filter` evaluates to `true`, (2) the `exit_endpoint_filter` evaluates to `false` on a fan-in/out endpoint (i.e., when exiting the current gate during traversal), or (3) the `entry_endpoint_filter` evaluates to `false` on a successor/predecessor endpoint (i.e., when entering the next gate during traversal).
@@ -94,11 +58,11 @@ namespace hal
9458
* @param[in] entry_endpoint_filter - Filter condition that determines whether to stop traversal on a successor/predecessor endpoint.
9559
* @returns The next gates fulfilling the target gate filter condition.
9660
*/
97-
Result<std::set<Gate*>> get_next_gates_fancy(const Net* net,
98-
bool successors,
99-
const std::function<bool(const Gate*)>& target_gate_filter,
100-
const std::function<bool(const Endpoint*, const u32 current_depth)>& exit_endpoint_filter = nullptr,
101-
const std::function<bool(const Endpoint*, const u32 current_depth)>& entry_endpoint_filter = nullptr) const;
61+
Result<std::set<Gate*>> get_next_gates(const Net* net,
62+
bool successors,
63+
const std::function<bool(const Gate*)>& target_gate_filter,
64+
const std::function<bool(const Endpoint*, const u32 current_depth)>& exit_endpoint_filter = nullptr,
65+
const std::function<bool(const Endpoint*, const u32 current_depth)>& entry_endpoint_filter = nullptr) const;
10266

10367
/**
10468
* Starting from the given gate, traverse the netlist and return only the successor/predecessor gates for which the `target_gate_filter` evaluates to `true`.
@@ -112,11 +76,11 @@ namespace hal
11276
* @param[in] entry_endpoint_filter - Filter condition that determines whether to stop traversal on a successor/predecessor endpoint.
11377
* @returns The next gates fulfilling the target gate filter condition.
11478
*/
115-
Result<std::set<Gate*>> get_next_gates_fancy(const Gate* gate,
116-
bool successors,
117-
const std::function<bool(const Gate*)>& target_gate_filter,
118-
const std::function<bool(const Endpoint*, const u32 current_depth)>& exit_endpoint_filter = nullptr,
119-
const std::function<bool(const Endpoint*, const u32 current_depth)>& entry_endpoint_filter = nullptr) const;
79+
Result<std::set<Gate*>> get_next_gates(const Gate* gate,
80+
bool successors,
81+
const std::function<bool(const Gate*)>& target_gate_filter,
82+
const std::function<bool(const Endpoint*, const u32 current_depth)>& exit_endpoint_filter = nullptr,
83+
const std::function<bool(const Endpoint*, const u32 current_depth)>& entry_endpoint_filter = nullptr) const;
12084

12185
/**
12286
* Starting from the given net, traverse the netlist and return only the successor/predecessor gates for which the `target_gate_filter` evaluates to `true`.

src/netlist/decorators/netlist_traversal_decorator.cpp

Lines changed: 11 additions & 140 deletions
Original file line numberDiff line numberDiff line change
@@ -9,140 +9,11 @@ namespace hal
99
{
1010
}
1111

12-
Result<std::unordered_set<Gate*>> NetlistTraversalDecorator::get_next_gates(std::unordered_map<const Net*, std::unordered_set<Gate*>>& cache,
13-
const Net* net,
14-
bool successors,
15-
const std::function<bool(const Gate*)>& filter,
16-
const std::set<PinType>& forbidden_pins) const
17-
{
18-
if (net == nullptr)
19-
{
20-
return ERR("nullptr given as net");
21-
}
22-
23-
if (!m_netlist.is_net_in_netlist(net))
24-
{
25-
return ERR("net does not belong to netlist");
26-
}
27-
28-
std::unordered_set<const Net*> visited;
29-
std::vector<const Net*> stack = {net};
30-
std::vector<const Net*> previous;
31-
while (!stack.empty())
32-
{
33-
const Net* current = stack.back();
34-
35-
if (!previous.empty() && current == previous.back())
36-
{
37-
stack.pop_back();
38-
previous.pop_back();
39-
continue;
40-
}
41-
42-
visited.insert(current);
43-
44-
if (const auto it = cache.find(current); it != cache.end())
45-
{
46-
for (const auto* n : previous)
47-
{
48-
const std::unordered_set<Gate*>& cached_gates = std::get<1>(*it);
49-
cache[n].insert(cached_gates.begin(), cached_gates.end());
50-
}
51-
stack.pop_back();
52-
}
53-
else
54-
{
55-
bool added = false;
56-
for (const auto* ep : successors ? current->get_destinations() : current->get_sources())
57-
{
58-
if (!forbidden_pins.empty())
59-
{
60-
if (forbidden_pins.find(ep->get_pin()->get_type()) != forbidden_pins.end())
61-
{
62-
continue;
63-
}
64-
}
65-
66-
auto* g = ep->get_gate();
67-
68-
if (filter(g))
69-
{
70-
cache[current].insert(g);
71-
for (const auto* n : previous)
72-
{
73-
cache[n].insert(g);
74-
}
75-
}
76-
else
77-
{
78-
for (const auto* n : successors ? g->get_fan_out_nets() : g->get_fan_in_nets())
79-
{
80-
if (visited.find(n) == visited.end())
81-
{
82-
stack.push_back(n);
83-
added = true;
84-
}
85-
}
86-
}
87-
}
88-
89-
if (added)
90-
{
91-
previous.push_back(current);
92-
}
93-
else
94-
{
95-
stack.pop_back();
96-
}
97-
}
98-
}
99-
100-
return OK(cache[net]);
101-
}
102-
103-
Result<std::unordered_set<Gate*>> NetlistTraversalDecorator::get_next_gates(std::unordered_map<const Net*, std::unordered_set<Gate*>>& cache,
104-
const Gate* gate,
105-
bool successors,
106-
const std::function<bool(const Gate*)>& filter,
107-
const std::set<PinType>& forbidden_pins) const
108-
{
109-
if (gate == nullptr)
110-
{
111-
return ERR("nullptr given as gate");
112-
}
113-
114-
if (!m_netlist.is_gate_in_netlist(gate))
115-
{
116-
return ERR("net does not belong to netlist");
117-
}
118-
119-
std::unordered_set<Gate*> res;
120-
for (const auto* ep : successors ? gate->get_fan_out_endpoints() : gate->get_fan_in_endpoints())
121-
{
122-
if (!forbidden_pins.empty())
123-
{
124-
if (forbidden_pins.find(ep->get_pin()->get_type()) != forbidden_pins.end())
125-
{
126-
continue;
127-
}
128-
}
129-
130-
const auto next_res = this->get_next_gates(cache, ep->get_net(), successors, filter, forbidden_pins);
131-
if (next_res.is_error())
132-
{
133-
return ERR(next_res.get_error());
134-
}
135-
auto next = next_res.get();
136-
res.insert(next.begin(), next.end());
137-
}
138-
return OK(res);
139-
}
140-
141-
Result<std::set<Gate*>> NetlistTraversalDecorator::get_next_gates_fancy(const Net* net,
142-
bool successors,
143-
const std::function<bool(const Gate*)>& target_gate_filter,
144-
const std::function<bool(const Endpoint*, u32 current_depth)>& exit_endpoint_filter,
145-
const std::function<bool(const Endpoint*, u32 current_depth)>& entry_endpoint_filter) const
12+
Result<std::set<Gate*>> NetlistTraversalDecorator::get_next_gates(const Net* net,
13+
bool successors,
14+
const std::function<bool(const Gate*)>& target_gate_filter,
15+
const std::function<bool(const Endpoint*, u32 current_depth)>& exit_endpoint_filter,
16+
const std::function<bool(const Endpoint*, u32 current_depth)>& entry_endpoint_filter) const
14617
{
14718
if (net == nullptr)
14819
{
@@ -217,11 +88,11 @@ namespace hal
21788
return OK(res);
21889
}
21990

220-
Result<std::set<Gate*>> NetlistTraversalDecorator::get_next_gates_fancy(const Gate* gate,
221-
bool successors,
222-
const std::function<bool(const Gate*)>& target_gate_filter,
223-
const std::function<bool(const Endpoint*, u32 current_depth)>& exit_endpoint_filter,
224-
const std::function<bool(const Endpoint*, u32 current_depth)>& entry_endpoint_filter) const
91+
Result<std::set<Gate*>> NetlistTraversalDecorator::get_next_gates(const Gate* gate,
92+
bool successors,
93+
const std::function<bool(const Gate*)>& target_gate_filter,
94+
const std::function<bool(const Endpoint*, u32 current_depth)>& exit_endpoint_filter,
95+
const std::function<bool(const Endpoint*, u32 current_depth)>& entry_endpoint_filter) const
22596
{
22697
if (gate == nullptr)
22798
{
@@ -241,7 +112,7 @@ namespace hal
241112
continue;
242113
}
243114

244-
const auto next_res = this->get_next_gates_fancy(exit_ep->get_net(), successors, target_gate_filter, exit_endpoint_filter, entry_endpoint_filter);
115+
const auto next_res = this->get_next_gates(exit_ep->get_net(), successors, target_gate_filter, exit_endpoint_filter, entry_endpoint_filter);
245116
if (next_res.is_error())
246117
{
247118
return ERR(next_res.get_error());

0 commit comments

Comments
 (0)