Skip to content

Commit 330cad7

Browse files
fix errors related to CHANZ connectivity in check_route.cpp
1 parent 0f394fc commit 330cad7

File tree

7 files changed

+137
-92
lines changed

7 files changed

+137
-92
lines changed

libs/librrgraph/src/base/check_rr_graph.cpp

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -331,7 +331,7 @@ void check_rr_node(const RRGraphView& rr_graph,
331331
bool is_flat) {
332332
//Make sure over-flow doesn't happen
333333
VTR_ASSERT(inode >= 0);
334-
int nodes_per_chan, tracks_per_node;
334+
int tracks_per_node;
335335
RRNodeId rr_node = RRNodeId(inode);
336336

337337
e_rr_type rr_type = rr_graph.node_type(rr_node);
@@ -484,11 +484,9 @@ void check_rr_node(const RRGraphView& rr_graph,
484484
case e_rr_type::CHANX:
485485
case e_rr_type::CHANY:
486486
if (route_type == e_route_type::DETAILED) {
487-
nodes_per_chan = chan_width.max;
488487
tracks_per_node = 1;
489488
} else {
490-
nodes_per_chan = 1;
491-
tracks_per_node = ((rr_type == e_rr_type::CHANX) ? chan_width.x_list[ylow] : chan_width.y_list[xlow]);
489+
tracks_per_node = (rr_type == e_rr_type::CHANX) ? chan_width.x_list[ylow] : chan_width.y_list[xlow];
492490
}
493491

494492
if (capacity != tracks_per_node) {

libs/librrgraph/src/base/rr_graph_storage.cpp

Lines changed: 11 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -663,32 +663,29 @@ int t_rr_graph_storage::node_ptc_num(RRNodeId id) const {
663663
return node_ptc_[id].ptc_.pin_num;
664664
}
665665

666-
static int get_node_pin_num(
667-
vtr::array_view_id<RRNodeId, const t_rr_node_data> node_storage,
668-
vtr::array_view_id<RRNodeId, const t_rr_node_ptc_data> node_ptc,
669-
RRNodeId id) {
666+
static int get_node_pin_num(vtr::array_view_id<RRNodeId, const t_rr_node_data> node_storage,
667+
vtr::array_view_id<RRNodeId, const t_rr_node_ptc_data> node_ptc,
668+
RRNodeId id) {
670669
e_rr_type node_type = node_storage[id].type_;
671670
if (node_type != e_rr_type::IPIN && node_type != e_rr_type::OPIN) {
672671
VTR_LOG_ERROR("Attempted to access RR node 'pin_num' for non-IPIN/OPIN type '%s'", rr_node_typename[node_type]);
673672
}
674673
return node_ptc[id].ptc_.pin_num;
675674
}
676675

677-
static int get_node_track_num(
678-
vtr::array_view_id<RRNodeId, const t_rr_node_data> node_storage,
679-
vtr::array_view_id<RRNodeId, const t_rr_node_ptc_data> node_ptc,
680-
RRNodeId id) {
676+
static int get_node_track_num(vtr::array_view_id<RRNodeId, const t_rr_node_data> node_storage,
677+
vtr::array_view_id<RRNodeId, const t_rr_node_ptc_data> node_ptc,
678+
RRNodeId id) {
681679
e_rr_type node_type = node_storage[id].type_;
682-
if (node_type != e_rr_type::CHANX && node_type != e_rr_type::CHANY) {
683-
VTR_LOG_ERROR("Attempted to access RR node 'track_num' for non-CHANX/CHANY type '%s'", rr_node_typename[node_type]);
680+
if (node_type != e_rr_type::CHANX && node_type != e_rr_type::CHANY && node_type != e_rr_type::CHANZ) {
681+
VTR_LOG_ERROR("Attempted to access RR node 'track_num' for non-CHANX/CHANY/CHANZ type '%s'", rr_node_typename[node_type]);
684682
}
685683
return node_ptc[id].ptc_.track_num;
686684
}
687685

688-
static int get_node_class_num(
689-
vtr::array_view_id<RRNodeId, const t_rr_node_data> node_storage,
690-
vtr::array_view_id<RRNodeId, const t_rr_node_ptc_data> node_ptc,
691-
RRNodeId id) {
686+
static int get_node_class_num(vtr::array_view_id<RRNodeId, const t_rr_node_data> node_storage,
687+
vtr::array_view_id<RRNodeId, const t_rr_node_ptc_data> node_ptc,
688+
RRNodeId id) {
692689
e_rr_type node_type = node_storage[id].type_;
693690
if (node_type != e_rr_type::SOURCE && node_type != e_rr_type::SINK) {
694691
VTR_LOG_ERROR("Attempted to access RR node 'class_num' for non-SOURCE/SINK type '%s'", rr_node_typename[node_type]);

libs/librrgraph/src/base/rr_graph_view.h

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -236,13 +236,14 @@ class RRGraphView {
236236
}
237237

238238
/** @brief Return the length (number of grid tile units spanned by the wire, including the endpoints) of a specified node.
239-
* @note node_length() only applies to CHANX or CHANY and is always a positive number
239+
* @note node_length() only applies to CHANX or CHANY or CHANZ and is always a positive number
240240
*/
241241
inline int node_length(RRNodeId node) const {
242-
VTR_ASSERT(node_type(node) == e_rr_type::CHANX || node_type(node) == e_rr_type::CHANY);
242+
VTR_ASSERT(node_type(node) == e_rr_type::CHANX || node_type(node) == e_rr_type::CHANY || node_type(node) == e_rr_type::CHANZ);
243243
if (node_direction(node) == Direction::NONE) {
244244
return 0; //length zero wire
245245
}
246+
// TODO: handle chanz nodes
246247
int length = 1 + node_xhigh(node) - node_xlow(node) + node_yhigh(node) - node_ylow(node);
247248
VTR_ASSERT_SAFE(length > 0);
248249
return length;
@@ -257,7 +258,8 @@ class RRGraphView {
257258
}
258259

259260
/** @brief Check if two routing resource nodes are adjacent (must be a CHANX and a CHANY).
260-
* @note This function performs error checking by determining whether two nodes are physically adjacent based on their geometry. It does not verify the routing edges to confirm if a connection is feasible within the current routing graph.
261+
* @note This function performs error checking by determining whether two nodes are physically adjacent based on their geometry.
262+
* It does not verify the routing edges to confirm if a connection is feasible within the current routing graph.
261263
*/
262264
inline bool nodes_are_adjacent(RRNodeId chanx_node, RRNodeId chany_node) const {
263265
VTR_ASSERT(node_type(chanx_node) == e_rr_type::CHANX && node_type(chany_node) == e_rr_type::CHANY);
@@ -332,7 +334,7 @@ class RRGraphView {
332334
start_x = " (" + std::to_string(node_xhigh(node)) + ",";
333335
start_y = std::to_string(node_yhigh(node)) + ",";
334336
start_layer_str = std::to_string(node_layer_num) + ")";
335-
} else if (node_type(node) == e_rr_type::CHANX || node_type(node) == e_rr_type::CHANY) { //for channels, we would like to describe the component with segment specific information
337+
} else if (node_type(node) == e_rr_type::CHANX || node_type(node) == e_rr_type::CHANY || node_type(node) == e_rr_type::CHANZ) { //for channels, we would like to describe the component with segment specific information
336338
RRIndexedDataId cost_index = node_cost_index(node);
337339
int seg_index = rr_indexed_data_[cost_index].seg_index;
338340
coordinate_string += rr_segments(RRSegmentId(seg_index)).name; //Write the segment name

libs/librrgraph/src/utils/alloc_and_load_rr_indexed_data.cpp

Lines changed: 8 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -159,9 +159,6 @@ std::vector<int> find_ortho_cost_index(const RRGraphView& rr_graph,
159159
const std::vector<t_segment_inf>& segment_inf_x,
160160
const std::vector<t_segment_inf>& segment_inf_y,
161161
e_parallel_axis parallel_axis) {
162-
const std::vector<t_segment_inf>& segment_inf_parallel = parallel_axis == X_AXIS ? segment_inf_x : segment_inf_y;
163-
const std::vector<t_segment_inf>& segment_inf_perp = parallel_axis == X_AXIS ? segment_inf_y : segment_inf_x;
164-
165162
size_t num_segments = segment_inf_x.size() + segment_inf_y.size();
166163
std::vector<std::vector<size_t>> dest_nodes_count;
167164

@@ -179,8 +176,8 @@ std::vector<int> find_ortho_cost_index(const RRGraphView& rr_graph,
179176

180177
std::vector<int> ortho_cost_indices(dest_nodes_count.size(), 0);
181178

182-
//Go through all rr_Nodes. Look at the ones with CHAN type. Count all outgoing edges to CHAN typed nodes from each CHAN type node.
183-
for (const RRNodeId& rr_node : rr_graph.nodes()) {
179+
// Go through all rr_Nodes. Look at the ones with CHAN type. Count all outgoing edges to CHAN typed nodes from each CHAN type node.
180+
for (const RRNodeId rr_node : rr_graph.nodes()) {
184181
for (size_t iedge = 0; iedge < rr_graph.num_edges(rr_node); ++iedge) {
185182
RRNodeId to_node = rr_graph.edge_sink_node(rr_node, iedge);
186183
e_rr_type from_node_type = rr_graph.node_type(rr_node);
@@ -189,7 +186,7 @@ std::vector<int> find_ortho_cost_index(const RRGraphView& rr_graph,
189186
size_t from_node_cost_index = (size_t)rr_graph.node_cost_index(rr_node);
190187
size_t to_node_cost_index = (size_t)rr_graph.node_cost_index(to_node);
191188

192-
//if the type is smaller than start index, means destination is not a CHAN type node.
189+
// if the type is smaller than start index, means destination is not a CHAN type node.
193190

194191
if ((from_node_type == e_rr_type::CHANX && to_node_type == e_rr_type::CHANY) || (from_node_type == e_rr_type::CHANY && to_node_type == e_rr_type::CHANX)) {
195192
if (to_node_type == e_rr_type::CHANY) {
@@ -222,7 +219,8 @@ std::vector<int> find_ortho_cost_index(const RRGraphView& rr_graph,
222219
/*Update seg_index */
223220

224221
#ifdef FREQ_LENGTH_ORTHO_COSTS
225-
222+
const std::vector<t_segment_inf>& segment_inf_parallel = parallel_axis == X_AXIS ? segment_inf_x : segment_inf_y;
223+
const std::vector<t_segment_inf>& segment_inf_perp = parallel_axis == X_AXIS ? segment_inf_y : segment_inf_x;
226224
for (int i = 0; i < (int)segment_inf_perp.size(); ++i)
227225
segment_inf_perp[i].seg_index = i;
228226

@@ -321,6 +319,9 @@ std::vector<int> find_ortho_cost_index(const RRGraphView& rr_graph,
321319
# endif
322320

323321
return ortho_costs_indices;
322+
323+
#else
324+
(void)parallel_axis;
324325
#endif
325326
}
326327

libs/librrgraph/src/utils/describe_rr_node.cpp

Lines changed: 8 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -10,9 +10,10 @@ std::string describe_rr_node(const RRGraphView& rr_graph,
1010
RRNodeId inode,
1111
bool is_flat) {
1212

13+
const e_rr_type node_type = rr_graph.node_type(inode);
1314
std::string msg = vtr::string_fmt("RR node: %d", inode);
14-
if (rr_graph.node_type(inode) == e_rr_type::CHANX || rr_graph.node_type(inode) == e_rr_type::CHANY) {
15-
auto cost_index = rr_graph.node_cost_index(inode);
15+
if (node_type == e_rr_type::CHANX || node_type == e_rr_type::CHANY || node_type == e_rr_type::CHANZ) {
16+
RRIndexedDataId cost_index = rr_graph.node_cost_index(inode);
1617

1718
int seg_index = rr_indexed_data[cost_index].seg_index;
1819
std::string rr_node_direction_string = rr_graph.node_direction_string(inode);
@@ -26,18 +27,18 @@ std::string describe_rr_node(const RRGraphView& rr_graph,
2627
rr_graph.node_track_num(inode),
2728
seg_index);
2829
}
29-
} else if (rr_graph.node_type(inode) == e_rr_type::IPIN || rr_graph.node_type(inode) == e_rr_type::OPIN) {
30-
auto type = grid.get_physical_type({rr_graph.node_xlow(inode),
31-
rr_graph.node_ylow(inode),
32-
rr_graph.node_layer(inode)});
30+
} else if (node_type == e_rr_type::IPIN || node_type == e_rr_type::OPIN) {
31+
t_physical_tile_type_ptr type = grid.get_physical_type({rr_graph.node_xlow(inode),
32+
rr_graph.node_ylow(inode),
33+
rr_graph.node_layer(inode)});
3334

3435
std::string pin_name = block_type_pin_index_to_name(type, rr_graph.node_pin_num(inode), is_flat);
3536

3637
msg += vtr::string_fmt(" pin: %d pin_name: %s",
3738
rr_graph.node_pin_num(inode),
3839
pin_name.c_str());
3940
} else {
40-
VTR_ASSERT(rr_graph.node_type(inode) == e_rr_type::SOURCE || rr_graph.node_type(inode) == e_rr_type::SINK);
41+
VTR_ASSERT(node_type == e_rr_type::SOURCE || node_type == e_rr_type::SINK);
4142

4243
msg += vtr::string_fmt(" class: %d", rr_graph.node_class_num(inode));
4344
}

vpr/src/base/read_route.cpp

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -563,9 +563,9 @@ void print_route(const Netlist<>& net_list,
563563
auto& route_ctx = g_vpr_ctx.mutable_routing();
564564

565565
if (route_ctx.route_trees.empty())
566-
return; //Only if routing exists
566+
return; // Only if routing exists
567567

568-
for (auto net_id : net_list.nets()) {
568+
for (ParentNetId net_id : net_list.nets()) {
569569
if (!net_list.net_is_ignored(net_id)) {
570570
fprintf(fp, "\n\nNet %zu (%s)\n\n", size_t(net_id), net_list.net_name(net_id).c_str());
571571
if (net_list.net_sinks(net_id).size() == false) {
@@ -587,8 +587,8 @@ void print_route(const Netlist<>& net_list,
587587
fprintf(fp, "Node:\t%zu\t%6s (%d,%d,%d) ", size_t(inode),
588588
rr_graph.node_type_string(inode), ilow, jlow, layer_num);
589589

590-
if ((ilow != rr_graph.node_xhigh(inode))
591-
|| (jlow != rr_graph.node_yhigh(inode)))
590+
if (ilow != rr_graph.node_xhigh(inode)
591+
|| jlow != rr_graph.node_yhigh(inode))
592592
fprintf(fp, "to (%d,%d,%d) ", rr_graph.node_xhigh(inode),
593593
rr_graph.node_yhigh(inode), layer_num);
594594

@@ -600,21 +600,22 @@ void print_route(const Netlist<>& net_list,
600600

601601
if (physical_tile->is_io()) {
602602
fprintf(fp, " Pad: ");
603-
} else { /* IO Pad. */
603+
} else { // IO Pad
604604
fprintf(fp, " Pin: ");
605605
}
606606
break;
607607

608608
case e_rr_type::CHANX:
609609
case e_rr_type::CHANY:
610+
case e_rr_type::CHANZ:
610611
fprintf(fp, " Track: ");
611612
break;
612613

613614
case e_rr_type::SOURCE:
614615
case e_rr_type::SINK:
615616
if (physical_tile->is_io()) {
616617
fprintf(fp, " Pad: ");
617-
} else { /* IO Pad. */
618+
} else { // IO Pad
618619
fprintf(fp, " Class: ");
619620
}
620621
break;

0 commit comments

Comments
 (0)