Skip to content

Commit b4dd148

Browse files
handled CHANZ in some RR checks
1 parent 6700da8 commit b4dd148

File tree

5 files changed

+57
-40
lines changed

5 files changed

+57
-40
lines changed

libs/librrgraph/src/base/check_rr_graph.cpp

Lines changed: 15 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -329,14 +329,9 @@ 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);
338334
int nodes_per_chan, tracks_per_node;
339-
float C, R;
340335
RRNodeId rr_node = RRNodeId(inode);
341336

342337
e_rr_type rr_type = rr_graph.node_type(rr_node);
@@ -437,6 +432,14 @@ void check_rr_node(const RRGraphView& rr_graph,
437432
}
438433
break;
439434

435+
case e_rr_type::CHANZ:
436+
if (xhigh != xlow || yhigh != ylow || xhigh > int(grid.width()) - 2 || ylow < 1 || yhigh > int(grid.height()) - 2) {
437+
VPR_FATAL_ERROR(VPR_ERROR_ROUTE,
438+
"Error in check_rr_node: CHANZ out of range for endpoints (%d,%d) and (%d,%d)\n", xlow, ylow, xhigh, yhigh);
439+
}
440+
// TODO: handle global routing case
441+
break;
442+
440443
default:
441444
VPR_FATAL_ERROR(VPR_ERROR_ROUTE,
442445
"in check_rr_node: Unexpected segment type: %d\n", rr_type);
@@ -488,29 +491,24 @@ void check_rr_node(const RRGraphView& rr_graph,
488491
tracks_per_node = ((rr_type == e_rr_type::CHANX) ? chan_width.x_list[ylow] : chan_width.y_list[xlow]);
489492
}
490493

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-
}
498-
}
499-
500494
if (capacity != tracks_per_node) {
501495
VPR_FATAL_ERROR(VPR_ERROR_ROUTE,
502496
"in check_rr_node: inode %d (type %d) has a capacity of %d.\n", inode, rr_type, capacity);
503497
}
504498
break;
505499

500+
case e_rr_type::CHANZ:
501+
// TODO: do checks for CHANZ type
502+
break;
503+
506504
default:
507505
VPR_FATAL_ERROR(VPR_ERROR_ROUTE,
508506
"in check_rr_node: Unexpected segment type: %d\n", rr_type);
509507
}
510508

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);
509+
// Check that the capacitance and resistance are reasonable.
510+
float C = rr_graph.node_C(rr_node);
511+
float R = rr_graph.node_R(rr_node);
514512

