39
39
#include " old_traceback.h"
40
40
41
41
/* ************Functions local to this module*************/
42
+
43
+ /* *
44
+ * @brief Read the routing file and create the routing tree for each net.
45
+ *
46
+ * @param net_list The netlist to process.
47
+ * @param fp The file stream to read from.
48
+ * @param filename The name of the file to read from.
49
+ * @param lineno The line number currently being processed.
50
+ * @param verify_rr_switch_id Whether to verify the RR switch IDs in the routing file.
51
+ * @param is_flat Whether flat-router is enabled.
52
+ */
42
53
static void process_route (const Netlist<>& net_list,
43
54
std::ifstream& fp,
44
55
const char * filename,
45
56
int & lineno,
46
57
bool verify_rr_switch_id,
47
58
bool is_flat);
48
59
60
+ /* *
61
+ * @brief Create the routing tree for the net at the given line number in the routing file.
62
+ *
63
+ * @param net_list The netlist to process.
64
+ * @param fp The file stream to read from.
65
+ * @param inet The net ID to process.
66
+ * @param filename The name of the file to read from.
67
+ * @param verify_rr_switch_id Whether to verify the RR switch IDs in the routing file.
68
+ */
49
69
static void process_nodes (const Netlist<>& net_list,
50
70
std::ifstream& fp,
51
71
ClusterNetId inet,
52
72
const char * filename,
53
73
bool verify_rr_switch_id,
54
74
int & lineno);
55
75
76
+ /* *
77
+ * @brief Process the net at the given line number in the routing file.
78
+ *
79
+ * @param net_list The netlist to process.
80
+ * @param fp The file stream to read from.
81
+ * @param inet The net ID to process.
82
+ * @param name The name of the net.
83
+ * @param input_tokens The tokens of the net.
84
+ * @param filename The name of the file to read from.
85
+ * @param lineno The line number currently being processed.
86
+ * @param verify_rr_switch_id Whether to verify the RR switch IDs in the routing file.
87
+ * @param is_flat Whether flat-router is enabled.
88
+ */
56
89
static void process_nets (const Netlist<>& net_list,
57
90
std::ifstream& fp,
58
91
ClusterNetId inet,
@@ -63,14 +96,49 @@ static void process_nets(const Netlist<>& net_list,
63
96
bool verify_rr_switch_id,
64
97
bool is_flat);
65
98
66
- static void update_rr_switch_id (t_trace* trace, std::set<int >& seen_rr_nodes);
99
+ /* *
100
+ * @brief Update the switch IDs in the routing trace to match the RR Graph.
101
+ *
102
+ * @note This function is called recursively to update the switch IDs in the routing trace.
103
+ *
104
+ * @param trace Pointer to the head of the routing trace of the net to update.
105
+ * @param seen_rr_nodes A set of seen RR nodes to avoid duplicate updates.
106
+ */
107
+ static void update_rr_switch_id (t_trace* trace,
108
+ std::set<int >& seen_rr_nodes);
109
+
110
+ /* *
111
+ * @brief This function goes through all the blocks in a global net and verify
112
+ * it with the clustered netlist and the placement
113
+ */
114
+ static void process_global_blocks (const Netlist<>& net_list,
115
+ std::ifstream& fp,
116
+ ClusterNetId inet,
117
+ const char * filename,
118
+ int & lineno,
119
+ bool is_flat);
120
+
121
+ static void format_coordinates (int & layer_num,
122
+ int & x,
123
+ int & y,
124
+ std::string coord,
125
+ ClusterNetId net,
126
+ const char * filename,
127
+ const int lineno);
128
+
129
+ static void format_pin_info (std::string& pb_name,
130
+ std::string& port_name,
131
+ int & pb_pin_num,
132
+ const std::string& input);
67
133
68
- static void process_global_blocks (const Netlist<>& net_list, std::ifstream& fp, ClusterNetId inet, const char * filename, int & lineno, bool is_flat);
69
- static void format_coordinates (int & layer_num, int & x, int & y, std::string coord, ClusterNetId net, const char * filename, const int lineno);
70
- static void format_pin_info (std::string& pb_name, std::string& port_name, int & pb_pin_num, const std::string& input);
71
134
static std::string format_name (std::string name);
72
- static bool check_rr_graph_connectivity (RRNodeId prev_node, RRNodeId node);
73
- void print_route (const Netlist<>& net_list, FILE* fp, bool is_flat);
135
+
136
+ static bool check_rr_graph_connectivity (RRNodeId prev_node,
137
+ RRNodeId node);
138
+
139
+ void print_route (const Netlist<>& net_list,
140
+ FILE* fp,
141
+ bool is_flat);
74
142
75
143
/* ************Global Functions****************************/
76
144
@@ -80,7 +148,10 @@ void print_route(const Netlist<>& net_list, FILE* fp, bool is_flat);
80
148
* Perform a series of verification tests to ensure the netlist,
81
149
* placement, and routing files match
82
150
*/
83
- bool read_route (const char * route_file, const t_router_opts& router_opts, bool verify_file_digests, bool is_flat) {
151
+ bool read_route (const char * route_file,
152
+ const t_router_opts& router_opts,
153
+ bool verify_file_digests,
154
+ bool is_flat) {
84
155
auto & device_ctx = g_vpr_ctx.mutable_device ();
85
156
auto & place_ctx = g_vpr_ctx.placement ();
86
157
bool flat_router = router_opts.flat_routing ;
@@ -167,7 +238,6 @@ bool read_route(const char* route_file, const t_router_opts& router_opts, bool v
167
238
return is_feasible;
168
239
}
169
240
170
- // /@brief Walks through every net and add the routing appropriately
171
241
static void process_route (const Netlist<>& net_list,
172
242
std::ifstream& fp,
173
243
const char * filename,
@@ -186,15 +256,30 @@ static void process_route(const Netlist<>& net_list,
186
256
continue ; // Skip commented lines
187
257
} else if (tokens[0 ] == " Net" ) {
188
258
ClusterNetId inet (atoi (tokens[1 ].c_str ()));
189
- process_nets (net_list, fp, inet, tokens[2 ], tokens, filename, lineno, verify_rr_switch_id, is_flat);
259
+ process_nets (net_list,
260
+ fp,
261
+ inet,
262
+ tokens[2 ],
263
+ tokens,
264
+ filename,
265
+ lineno,
266
+ verify_rr_switch_id,
267
+ is_flat);
190
268
}
191
269
}
192
270
193
271
tokens.clear ();
194
272
}
195
273
196
- // /@brief Check if the net is global or not, and process appropriately
197
- static void process_nets (const Netlist<>& net_list, std::ifstream& fp, ClusterNetId inet, std::string name, std::vector<std::string> input_tokens, const char * filename, int & lineno, bool verify_rr_switch_id, bool is_flat) {
274
+ static void process_nets (const Netlist<>& net_list,
275
+ std::ifstream& fp,
276
+ ClusterNetId inet,
277
+ std::string name,
278
+ std::vector<std::string> input_tokens,
279
+ const char * filename,
280
+ int & lineno,
281
+ bool verify_rr_switch_id,
282
+ bool is_flat) {
198
283
if (input_tokens.size () > 3 && input_tokens[3 ] == " global"
199
284
&& input_tokens[4 ] == " net" && input_tokens[5 ] == " connecting:" ) {
200
285
/* Global net. Never routed. */
@@ -227,12 +312,22 @@ static void process_nets(const Netlist<>& net_list, std::ifstream& fp, ClusterNe
227
312
name.c_str (), size_t (inet), net_list.net_name (inet).c_str ());
228
313
}
229
314
230
- process_nodes (net_list, fp, inet, filename, verify_rr_switch_id, lineno);
315
+ process_nodes (net_list,
316
+ fp,
317
+ inet,
318
+ filename,
319
+ verify_rr_switch_id,
320
+ lineno);
231
321
}
232
322
input_tokens.clear ();
233
323
}
234
324
235
- static void process_nodes (const Netlist<>& net_list, std::ifstream& fp, ClusterNetId inet, const char * filename, bool verify_rr_switch_id, int & lineno) {
325
+ static void process_nodes (const Netlist<>& net_list,
326
+ std::ifstream& fp,
327
+ ClusterNetId inet,
328
+ const char * filename,
329
+ bool verify_rr_switch_id,
330
+ int & lineno) {
236
331
/* Not a global net. Goes through every node and add it into trace.head*/
237
332
auto & device_ctx = g_vpr_ctx.mutable_device ();
238
333
const auto & rr_graph = device_ctx.rr_graph ;
@@ -437,58 +532,47 @@ static void process_nodes(const Netlist<>& net_list, std::ifstream& fp, ClusterN
437
532
}
438
533
439
534
static void update_rr_switch_id (t_trace* trace, std::set<int >& seen_rr_nodes) {
440
- if (! trace) {
535
+ if (trace == nullptr ) {
441
536
return ;
442
537
}
443
538
444
539
seen_rr_nodes.insert (trace->index );
445
540
446
541
t_trace* next = trace->next ;
447
542
448
- if (next) {
449
- if (trace->iswitch == OPEN) { // End of a branch
543
+ if (next == nullptr ) {
544
+ return ;
545
+ }
450
546
451
- // Verify that the next element (branch point) has been already seen in the traceback so far
452
- if (!seen_rr_nodes.count (next->index )) {
453
- VPR_FATAL_ERROR (VPR_ERROR_ROUTE, " Traceback branch point %d not found" , next->index );
454
- } else {
455
- // Recurse along the new branch
456
- update_rr_switch_id (next, seen_rr_nodes);
457
- return ;
458
- }
459
- } else { // Midway along branch
460
-
461
- // Check there is an edge connecting trace and next
462
-
463
- auto & device_ctx = g_vpr_ctx.device ();
464
- const auto & rr_graph = device_ctx.rr_graph ;
465
- bool found = false ;
466
- for (t_edge_size iedge = 0 ; iedge < rr_graph.num_edges (RRNodeId (trace->index )); ++iedge) {
467
- int to_node = size_t (rr_graph.edge_sink_node (RRNodeId (trace->index ), iedge));
468
- if (to_node == next->index ) {
469
- found = true ;
470
-
471
- // Verify that the switch matches
472
- int rr_iswitch = rr_graph.edge_switch (RRNodeId (trace->index ), iedge);
473
- trace->iswitch = rr_iswitch;
474
- break ;
475
- }
476
- }
477
- if (!found) {
478
- VPR_FATAL_ERROR (VPR_ERROR_ROUTE, " Traceback no RR edge between RR nodes %d -> %d\n " , trace->index , next->index );
547
+ if (trace->iswitch == OPEN) { // End of a branch
548
+ // Verify that the next element (branch point) has been already seen in the traceback so far
549
+ if (!seen_rr_nodes.count (next->index )) {
550
+ VPR_FATAL_ERROR (VPR_ERROR_ROUTE, " Traceback branch point %d not found" , next->index );
551
+ }
552
+ } else { // Midway along branch
553
+ // Check there is an edge connecting trace and next
554
+ auto & device_ctx = g_vpr_ctx.device ();
555
+ const auto & rr_graph = device_ctx.rr_graph ;
556
+ bool found = false ;
557
+ for (t_edge_size iedge = 0 ; iedge < rr_graph.num_edges (RRNodeId (trace->index )); ++iedge) {
558
+ int to_node = size_t (rr_graph.edge_sink_node (RRNodeId (trace->index ), iedge));
559
+ if (to_node == next->index ) {
560
+ found = true ;
561
+
562
+ // Verify that the switch matches
563
+ int rr_iswitch = rr_graph.edge_switch (RRNodeId (trace->index ), iedge);
564
+ trace->iswitch = rr_iswitch;
565
+ break ;
479
566
}
480
- // Recurse
481
- update_rr_switch_id (next, seen_rr_nodes);
482
- return ;
567
+ }
568
+ if (!found) {
569
+ VPR_FATAL_ERROR (VPR_ERROR_ROUTE, " Traceback no RR edge between RR nodes %d -> %d \n " , trace-> index , next-> index ) ;
483
570
}
484
571
}
485
- VTR_ASSERT (!next);
572
+ // Recurse
573
+ update_rr_switch_id (next, seen_rr_nodes);
486
574
}
487
575
488
- /* *
489
- * @brief This function goes through all the blocks in a global net and verify
490
- * it with the clustered netlist and the placement
491
- */
492
576
static void process_global_blocks (const Netlist<>& net_list, std::ifstream& fp, ClusterNetId inet, const char * filename, int & lineno, bool is_flat) {
493
577
std::string block, bnum_str;
494
578
int layer_num, x, y;
0 commit comments