3
3
* after routing optimization
4
4
*******************************************************************/
5
5
/* Headers from vtrutil library */
6
+ #include " clustered_netlist_fwd.h"
6
7
#include " clustered_netlist_utils.h"
7
8
#include " logic_types.h"
8
9
#include " netlist_fwd.h"
@@ -25,6 +26,31 @@ static void sync_pb_routes_to_routing(void);
25
26
static void sync_clustered_netlist_to_routing (void );
26
27
static void fixup_atom_pb_graph_pin_mapping (void );
27
28
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
+
28
54
/* Output all intra-cluster connections for a RouteTreeNode */
29
55
static void get_intra_cluster_connections (const RouteTree& tree, std::vector<std::pair<RRNodeId, RRNodeId>>& out_connections){
30
56
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
34
60
if (!parent) /* Root */
35
61
continue ;
36
62
63
+ /* Find the case where both nodes are IPIN/OPINs and on the same block */
37
64
auto type = rr_graph.node_type (node.inode );
38
65
auto parent_type = rr_graph.node_type (parent->inode );
39
66
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 });
43
72
}
44
73
}
45
74
}
46
75
47
76
/* * Rudimentary intra-cluster router between two pb_graph pins.
48
77
* 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)
50
79
* Outputs the path to the given pb. */
51
80
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
-
53
81
std::unordered_set<const t_pb_graph_pin*> visited;
54
82
std::deque<const t_pb_graph_pin*> queue;
55
83
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
61
89
62
90
while (!queue.empty ()){
63
91
const t_pb_graph_pin* cur_pin = queue.front ();
64
- // std::cout << "expanding: " << cur_pin->to_string() << "\n";
65
92
queue.pop_front ();
66
93
if (visited.count (cur_pin))
67
94
continue ;
@@ -75,20 +102,20 @@ static void route_intra_cluster_conn(const t_pb_graph_pin* source_pin, const t_p
75
102
for (auto & edge: cur_pin->output_edges ){
76
103
VTR_ASSERT (edge->num_output_pins == 1 );
77
104
queue.push_back (edge->output_pins [0 ]);
78
- // std::cout << "pushing back " << edge->output_pins[0]->to_string() << "\n";
79
105
prev[edge->output_pins [0 ]] = cur_pin;
80
106
}
81
107
}
82
-
108
+
83
109
VTR_ASSERT_MSG (visited.count (sink_pin), " Couldn't find sink pin" );
84
110
85
111
/* Collect path: we need to build pb_routes from source to sink */
86
112
std::vector<const t_pb_graph_pin*> path;
87
113
const t_pb_graph_pin* cur_pin = sink_pin;
88
- while (cur_pin){
114
+ while (cur_pin != source_pin ){
89
115
path.push_back (cur_pin);
90
116
cur_pin = prev[cur_pin];
91
117
}
118
+ path.push_back (source_pin);
92
119
93
120
/* Output the path into out_pb_routes (start from source) */
94
121
int prev_pin_id = -1 ;
0 commit comments