@@ -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,41 @@ 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) {
940
+ /* TODO: May let the length() == 0 case go through, to model muxes */
952
941
if (seg_details[track].length () <= 0 )
953
942
continue ;
954
943
955
944
int start = get_seg_start (seg_details, track, chan, seg);
956
945
946
+ /* TODO: Now we still use the (y, x) convention here for CHANX. Should rework later */
947
+ int node_x = chan;
948
+ int node_y = start;
949
+ if (CHANX == type) {
950
+ std::swap (node_x, node_y);
951
+ }
952
+
957
953
/* If the start of the wire doesn't have a inode,
958
954
* assign one to it. */
959
- int inode = indices[ type][chan][start][ 0 ][track] ;
960
- if (OPEN == inode) {
961
- inode = *index;
955
+ RRNodeId inode = rr_graph_builder. node_lookup (). find_node (node_x, node_y, type, track, SIDES[ 0 ]) ;
956
+ if (! inode) {
957
+ inode = RRNodeId ( *index) ;
962
958
++(*index);
963
959
964
- indices[type][ chan][ start] [0 ][track] = inode ;
960
+ rr_graph_builder. node_lookup (). add_node (inode, chan, start, type, track, SIDES [0 ]) ;
965
961
}
966
962
967
963
/* Assign inode of start of wire to current position */
968
- indices[type][ chan][ seg] [0 ][track] = inode ;
964
+ rr_graph_builder. node_lookup (). add_node (inode, chan, seg, type, track, SIDES [0 ]) ;
969
965
}
970
966
}
971
967
}
@@ -975,7 +971,6 @@ static void load_chan_rr_indices(const int max_chan_width,
975
971
* TODO: these building functions should only talk to a RRGraphBuilder object
976
972
*/
977
973
static void load_block_rr_indices (RRGraphBuilder& rr_graph_builder,
978
- t_rr_node_indices& indices,
979
974
const DeviceGrid& grid,
980
975
int * index) {
981
976
// Walk through the grid assigning indices to SOURCE/SINK IPIN/OPIN
@@ -991,16 +986,12 @@ static void load_block_rr_indices(RRGraphBuilder& rr_graph_builder,
991
986
auto class_type = type->class_inf [iclass].type ;
992
987
if (class_type == DRIVER) {
993
988
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
989
} else {
996
990
VTR_ASSERT (class_type == RECEIVER);
997
991
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
992
}
1000
993
++(*index);
1001
994
}
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
995
1005
996
/* Limited sides for grids
1006
997
* The wanted side depends on the location of the grid.
@@ -1068,18 +1059,13 @@ static void load_block_rr_indices(RRGraphBuilder& rr_graph_builder,
1068
1059
auto class_type = type->class_inf [iclass].type ;
1069
1060
1070
1061
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);
1062
+ rr_graph_builder.node_lookup ().add_node (RRNodeId (*index), x_tile, y_tile, OPIN, ipin, side);
1073
1063
assigned_to_rr_node = true ;
1074
1064
} else {
1075
1065
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);
1066
+ rr_graph_builder.node_lookup ().add_node (RRNodeId (*index), x_tile, y_tile, IPIN, ipin, side);
1078
1067
assigned_to_rr_node = true ;
1079
1068
}
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
1069
}
1084
1070
}
1085
1071
}
@@ -1099,25 +1085,6 @@ static void load_block_rr_indices(RRGraphBuilder& rr_graph_builder,
1099
1085
++(*index);
1100
1086
}
1101
1087
}
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
1088
}
1122
1089
}
1123
1090
}
@@ -1132,8 +1099,14 @@ static void load_block_rr_indices(RRGraphBuilder& rr_graph_builder,
1132
1099
int root_x = x - width_offset;
1133
1100
int root_y = y - height_offset;
1134
1101
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 ];
1102
+ rr_graph_builder.node_lookup ().mirror_nodes (vtr::Point<int >(root_x, root_y),
1103
+ vtr::Point<int >(x, y),
1104
+ SOURCE,
1105
+ SIDES[0 ]);
1106
+ rr_graph_builder.node_lookup ().mirror_nodes (vtr::Point<int >(root_x, root_y),
1107
+ vtr::Point<int >(x, y),
1108
+ SINK,
1109
+ SIDES[0 ]);
1137
1110
}
1138
1111
}
1139
1112
}
@@ -1149,7 +1122,7 @@ static void load_block_rr_indices(RRGraphBuilder& rr_graph_builder,
1149
1122
* This will block us when putting the RRGraphBuilder object as an input arguement
1150
1123
* of this function
1151
1124
*/
1152
- void alloc_and_load_rr_node_indices (t_rr_node_indices& indices ,
1125
+ void alloc_and_load_rr_node_indices (RRGraphBuilder& rr_graph_builder ,
1153
1126
const int max_chan_width,
1154
1127
const DeviceGrid& grid,
1155
1128
int * index,
@@ -1162,20 +1135,20 @@ void alloc_and_load_rr_node_indices(t_rr_node_indices& indices,
1162
1135
/* Alloc the lookup table */
1163
1136
for (t_rr_type rr_type : RR_TYPES) {
1164
1137
if (rr_type == CHANX) {
1165
- indices[rr_type]. resize ({ grid.height (), grid.width (), NUM_SIDES} );
1138
+ rr_graph_builder. node_lookup (). resize_nodes ( grid.height (), grid.width (), rr_type, NUM_SIDES);
1166
1139
} else {
1167
- indices[rr_type]. resize ({ grid.width (), grid.height (), NUM_SIDES} );
1140
+ rr_graph_builder. node_lookup (). resize_nodes ( grid.width (), grid.height (), rr_type, NUM_SIDES);
1168
1141
}
1169
1142
}
1170
1143
1171
1144
/* Assign indices for block nodes */
1172
- load_block_rr_indices (g_vpr_ctx. mutable_device (). rr_graph_builder , indices , grid, index);
1145
+ load_block_rr_indices (rr_graph_builder, grid, index);
1173
1146
1174
1147
/* Load the data for x and y channels */
1175
1148
load_chan_rr_indices (max_chan_width, grid.width (), grid.height (),
1176
- CHANX, chan_details_x, indices , index);
1149
+ CHANX, chan_details_x, rr_graph_builder , index);
1177
1150
load_chan_rr_indices (max_chan_width, grid.height (), grid.width (),
1178
- CHANY, chan_details_y, indices , index);
1151
+ CHANY, chan_details_y, rr_graph_builder , index);
1179
1152
}
1180
1153
1181
1154
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