@@ -32,11 +32,10 @@ static void load_chan_rr_indices(const int max_chan_width,
32
32
const int num_chans,
33
33
const t_rr_type type,
34
34
const t_chan_details& chan_details,
35
- t_rr_node_indices& indices ,
35
+ RRGraphBuilder& rr_graph_builder ,
36
36
int * index);
37
37
38
38
static void load_block_rr_indices (RRGraphBuilder& rr_graph_builder,
39
- t_rr_node_indices& indices,
40
39
const DeviceGrid& grid,
41
40
int * index);
42
41
@@ -928,44 +927,40 @@ static void load_chan_rr_indices(const int max_chan_width,
928
927
const int num_chans,
929
928
const t_rr_type type,
930
929
const t_chan_details& chan_details,
931
- t_rr_node_indices& indices ,
930
+ RRGraphBuilder& rr_graph_builder ,
932
931
int * index) {
933
- VTR_ASSERT (indices[type].dim_size (0 ) == size_t (num_chans));
934
- VTR_ASSERT (indices[type].dim_size (1 ) == size_t (chan_len));
935
- VTR_ASSERT (indices[type].dim_size (2 ) == NUM_SIDES);
936
- for (int chan = 0 ; chan < num_chans - 1 ; ++chan) {
937
- for (int seg = 1 ; seg < chan_len - 1 ; ++seg) {
938
- /* Alloc the track inode lookup list */
939
- // Since channels have no side, we just use the first side
940
- indices[type][chan][seg][0 ].resize (max_chan_width, OPEN);
941
- }
942
- }
943
-
944
932
for (int chan = 0 ; chan < num_chans - 1 ; ++chan) {
945
933
for (int seg = 1 ; seg < chan_len - 1 ; ++seg) {
946
934
/* Assign an inode to the starts of tracks */
947
935
int x = (type == CHANX ? seg : chan);
948
936
int y = (type == CHANX ? chan : seg);
949
937
const t_chan_seg_details* seg_details = chan_details[x][y].data ();
950
938
951
- for (unsigned track = 0 ; track < indices[type][chan][seg][ 0 ]. size () ; ++track) {
939
+ for (int track = 0 ; track < max_chan_width ; ++track) {
952
940
if (seg_details[track].length () <= 0 )
953
941
continue ;
954
942
955
943
int start = get_seg_start (seg_details, track, chan, seg);
956
944
945
+ /* TODO: Now we still use the (y, x) convention here for CHANX. Should rework later */
946
+ int node_x = chan;
947
+ int node_y = start;
948
+ if (CHANX == type) {
949
+ std::swap (node_x, node_y);
950
+ }
951
+
957
952
/* If the start of the wire doesn't have a inode,
958
953
* assign one to it. */
959
- int inode = indices[ type][chan][start][ 0 ][track] ;
960
- if (OPEN == inode) {
961
- inode = *index;
954
+ RRNodeId inode = rr_graph_builder. node_lookup (). find_node (node_x, node_y, type, track, SIDES[ 0 ]) ;
955
+ if (! inode) {
956
+ inode = RRNodeId ( *index) ;
962
957
++(*index);
963
958
964
- indices[type][ chan][ start] [0 ][track] = inode ;
959
+ rr_graph_builder. node_lookup (). add_node (inode, chan, start, type, track, SIDES [0 ]) ;
965
960
}
966
961
967
962
/* Assign inode of start of wire to current position */
968
- indices[type][ chan][ seg] [0 ][track] = inode ;
963
+ rr_graph_builder. node_lookup (). add_node (inode, chan, seg, type, track, SIDES [0 ]) ;
969
964
}
970
965
}
971
966
}
@@ -975,7 +970,6 @@ static void load_chan_rr_indices(const int max_chan_width,
975
970
* TODO: these building functions should only talk to a RRGraphBuilder object
976
971
*/
977
972
static void load_block_rr_indices (RRGraphBuilder& rr_graph_builder,
978
- t_rr_node_indices& indices,
979
973
const DeviceGrid& grid,
980
974
int * index) {
981
975
// Walk through the grid assigning indices to SOURCE/SINK IPIN/OPIN
@@ -991,16 +985,12 @@ static void load_block_rr_indices(RRGraphBuilder& rr_graph_builder,
991
985
auto class_type = type->class_inf [iclass].type ;
992
986
if (class_type == DRIVER) {
993
987
rr_graph_builder.node_lookup ().add_node (RRNodeId (*index), x, y, SOURCE, iclass, SIDES[0 ]);
994
- rr_graph_builder.node_lookup ().add_node (RRNodeId::INVALID (), x, y, SINK, iclass, SIDES[0 ]);
995
988
} else {
996
989
VTR_ASSERT (class_type == RECEIVER);
997
990
rr_graph_builder.node_lookup ().add_node (RRNodeId (*index), x, y, SINK, iclass, SIDES[0 ]);
998
- rr_graph_builder.node_lookup ().add_node (RRNodeId::INVALID (), x, y, SOURCE, iclass, SIDES[0 ]);
999
991
}
1000
992
++(*index);
1001
993
}
1002
- VTR_ASSERT (indices[SOURCE][x][y][0 ].size () == type->class_inf .size ());
1003
- VTR_ASSERT (indices[SINK][x][y][0 ].size () == type->class_inf .size ());
1004
994
1005
995
/* Limited sides for grids
1006
996
* The wanted side depends on the location of the grid.
@@ -1068,18 +1058,13 @@ static void load_block_rr_indices(RRGraphBuilder& rr_graph_builder,
1068
1058
auto class_type = type->class_inf [iclass].type ;
1069
1059
1070
1060
if (class_type == DRIVER) {
1071
- indices[OPIN][x_tile][y_tile][side].push_back (*index);
1072
- indices[IPIN][x_tile][y_tile][side].push_back (OPEN);
1061
+ rr_graph_builder.node_lookup ().add_node (RRNodeId (*index), x_tile, y_tile, OPIN, ipin, side);
1073
1062
assigned_to_rr_node = true ;
1074
1063
} else {
1075
1064
VTR_ASSERT (class_type == RECEIVER);
1076
- indices[OPIN][x_tile][y_tile][side].push_back (OPEN);
1077
- indices[IPIN][x_tile][y_tile][side].push_back (*index);
1065
+ rr_graph_builder.node_lookup ().add_node (RRNodeId (*index), x_tile, y_tile, IPIN, ipin, side);
1078
1066
assigned_to_rr_node = true ;
1079
1067
}
1080
- } else {
1081
- indices[IPIN][x_tile][y_tile][side].push_back (OPEN);
1082
- indices[OPIN][x_tile][y_tile][side].push_back (OPEN);
1083
1068
}
1084
1069
}
1085
1070
}
@@ -1099,25 +1084,6 @@ static void load_block_rr_indices(RRGraphBuilder& rr_graph_builder,
1099
1084
++(*index);
1100
1085
}
1101
1086
}
1102
-
1103
- // Sanity check
1104
- for (int width_offset = 0 ; width_offset < type->width ; ++width_offset) {
1105
- int x_tile = x + width_offset;
1106
- for (int height_offset = 0 ; height_offset < type->height ; ++height_offset) {
1107
- int y_tile = y + height_offset;
1108
- for (e_side side : SIDES) {
1109
- // Note that the fast look-up stores all the indices for the pins on each side
1110
- // It has a fixed size (either 0 or the number of pins)
1111
- // Case 0 pins: the side is skipped as no pins are located on it
1112
- // Case number of pins: there are pins on this side
1113
- // and data query can be applied any pin id on this side
1114
- VTR_ASSERT ((indices[IPIN][x_tile][y_tile][side].size () == size_t (type->num_pins ))
1115
- || (0 == indices[IPIN][x_tile][y_tile][side].size ()));
1116
- VTR_ASSERT ((indices[OPIN][x_tile][y_tile][side].size () == size_t (type->num_pins ))
1117
- || (0 == indices[OPIN][x_tile][y_tile][side].size ()));
1118
- }
1119
- }
1120
- }
1121
1087
}
1122
1088
}
1123
1089
}
@@ -1132,8 +1098,14 @@ static void load_block_rr_indices(RRGraphBuilder& rr_graph_builder,
1132
1098
int root_x = x - width_offset;
1133
1099
int root_y = y - height_offset;
1134
1100
1135
- indices[SOURCE][x][y][0 ] = indices[SOURCE][root_x][root_y][0 ];
1136
- indices[SINK][x][y][0 ] = indices[SINK][root_x][root_y][0 ];
1101
+ rr_graph_builder.node_lookup ().mirror_nodes (vtr::Point<int >(root_x, root_y),
1102
+ vtr::Point<int >(x, y),
1103
+ SOURCE,
1104
+ SIDES[0 ]);
1105
+ rr_graph_builder.node_lookup ().mirror_nodes (vtr::Point<int >(root_x, root_y),
1106
+ vtr::Point<int >(x, y),
1107
+ SINK,
1108
+ SIDES[0 ]);
1137
1109
}
1138
1110
}
1139
1111
}
@@ -1149,7 +1121,7 @@ static void load_block_rr_indices(RRGraphBuilder& rr_graph_builder,
1149
1121
* This will block us when putting the RRGraphBuilder object as an input arguement
1150
1122
* of this function
1151
1123
*/
1152
- void alloc_and_load_rr_node_indices (t_rr_node_indices& indices ,
1124
+ void alloc_and_load_rr_node_indices (RRGraphBuilder& rr_graph_builder ,
1153
1125
const int max_chan_width,
1154
1126
const DeviceGrid& grid,
1155
1127
int * index,
@@ -1162,20 +1134,20 @@ void alloc_and_load_rr_node_indices(t_rr_node_indices& indices,
1162
1134
/* Alloc the lookup table */
1163
1135
for (t_rr_type rr_type : RR_TYPES) {
1164
1136
if (rr_type == CHANX) {
1165
- indices[rr_type]. resize ({ grid.height (), grid.width (), NUM_SIDES} );
1137
+ rr_graph_builder. node_lookup (). resize_nodes ( grid.height (), grid.width (), rr_type, NUM_SIDES);
1166
1138
} else {
1167
- indices[rr_type]. resize ({ grid.width (), grid.height (), NUM_SIDES} );
1139
+ rr_graph_builder. node_lookup (). resize_nodes ( grid.width (), grid.height (), rr_type, NUM_SIDES);
1168
1140
}
1169
1141
}
1170
1142
1171
1143
/* Assign indices for block nodes */
1172
- load_block_rr_indices (g_vpr_ctx. mutable_device (). rr_graph_builder , indices , grid, index);
1144
+ load_block_rr_indices (rr_graph_builder, grid, index);
1173
1145
1174
1146
/* Load the data for x and y channels */
1175
1147
load_chan_rr_indices (max_chan_width, grid.width (), grid.height (),
1176
- CHANX, chan_details_x, indices , index);
1148
+ CHANX, chan_details_x, rr_graph_builder , index);
1177
1149
load_chan_rr_indices (max_chan_width, grid.height (), grid.width (),
1178
- CHANY, chan_details_y, indices , index);
1150
+ CHANY, chan_details_y, rr_graph_builder , index);
1179
1151
}
1180
1152
1181
1153
bool verify_rr_node_indices (const DeviceGrid& grid, const t_rr_node_indices& rr_node_indices, const t_rr_graph_storage& rr_nodes) {
0 commit comments