@@ -58,13 +58,13 @@ void check_rr_graph(const RRGraphView& rr_graph,
5858 route_type = e_route_type::GLOBAL;
5959 }
6060
61- auto total_edges_to_node = std::vector<int >(rr_graph.num_nodes ());
62- auto switch_types_from_current_to_node = std::vector<unsigned char >(rr_graph.num_nodes ());
61+ std::vector<int > total_edges_to_node (rr_graph.num_nodes ());
62+ std::vector<unsigned char > switch_types_from_current_to_node (rr_graph.num_nodes ());
6363 const int num_rr_switches = rr_graph.num_rr_switches ();
6464
6565 std::vector<std::pair<int , int >> edges;
6666
67- for (const RRNodeId& rr_node : rr_graph.nodes ()) {
67+ for (const RRNodeId rr_node : rr_graph.nodes ()) {
6868 size_t inode = (size_t )rr_node;
6969 rr_graph.validate_node (rr_node);
7070
@@ -83,7 +83,7 @@ void check_rr_graph(const RRGraphView& rr_graph,
8383
8484 check_rr_node (rr_graph, rr_indexed_data, grid, chan_width, route_type, inode, is_flat);
8585
86- /* Check all the connectivity (edges, etc.) information. */
86+ // Check all the connectivity (edges, etc.) information.
8787 edges.resize (0 );
8888 edges.reserve (num_edges);
8989
@@ -329,16 +329,15 @@ void check_rr_node(const RRGraphView& rr_graph,
329329 const enum e_route_type route_type,
330330 const int inode,
331331 bool is_flat) {
332- /* This routine checks that the rr_node is inside the grid and has a valid
333- * pin number, etc.
334- */
335-
336332 // Make sure over-flow doesn't happen
337333 VTR_ASSERT (inode >= 0 );
338- int nodes_per_chan, tracks_per_node;
339- float C, R;
334+ int tracks_per_node;
340335 RRNodeId rr_node = RRNodeId (inode);
341336
337+ const int grid_width = grid.width ();
338+ const int grid_height = grid.height ();
339+ const int grid_layers = grid.get_num_layers ();
340+
342341 e_rr_type rr_type = rr_graph.node_type (rr_node);
343342 int xlow = rr_graph.node_xlow (rr_node);
344343 int xhigh = rr_graph.node_xhigh (rr_node);
@@ -348,19 +347,18 @@ void check_rr_node(const RRGraphView& rr_graph,
348347 int ptc_num = rr_graph.node_ptc_num (rr_node);
349348 int capacity = rr_graph.node_capacity (rr_node);
350349 RRIndexedDataId cost_index = rr_graph.node_cost_index (rr_node);
351- t_physical_tile_type_ptr type = nullptr ;
352350
353351 if (xlow > xhigh || ylow > yhigh) {
354352 VPR_ERROR (VPR_ERROR_ROUTE,
355353 " in check_rr_node: rr endpoints are (%d,%d) and (%d,%d).\n " , xlow, ylow, xhigh, yhigh);
356354 }
357355
358- if (xlow < 0 || xhigh > int (grid. width ()) - 1 || ylow < 0 || yhigh > int (grid. height ()) - 1 ) {
356+ if (xlow < 0 || xhigh > grid_width - 1 || ylow < 0 || yhigh > grid_height - 1 ) {
359357 VPR_FATAL_ERROR (VPR_ERROR_ROUTE,
360358 " in check_rr_node: rr endpoints (%d,%d) and (%d,%d) are out of range.\n " , xlow, ylow, xhigh, yhigh);
361359 }
362360
363- if (layer_num < 0 || layer_num > int (grid. get_num_layers ()) - 1 ) {
361+ if (layer_num < 0 || layer_num > grid_layers - 1 ) {
364362 VPR_FATAL_ERROR (VPR_ERROR_ROUTE,
365363 " in check_rr_node: rr endpoints layer_num (%d) is out of range.\n " , layer_num);
366364 }
@@ -375,8 +373,8 @@ void check_rr_node(const RRGraphView& rr_graph,
375373 " in check_rr_node: node %d cost index (%d) is out of range.\n " , inode, cost_index);
376374 }
377375
378- /* Check that the segment is within the array and such. */
379- type = grid.get_physical_type ({xlow, ylow, layer_num});
376+ // Check that the segment is within the array and such.
377+ t_physical_tile_type_ptr type = grid.get_physical_type ({xlow, ylow, layer_num});
380378
381379 switch (rr_type) {
382380 case e_rr_type::SOURCE:
@@ -416,7 +414,7 @@ void check_rr_node(const RRGraphView& rr_graph,
416414 break ;
417415
418416 case e_rr_type::CHANX:
419- if (xlow < 1 || xhigh > int (grid. width ()) - 2 || yhigh > int (grid. height ()) - 2 || yhigh != ylow) {
417+ if (xlow < 1 || xhigh > grid_width - 1 || yhigh > grid_height - 1 || yhigh != ylow) {
420418 VPR_FATAL_ERROR (VPR_ERROR_ROUTE,
421419 " in check_rr_node: CHANX out of range for endpoints (%d,%d) and (%d,%d)\n " , xlow, ylow, xhigh, yhigh);
422420 }
@@ -427,7 +425,7 @@ void check_rr_node(const RRGraphView& rr_graph,
427425 break ;
428426
429427 case e_rr_type::CHANY:
430- if (xhigh > int (grid. width ()) - 2 || ylow < 1 || yhigh > int (grid. height ()) - 2 || xlow != xhigh) {
428+ if (xhigh > grid_width - 1 || ylow < 1 || yhigh > grid_height - 1 || xlow != xhigh) {
431429 VPR_FATAL_ERROR (VPR_ERROR_ROUTE,
432430 " Error in check_rr_node: CHANY out of range for endpoints (%d,%d) and (%d,%d)\n " , xlow, ylow, xhigh, yhigh);
433431 }
@@ -437,12 +435,20 @@ void check_rr_node(const RRGraphView& rr_graph,
437435 }
438436 break ;
439437
438+ case e_rr_type::CHANZ:
439+ if (xhigh != xlow || yhigh != ylow || xhigh > grid_width - 1 || ylow < 1 || yhigh > grid_height - 1 ) {
440+ VPR_FATAL_ERROR (VPR_ERROR_ROUTE,
441+ " Error in check_rr_node: CHANZ out of range for endpoints (%d,%d) and (%d,%d)\n " , xlow, ylow, xhigh, yhigh);
442+ }
443+ // TODO: handle global routing case
444+ break ;
445+
440446 default :
441447 VPR_FATAL_ERROR (VPR_ERROR_ROUTE,
442448 " in check_rr_node: Unexpected segment type: %d\n " , rr_type);
443449 }
444450
445- /* Check that it's capacities and such make sense. */
451+ // Check that its capacities and such make sense.
446452
447453 int class_max_ptc = get_tile_class_max_ptc (type, is_flat);
448454 int pin_max_ptc = get_tile_pin_max_ptc (type, is_flat);
@@ -481,20 +487,9 @@ void check_rr_node(const RRGraphView& rr_graph,
481487 case e_rr_type::CHANX:
482488 case e_rr_type::CHANY:
483489 if (route_type == e_route_type::DETAILED) {
484- nodes_per_chan = chan_width.max ;
485490 tracks_per_node = 1 ;
486491 } else {
487- nodes_per_chan = 1 ;
488- tracks_per_node = ((rr_type == e_rr_type::CHANX) ? chan_width.x_list [ylow] : chan_width.y_list [xlow]);
489- }
490-
491- // if a chanx/chany has length 0, it means it is used to connect different dice together
492- // hence, the ptc number can be larger than nodes_per_chan
493- if (xlow != xhigh || ylow != yhigh) {
494- if (ptc_num >= nodes_per_chan) {
495- VPR_ERROR (VPR_ERROR_ROUTE,
496- " in check_rr_node: inode %d (type %d) has a ptc_num of %d.\n " , inode, rr_type, ptc_num);
497- }
492+ tracks_per_node = (rr_type == e_rr_type::CHANX) ? chan_width.x_list [ylow] : chan_width.y_list [xlow];
498493 }
499494
500495 if (capacity != tracks_per_node) {
@@ -503,14 +498,26 @@ void check_rr_node(const RRGraphView& rr_graph,
503498 }
504499 break ;
505500
501+ case e_rr_type::CHANZ:
502+ if (route_type == e_route_type::DETAILED) {
503+ tracks_per_node = 1 ;
504+ } else {
505+ // TODO: do checks for CHANZ type when global routing is enabled
506+ // This can be done once we have a way to specify how many chanz
507+ // nodes per switch block exist.
508+ VPR_FATAL_ERROR (VPR_ERROR_ROUTE,
509+ " in check_rr_node: Global routing is not supported in 3D architectures.\n " );
510+ }
511+ break ;
512+
506513 default :
507514 VPR_FATAL_ERROR (VPR_ERROR_ROUTE,
508515 " in check_rr_node: Unexpected segment type: %d\n " , rr_type);
509516 }
510517
511- /* Check that the capacitance and resistance are reasonable. */
512- C = rr_graph.node_C (rr_node);
513- R = rr_graph.node_R (rr_node);
518+ // Check that the capacitance and resistance are reasonable.
519+ float C = rr_graph.node_C (rr_node);
520+ float R = rr_graph.node_R (rr_node);
514521
515522 if (rr_type == e_rr_type::CHANX || rr_type == e_rr_type::CHANY) {
516523 if (C < 0 . || R < 0 .) {
0 commit comments