|
6 | 6 | #include "rr_graph_obj.h"
|
7 | 7 | #include "rr_graph_builder.h"
|
8 | 8 |
|
| 9 | +// Add "cluster-edge" IPINs to sink_ipins |
| 10 | +static void walk_cluster_recursive(const RRGraphView& rr_graph, |
| 11 | + const vtr::vector<RRNodeId, std::vector<RREdgeId>>& fanins, |
| 12 | + std::unordered_set<RRNodeId>& sink_ipins, |
| 13 | + const RRNodeId curr, |
| 14 | + const RRNodeId origin) { |
| 15 | + // Make sure SINK in the same cluster as origin |
| 16 | + int curr_x = rr_graph.node_xlow(curr); |
| 17 | + int curr_y = rr_graph.node_ylow(curr); |
| 18 | + if ((curr_x < rr_graph.node_xlow(origin)) || (curr_x > rr_graph.node_xhigh(origin)) || (curr_y < rr_graph.node_ylow(origin)) || (curr_y > rr_graph.node_yhigh(origin))) |
| 19 | + return; |
| 20 | + |
| 21 | + VTR_ASSERT_SAFE(rr_graph.node_type(origin) == e_rr_type::SINK); |
| 22 | + |
| 23 | + // We want to go "backward" to the cluster IPINs connected to the origin node |
| 24 | + auto incoming_edges = fanins[curr]; |
| 25 | + for (RREdgeId edge : incoming_edges) { |
| 26 | + RRNodeId parent = rr_graph.edge_src_node(edge); |
| 27 | + VTR_ASSERT_SAFE(parent != RRNodeId::INVALID()); |
| 28 | + |
| 29 | + if (rr_graph.node_type(parent) == e_rr_type::CHANX || rr_graph.node_type(parent) == e_rr_type::CHANY) { /* Outside of origin cluster */ |
| 30 | + VTR_ASSERT_SAFE(rr_graph.node_type(curr) == e_rr_type::IPIN); |
| 31 | + |
| 32 | + // If the parent node isn't in the origin's cluster, the current node is a "cluster-edge" pin, |
| 33 | + // so add it to sink_ipins |
| 34 | + sink_ipins.insert(curr); |
| 35 | + return; |
| 36 | + } |
| 37 | + |
| 38 | + // If the parent node is intra-cluster, keep going "backward" |
| 39 | + walk_cluster_recursive(rr_graph, fanins, sink_ipins, parent, origin); |
| 40 | + } |
| 41 | +} |
| 42 | + |
9 | 43 | std::vector<RRSwitchId> find_rr_graph_switches(const RRGraph& rr_graph,
|
10 | 44 | const RRNodeId& from_node,
|
11 | 45 | const RRNodeId& to_node) {
|
@@ -144,22 +178,7 @@ void set_sink_locs(const RRGraphView& rr_graph, RRGraphBuilder& rr_graph_builder
|
144 | 178 |
|
145 | 179 | // The IPINs of the current SINK node
|
146 | 180 | std::unordered_set<RRNodeId> sink_ipins = {};
|
147 |
| - |
148 |
| - // IPINs are always one node away from the SINK. So, we just get the fanins of the SINK |
149 |
| - // and add them to the set |
150 |
| - for (auto edge : node_fanins[node_id]) { |
151 |
| - RRNodeId pin = rr_graph.edge_src_node(edge); |
152 |
| - |
153 |
| - VTR_ASSERT_SAFE(rr_graph.node_type(pin) == e_rr_type::IPIN); |
154 |
| - |
155 |
| - // Make sure IPIN in the same cluster as origin |
156 |
| - size_t curr_x = rr_graph.node_xlow(pin); |
157 |
| - size_t curr_y = rr_graph.node_ylow(pin); |
158 |
| - if ((curr_x < tile_xlow) || (curr_x > tile_xhigh) || (curr_y < tile_ylow) || (curr_y > tile_yhigh)) |
159 |
| - continue; |
160 |
| - |
161 |
| - sink_ipins.insert(pin); |
162 |
| - } |
| 181 | + walk_cluster_recursive(rr_graph, node_fanins, sink_ipins, node_id, node_id); |
163 | 182 |
|
164 | 183 | /* Set SINK locations as average of collected IPINs */
|
165 | 184 |
|
|
0 commit comments