Skip to content

Commit c27caa3

Browse files
committed
[core] fixed a bug on rr gsb when sorting edges from OPINs
1 parent 48c0303 commit c27caa3

File tree

1 file changed

+54
-2
lines changed

1 file changed

+54
-2
lines changed

vpr/src/tileable_rr_graph/rr_gsb.cpp

Lines changed: 54 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -893,6 +893,7 @@ void RRGSB::sort_ipin_node_in_edges(const RRGraphView& rr_graph,
893893
const e_side& ipin_side,
894894
const size_t& ipin_id) {
895895
std::map<size_t, RREdgeId> from_track_edge_map;
896+
std::array<std::map<size_t, RREdgeId>, NUM_SIDES> from_opin_edge_map;
896897

897898
e_side chan_side = get_cb_chan_side(ipin_side);
898899

@@ -905,14 +906,21 @@ void RRGSB::sort_ipin_node_in_edges(const RRGraphView& rr_graph,
905906
* and cache these. Then we will use the data to sort the edge in the
906907
* following sequence:
907908
* 0----------------------------------------------------------------> num_in_edges()
909+
* |<---------------------------1st part routing tracks ------------->
910+
* |<--TOP side-->|<--RIGHT side-->|<--BOTTOM side-->|<--LEFT side-->|
911+
* |<---------------------------2nd part IPINs ------------->
908912
* |<--TOP side-->|<--RIGHT side-->|<--BOTTOM side-->|<--LEFT side-->|
909913
* For each side, the edge will be sorted by the node index starting from 0
910-
* For each side, the edge from grid pins will be the 1st part
911-
* while the edge from routing tracks will be the 2nd part
914+
* For each side, the edge from grid pins will be the 2nd part (sorted by ptc number)
915+
* while the edge from routing tracks will be the 1st part
912916
*/
913917
for (const RREdgeId& edge : rr_graph.node_in_edges(ipin_node)) {
914918
/* We care the source node of this edge, and it should be an input of the GSB!!! */
915919
const RRNodeId& src_node = rr_graph.edge_src_node(edge);
920+
/* In this part, we only sort routing track nodes. IPIN nodes will be handled later */
921+
if (CHANX != rr_graph.node_type(src_node) && CHANY != rr_graph.node_type(src_node)) {
922+
continue;
923+
}
916924
/* The driver routing channel node can be either an input or an output to the GSB.
917925
* Just try to find a qualified one. */
918926
int index = OPEN;
@@ -949,13 +957,57 @@ void RRGSB::sort_ipin_node_in_edges(const RRGraphView& rr_graph,
949957
edge_counter++;
950958
}
951959

960+
for (const RREdgeId& edge : rr_graph.node_in_edges(ipin_node)) {
961+
/* We care the source node of this edge, and it should be an input of the GSB!!! */
962+
const RRNodeId& src_node = rr_graph.edge_src_node(edge);
963+
/* In this part, we only sort routing track nodes. IPIN nodes will be handled later */
964+
if (OPIN != rr_graph.node_type(src_node)) {
965+
continue;
966+
}
967+
enum e_side cb_opin_side = NUM_SIDES;
968+
int cb_opin_index = -1;
969+
get_node_side_and_index(rr_graph, src_node, IN_PORT, cb_opin_side,
970+
cb_opin_index);
971+
VTR_ASSERT((-1 != cb_opin_index) && (NUM_SIDES != cb_opin_side));
972+
/* Must have valid side and index */
973+
if (OPEN == cb_opin_index || NUM_SIDES == cb_opin_side) {
974+
VTR_LOG("GSB[%lu][%lu]:\n", get_x(), get_y());
975+
VTR_LOG("----------------------------------\n");
976+
VTR_LOG("SRC node:\n");
977+
VTR_LOG("Node info: %s\n", rr_graph.node_coordinate_to_string(src_node).c_str());
978+
VTR_LOG("Node ptc: %d\n", rr_graph.node_ptc_num(src_node));
979+
VTR_LOG("Fan-out nodes:\n");
980+
for (const auto& temp_edge : rr_graph.edge_range(src_node)) {
981+
VTR_LOG("\t%s\n", rr_graph.node_coordinate_to_string(rr_graph.edge_sink_node(temp_edge)).c_str());
982+
}
983+
VTR_LOG("\n----------------------------------\n");
984+
VTR_LOG("IPIN node:\n");
985+
VTR_LOG("Node info: %s\n", rr_graph.node_coordinate_to_string(ipin_node).c_str());
986+
VTR_LOG("Node ptc: %d\n", rr_graph.node_ptc_num(ipin_node));
987+
VTR_LOG("Fan-in nodes:\n");
988+
for (const auto& temp_edge : rr_graph.node_in_edges(ipin_node)) {
989+
VTR_LOG("\t%s\n", rr_graph.node_coordinate_to_string(rr_graph.edge_src_node(temp_edge)).c_str());
990+
}
991+
}
992+
from_opin_edge_map[size_t(cb_opin_side)][cb_opin_index] = edge;
993+
edge_counter++;
994+
}
995+
952996
/* Store the sorted edge */
953997
for (size_t itrack = 0; itrack < chan_node_[size_t(chan_side)].get_chan_width(); ++itrack) {
954998
if (0 < from_track_edge_map.count(itrack)) {
955999
ipin_node_in_edges_[size_t(ipin_side)][ipin_id].push_back(from_track_edge_map[itrack]);
9561000
}
9571001
}
9581002

1003+
for (e_side iside : {TOP, RIGHT, BOTTOM, LEFT}) {
1004+
for (size_t ipin = 0; ipin < get_num_opin_nodes(iside); ++ipin) {
1005+
if (0 < from_opin_edge_map[size_t(iside)].count(ipin)) {
1006+
ipin_node_in_edges_[size_t(ipin_side)][ipin_id].push_back(from_opin_edge_map[size_t(iside)][ipin]);
1007+
}
1008+
}
1009+
}
1010+
9591011
VTR_ASSERT(edge_counter == ipin_node_in_edges_[size_t(ipin_side)][ipin_id].size());
9601012
}
9611013

0 commit comments

Comments
 (0)