Skip to content

Commit 7231688

Browse files
committed
cover some edge cases
1 parent 2a18489 commit 7231688

File tree

1 file changed

+36
-9
lines changed

1 file changed

+36
-9
lines changed

vpr/src/pack/sync_netlists_to_routing_flat.cpp

Lines changed: 36 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
* after routing optimization
44
*******************************************************************/
55
/* Headers from vtrutil library */
6+
#include "clustered_netlist_fwd.h"
67
#include "clustered_netlist_utils.h"
78
#include "logic_types.h"
89
#include "netlist_fwd.h"
@@ -25,6 +26,31 @@ static void sync_pb_routes_to_routing(void);
2526
static void sync_clustered_netlist_to_routing(void);
2627
static void fixup_atom_pb_graph_pin_mapping(void);
2728

29+
inline ClusterBlockId get_cluster_block_from_rr_node(RRNodeId inode){
30+
auto& device_ctx = g_vpr_ctx.device();
31+
auto& place_ctx = g_vpr_ctx.placement();
32+
auto& rr_graph = device_ctx.rr_graph;
33+
34+
auto physical_tile = device_ctx.grid.get_physical_type({
35+
rr_graph.node_xlow(inode),
36+
rr_graph.node_ylow(inode),
37+
rr_graph.node_layer(inode)
38+
});
39+
40+
int source_pin = rr_graph.node_pin_num(inode);
41+
42+
auto [_, subtile] = get_sub_tile_from_pin_physical_num(physical_tile, source_pin);
43+
44+
ClusterBlockId clb = place_ctx.grid_blocks.block_at_location({
45+
rr_graph.node_xlow(inode),
46+
rr_graph.node_ylow(inode),
47+
subtile,
48+
rr_graph.node_layer(inode)
49+
});
50+
51+
return clb;
52+
}
53+
2854
/* Output all intra-cluster connections for a RouteTreeNode */
2955
static void get_intra_cluster_connections(const RouteTree& tree, std::vector<std::pair<RRNodeId, RRNodeId>>& out_connections){
3056
auto& rr_graph = g_vpr_ctx.device().rr_graph;
@@ -34,22 +60,24 @@ static void get_intra_cluster_connections(const RouteTree& tree, std::vector<std
3460
if(!parent) /* Root */
3561
continue;
3662

63+
/* Find the case where both nodes are IPIN/OPINs and on the same block */
3764
auto type = rr_graph.node_type(node.inode);
3865
auto parent_type = rr_graph.node_type(parent->inode);
3966

40-
/* Both nodes are IPIN/OPIN: this has to be an intrablock connection */
41-
if((type == OPIN || type == IPIN) && (parent_type == OPIN || parent_type == IPIN)){
42-
out_connections.push_back({parent->inode, node.inode});
67+
if((type == IPIN || type == OPIN) && (parent_type == IPIN || parent_type == OPIN)){
68+
auto clb = get_cluster_block_from_rr_node(node.inode);
69+
auto parent_clb = get_cluster_block_from_rr_node(parent->inode);
70+
if(clb == parent_clb)
71+
out_connections.push_back({parent->inode, node.inode});
4372
}
4473
}
4574
}
4675

4776
/** Rudimentary intra-cluster router between two pb_graph pins.
4877
* Easier to use than the packer's router, but it assumes that there is only one path between the provided pins.
49-
* Expect this to fail/produce invalid results if that's not the case with your architecture.
78+
* (which should be the case due to the flat router's RR graph compression)
5079
* Outputs the path to the given pb. */
5180
static void route_intra_cluster_conn(const t_pb_graph_pin* source_pin, const t_pb_graph_pin* sink_pin, AtomNetId net_id, t_pb* out_pb){
52-
5381
std::unordered_set<const t_pb_graph_pin*> visited;
5482
std::deque<const t_pb_graph_pin*> queue;
5583
std::unordered_map<const t_pb_graph_pin*, const t_pb_graph_pin*> prev;
@@ -61,7 +89,6 @@ static void route_intra_cluster_conn(const t_pb_graph_pin* source_pin, const t_p
6189

6290
while(!queue.empty()){
6391
const t_pb_graph_pin* cur_pin = queue.front();
64-
//std::cout << "expanding: " << cur_pin->to_string() << "\n";
6592
queue.pop_front();
6693
if(visited.count(cur_pin))
6794
continue;
@@ -75,20 +102,20 @@ static void route_intra_cluster_conn(const t_pb_graph_pin* source_pin, const t_p
75102
for(auto& edge: cur_pin->output_edges){
76103
VTR_ASSERT(edge->num_output_pins == 1);
77104
queue.push_back(edge->output_pins[0]);
78-
//std::cout << "pushing back " << edge->output_pins[0]->to_string() << "\n";
79105
prev[edge->output_pins[0]] = cur_pin;
80106
}
81107
}
82-
108+
83109
VTR_ASSERT_MSG(visited.count(sink_pin), "Couldn't find sink pin");
84110

85111
/* Collect path: we need to build pb_routes from source to sink */
86112
std::vector<const t_pb_graph_pin*> path;
87113
const t_pb_graph_pin* cur_pin = sink_pin;
88-
while(cur_pin){
114+
while(cur_pin != source_pin){
89115
path.push_back(cur_pin);
90116
cur_pin = prev[cur_pin];
91117
}
118+
path.push_back(source_pin);
92119

93120
/* Output the path into out_pb_routes (start from source) */
94121
int prev_pin_id = -1;

0 commit comments

Comments
 (0)