515513
if (rr_type == e_rr_type::CHANX || rr_type == e_rr_type::CHANY) {
516514
if (C < 0. || R < 0.) {

libs/librrgraph/src/base/check_rr_graph.h

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,27 @@ void check_rr_graph(const RRGraphView& rr_graph,
1212
const e_graph_type graph_type,
1313
bool is_flat);
1414

15+
/**
16+
* @brief Validates the internal consistency of a single RR node in the routing resource graph.
17+
*
18+
* This function performs a series of checks on the specified RR node to ensure it conforms
19+
* to architectural and routing constraints. It verifies:
20+
* - That the node's bounding box is valid and within the device grid bounds.
21+
* - That the node's PTC number, capacity, and cost index are within legal limits.
22+
* - That IPINs, OPINs, SOURCEs, and SINKs correspond to valid physical locations and types.
23+
* - That CHANX, CHANY, and CHANZ nodes have legal coordinate bounds and track indices.
24+
* - That electrical characteristics (resistance and capacitance) are appropriate for the node type.
25+
*
26+
* Errors or inconsistencies will cause fatal errors or logged messages, depending on severity.
27+
*
28+
* @param rr_graph The read-only view of the routing resource graph.
29+
* @param rr_indexed_data Indexed data for RR node cost metrics.
30+
* @param grid The device grid.
31+
* @param chan_width The channel widths for different channels
32+
* @param route_type The routing type (GLOBAL or DETAILED).
33+
* @param inode The index of the RR node to be checked.
34+
* @param is_flat Flag indicating if flat routing is enabled.
35+
*/
1536
void check_rr_node(const RRGraphView& rr_graph,
1637
const vtr::vector<RRIndexedDataId, t_rr_indexed_data>& rr_indexed_data,
1738
const DeviceGrid& grid,

libs/librrgraph/src/base/rr_graph_storage.cpp

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -646,8 +646,8 @@ void t_rr_graph_storage::set_node_pin_num(RRNodeId id, int new_pin_num) {
646646
}
647647

648648
void t_rr_graph_storage::set_node_track_num(RRNodeId id, int new_track_num) {
649-
if (node_type(id) != e_rr_type::CHANX && node_type(id) != e_rr_type::CHANY) {
650-
VTR_LOG_ERROR("Attempted to set RR node 'track_num' for non-CHANX/CHANY type '%s'", node_type_string(id));
649+
if (node_type(id) != e_rr_type::CHANX && node_type(id) != e_rr_type::CHANY && node_type(id) != e_rr_type::CHANZ) {
650+
VTR_LOG_ERROR("Attempted to set RR node 'track_num' for non-CHANX/CHANY/CHANZ type '%s'", node_type_string(id));
651651
}
652652
node_ptc_[id].ptc_.track_num = new_track_num;
653653
}
@@ -760,7 +760,7 @@ void t_rr_graph_storage::set_node_capacity(RRNodeId id, short new_capacity) {
760760
}
761761

762762
void t_rr_graph_storage::set_node_direction(RRNodeId id, Direction new_direction) {
763-
if (node_type(id) != e_rr_type::CHANX && node_type(id) != e_rr_type::CHANY) {
763+
if (node_type(id) != e_rr_type::CHANX && node_type(id) != e_rr_type::CHANY && node_type(id) != e_rr_type::CHANZ) {
764764
VTR_LOG_ERROR("Attempted to set RR node 'direction' for non-channel type '%s'", node_type_string(id));
765765
}
766766
node_storage_[id].dir_side_.direction = new_direction;

vpr/src/route/rr_graph_generation/rr_graph.cpp

Lines changed: 17 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -888,22 +888,22 @@ static void add_intra_tile_edges_rr_graph(RRGraphBuilder& rr_graph_builder,
888888
if (is_pin_on_tile(physical_tile, pin_physical_num)) {
889889
continue;
890890
}
891-
auto pin_rr_node_id = get_pin_rr_node_id(rr_graph_builder.node_lookup(),
892-
physical_tile,
893-
layer,
894-
i,
895-
j,
896-
pin_physical_num);
891+
RRNodeId pin_rr_node_id = get_pin_rr_node_id(rr_graph_builder.node_lookup(),
892+
physical_tile,
893+
layer,
894+
i,
895+
j,
896+
pin_physical_num);
897897
VTR_ASSERT(pin_rr_node_id != RRNodeId::INVALID());
898-
auto logical_block = get_logical_block_from_pin_physical_num(physical_tile, pin_physical_num);
899-
auto driving_pins = get_physical_pin_src_pins(physical_tile, logical_block, pin_physical_num);
900-
for (auto driving_pin : driving_pins) {
901-
auto driving_pin_node_id = get_pin_rr_node_id(rr_graph_builder.node_lookup(),
902-
physical_tile,
903-
layer,
904-
i,
905-
j,
906-
driving_pin);
898+
t_logical_block_type_ptr logical_block = get_logical_block_from_pin_physical_num(physical_tile, pin_physical_num);
899+
std::vector<int> driving_pins = get_physical_pin_src_pins(physical_tile, logical_block, pin_physical_num);
900+
for (int driving_pin : driving_pins) {
901+
RRNodeId driving_pin_node_id = get_pin_rr_node_id(rr_graph_builder.node_lookup(),
902+
physical_tile,
903+
layer,
904+
i,
905+
j,
906+
driving_pin);
907907
VTR_ASSERT(driving_pin_node_id != RRNodeId::INVALID());
908908

909909
int sw_idx = get_edge_sw_arch_idx(physical_tile,
@@ -918,12 +918,10 @@ static void add_intra_tile_edges_rr_graph(RRGraphBuilder& rr_graph_builder,
918918
}
919919

920920
void print_rr_graph_stats() {
921-
auto& device_ctx = g_vpr_ctx.device();
922-
923-
const auto& rr_graph = device_ctx.rr_graph;
921+
const auto& rr_graph = g_vpr_ctx.device().rr_graph;
924922

925923
size_t num_rr_edges = 0;
926-
for (auto& rr_node : rr_graph.rr_nodes()) {
924+
for (const t_rr_node& rr_node : rr_graph.rr_nodes()) {
927925
num_rr_edges += rr_graph.edges(rr_node.id()).size();
928926
}
929927

vpr/src/route/rr_graph_generation/rr_node_indices.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -532,7 +532,7 @@ bool verify_rr_node_indices(const DeviceGrid& grid,
532532
y,
533533
describe_rr_node(rr_graph, grid, rr_indexed_data, inode, is_flat).c_str());
534534
}
535-
535+
536536
} else if (rr_graph.node_type(inode) == e_rr_type::SOURCE || rr_graph.node_type(inode) == e_rr_type::SINK) {
537537
// Sources have co-ordinates covering the entire block they are in, but not sinks
538538
if (!rr_graph.x_in_node_range(x, inode)) {

0 commit comments

Comments
 (0)