Skip to content

Commit 0845c14

Browse files
committed
[VPR] Added a new API add_node_to_all_locs to RRGraphBuilder
1 parent b661ceb commit 0845c14

File tree

3 files changed

+45
-30
lines changed

3 files changed

+45
-30
lines changed

vpr/src/device/rr_graph_builder.cpp

Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
#include "vtr_log.h"
12
#include "rr_graph_builder.h"
23

34
RRGraphBuilder::RRGraphBuilder(t_rr_graph_storage* node_storage,
@@ -13,3 +14,37 @@ t_rr_graph_storage& RRGraphBuilder::node_storage() {
1314
RRSpatialLookup& RRGraphBuilder::node_lookup() {
1415
return node_lookup_;
1516
}
17+
18+
void RRGraphBuilder::add_node_to_all_locs(RRNodeId node) {
19+
t_rr_type node_type = node_storage_.node_type(node);
20+
short node_ptc_num = node_storage_.node_ptc_num(node);
21+
for (int ix = node_storage_.node_xlow(node); ix <= node_storage_.node_xhigh(node); ix++) {
22+
for (int iy = node_storage_.node_ylow(node); iy <= node_storage_.node_yhigh(node); iy++) {
23+
switch (node_type) {
24+
case SOURCE:
25+
case SINK:
26+
case CHANY:
27+
node_lookup_.add_node(node, ix, iy, node_type, node_ptc_num, SIDES[0]);
28+
break;
29+
case CHANX:
30+
/* Currently need to swap x and y for CHANX because of chan, seg convention
31+
* TODO: Once the builders is reworked for use consistent (x, y) convention,
32+
* the following swapping can be removed
33+
*/
34+
node_lookup_.add_node(node, iy, ix, node_type, node_ptc_num, SIDES[0]);
35+
break;
36+
case OPIN:
37+
case IPIN:
38+
for (const e_side& side : SIDES) {
39+
if (node_storage_.is_node_on_specific_side(node, side)) {
40+
node_lookup_.add_node(node, ix, iy, node_type, node_ptc_num, side);
41+
}
42+
}
43+
break;
44+
default:
45+
VTR_LOG_ERROR("Invalid node type for node '%lu' in the routing resource graph file", size_t(node));
46+
break;
47+
}
48+
}
49+
}
50+
}

vpr/src/device/rr_graph_builder.h

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,15 @@ class RRGraphBuilder {
3737
t_rr_graph_storage& node_storage();
3838
/* Return a writable object for update the fast look-up of rr_node */
3939
RRSpatialLookup& node_lookup();
40+
/* Add an existing rr_node in the node storage to the node look-up
41+
* This function requires a valid node which has already been allocated in the node storage, with
42+
* - a valid node id
43+
* - valid geometry information: xlow/ylow/xhigh/yhigh
44+
* - a valid node type
45+
* - a valid node ptc number
46+
* - a valid side (applicable to OPIN and IPIN nodes only
47+
*/
48+
void add_node_to_all_locs(RRNodeId node);
4049

4150
/* -- Internal data storage -- */
4251
private:

vpr/src/route/rr_graph_uxsdcxx_serializer.h

Lines changed: 1 addition & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -1566,7 +1566,6 @@ class RrGraphSerializer final : public uxsd::RrGraphBase<RrGraphContextTypes> {
15661566
/*Allocates and load the rr_node look up table. SINK and SOURCE, IPIN and OPIN
15671567
*share the same look up table. CHANX and CHANY have individual look ups */
15681568
void process_rr_node_indices() {
1569-
const auto& rr_graph = (*rr_graph_);
15701569
auto& rr_graph_builder = (*rr_graph_builder_);
15711570

15721571
/* Alloc the lookup table */
@@ -1581,35 +1580,7 @@ class RrGraphSerializer final : public uxsd::RrGraphBase<RrGraphContextTypes> {
15811580
/* Add the correct node into the vector */
15821581
for (size_t inode = 0; inode < rr_nodes_->size(); inode++) {
15831582
auto node = (*rr_nodes_)[inode];
1584-
for (int ix = node.xlow(); ix <= node.xhigh(); ix++) {
1585-
for (int iy = node.ylow(); iy <= node.yhigh(); iy++) {
1586-
switch (rr_graph.node_type(node.id())) {
1587-
case SOURCE:
1588-
case SINK:
1589-
case CHANY:
1590-
rr_graph_builder.node_lookup().add_node(node.id(), ix, iy, rr_graph.node_type(node.id()), node.ptc_num(), SIDES[0]);
1591-
break;
1592-
case CHANX:
1593-
/* Currently need to swap x and y for CHANX because of chan, seg convention
1594-
* TODO: Once the builders is reworked for use consistent (x, y) convention,
1595-
* the following swapping can be removed
1596-
*/
1597-
rr_graph_builder.node_lookup().add_node(node.id(), iy, ix, rr_graph.node_type(node.id()), node.ptc_num(), SIDES[0]);
1598-
break;
1599-
case OPIN:
1600-
case IPIN:
1601-
for (const e_side& side : SIDES) {
1602-
if (node.is_node_on_specific_side(side)) {
1603-
rr_graph_builder.node_lookup().add_node(node.id(), ix, iy, rr_graph.node_type(node.id()), node.ptc_num(), side);
1604-
}
1605-
}
1606-
break;
1607-
default:
1608-
report_error("Invalid node type for node '%lu' in the routing resource graph file", size_t(node.id()));
1609-
break;
1610-
}
1611-
}
1612-
}
1583+
rr_graph_builder.add_node_to_all_locs(node.id());
16131584
}
16141585
}
16151586

0 commit comments

Comments
 (0)