@@ -893,6 +893,7 @@ void RRGSB::sort_ipin_node_in_edges(const RRGraphView& rr_graph,
893
893
const e_side& ipin_side,
894
894
const size_t & ipin_id) {
895
895
std::map<size_t , RREdgeId> from_track_edge_map;
896
+ std::array<std::map<size_t , RREdgeId>, NUM_SIDES> from_opin_edge_map;
896
897
897
898
e_side chan_side = get_cb_chan_side (ipin_side);
898
899
@@ -905,14 +906,21 @@ void RRGSB::sort_ipin_node_in_edges(const RRGraphView& rr_graph,
905
906
* and cache these. Then we will use the data to sort the edge in the
906
907
* following sequence:
907
908
* 0----------------------------------------------------------------> num_in_edges()
909
+ * |<---------------------------1st part routing tracks ------------->
910
+ * |<--TOP side-->|<--RIGHT side-->|<--BOTTOM side-->|<--LEFT side-->|
911
+ * |<---------------------------2nd part IPINs ------------->
908
912
* |<--TOP side-->|<--RIGHT side-->|<--BOTTOM side-->|<--LEFT side-->|
909
913
* 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
912
916
*/
913
917
for (const RREdgeId& edge : rr_graph.node_in_edges (ipin_node)) {
914
918
/* We care the source node of this edge, and it should be an input of the GSB!!! */
915
919
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
+ }
916
924
/* The driver routing channel node can be either an input or an output to the GSB.
917
925
* Just try to find a qualified one. */
918
926
int index = OPEN;
@@ -949,13 +957,57 @@ void RRGSB::sort_ipin_node_in_edges(const RRGraphView& rr_graph,
949
957
edge_counter++;
950
958
}
951
959
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
+
952
996
/* Store the sorted edge */
953
997
for (size_t itrack = 0 ; itrack < chan_node_[size_t (chan_side)].get_chan_width (); ++itrack) {
954
998
if (0 < from_track_edge_map.count (itrack)) {
955
999
ipin_node_in_edges_[size_t (ipin_side)][ipin_id].push_back (from_track_edge_map[itrack]);
956
1000
}
957
1001
}
958
1002
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
+
959
1011
VTR_ASSERT (edge_counter == ipin_node_in_edges_[size_t (ipin_side)][ipin_id].size ());
960
1012
}
961
1013
0 commit comments