@@ -92,7 +92,7 @@ static void get_switchblocks_edges(RRGraphBuilder& rr_graph_builder,
92
92
const int switch_override,
93
93
const int custom_3d_sb_fanin_fanout,
94
94
const int delayless_switch,
95
- t_sb_connection_map* sb_conn_map,
95
+ const t_sb_connection_map& sb_conn_map,
96
96
vtr::NdMatrix<int , 2 >& num_of_3d_conns_custom_SB,
97
97
t_rr_edge_info_set& rr_edges_to_create,
98
98
t_rr_edge_info_set& des_3d_rr_edges_to_create,
@@ -130,7 +130,7 @@ static int get_track_to_chan_seg(RRGraphBuilder& rr_graph_builder,
130
130
const int swtich_override,
131
131
const int custom_3d_sb_fanin_fanout,
132
132
const int delayless_switch,
133
- t_sb_connection_map* sb_conn_map,
133
+ const t_sb_connection_map& sb_conn_map,
134
134
vtr::NdMatrix<int , 2 >& num_of_3d_conns_custom_SB,
135
135
RRNodeId from_rr_node,
136
136
t_rr_edge_info_set& rr_edges_to_create,
@@ -1245,15 +1245,15 @@ int get_track_to_tracks(RRGraphBuilder& rr_graph_builder,
1245
1245
const int custom_3d_sb_fanin_fanout,
1246
1246
const int delayless_switch,
1247
1247
const vtr::NdMatrix<std::vector<int >, 3 >& switch_block_conn,
1248
- t_sb_connection_map* sb_conn_map) {
1248
+ const t_sb_connection_map* sb_conn_map) {
1249
1249
int to_chan, to_sb;
1250
1250
std::vector<int > conn_tracks;
1251
1251
bool from_is_sblock, is_behind, Fs_clipped;
1252
1252
enum e_side to_side;
1253
1253
1254
1254
/* check whether a custom switch block will be used */
1255
1255
bool custom_switch_block = false ;
1256
- if (sb_conn_map) {
1256
+ if (sb_conn_map != nullptr ) {
1257
1257
custom_switch_block = true ;
1258
1258
VTR_ASSERT (switch_block_conn.empty ());
1259
1259
}
@@ -1375,7 +1375,7 @@ int get_track_to_tracks(RRGraphBuilder& rr_graph_builder,
1375
1375
num_conn += get_track_to_chan_seg (rr_graph_builder, layer, max_chan_width, from_track, to_chan, to_seg,
1376
1376
to_type, from_side_a, to_side,
1377
1377
switch_override, custom_3d_sb_fanin_fanout, delayless_switch,
1378
- sb_conn_map, num_of_3d_conns_custom_SB, from_rr_node, rr_edges_to_create, des_3d_rr_edges_to_create);
1378
+ * sb_conn_map, num_of_3d_conns_custom_SB, from_rr_node, rr_edges_to_create, des_3d_rr_edges_to_create);
1379
1379
}
1380
1380
} else {
1381
1381
if (BI_DIRECTIONAL == directionality) {
@@ -1413,7 +1413,7 @@ int get_track_to_tracks(RRGraphBuilder& rr_graph_builder,
1413
1413
num_conn += get_track_to_chan_seg (rr_graph_builder, layer, max_chan_width, from_track, to_chan, to_seg,
1414
1414
to_type, from_side_b, to_side,
1415
1415
switch_override, custom_3d_sb_fanin_fanout, delayless_switch,
1416
- sb_conn_map, num_of_3d_conns_custom_SB, from_rr_node, rr_edges_to_create, des_3d_rr_edges_to_create);
1416
+ * sb_conn_map, num_of_3d_conns_custom_SB, from_rr_node, rr_edges_to_create, des_3d_rr_edges_to_create);
1417
1417
}
1418
1418
} else {
1419
1419
if (BI_DIRECTIONAL == directionality) {
@@ -1527,38 +1527,39 @@ static void get_switchblocks_edges(RRGraphBuilder& rr_graph_builder,
1527
1527
const int switch_override,
1528
1528
const int custom_3d_sb_fanin_fanout,
1529
1529
const int delayless_switch,
1530
- t_sb_connection_map* sb_conn_map,
1530
+ const t_sb_connection_map& sb_conn_map,
1531
1531
vtr::NdMatrix<int , 2 >& num_of_3d_conns_custom_SB,
1532
1532
t_rr_edge_info_set& rr_edges_to_create,
1533
1533
t_rr_edge_info_set& des_3d_rr_edges_to_create,
1534
1534
int & edge_count) {
1535
- auto & device_ctx = g_vpr_ctx.device ();
1535
+ const auto & device_ctx = g_vpr_ctx.device ();
1536
1536
1537
- /* get coordinate to index into the SB map */
1537
+ // Coordinate to index into the SB map
1538
1538
SwitchblockLookupKey sb_coord (tile_x, tile_y, layer, from_side, to_side);
1539
- if (sb_conn_map-> count (sb_coord) > 0 ) {
1540
- /* get reference to the connections vector which lists all destination wires for a given source wire
1541
- * at a specific coordinate sb_coord */
1542
- std::vector<t_switchblock_edge>& conn_vector = (* sb_conn_map)[ sb_coord] ;
1543
-
1544
- /* go through the connections... */
1545
- for (int iconn = 0 ; iconn < ( int )conn_vector. size (); ++iconn ) {
1546
- if (conn_vector. at (iconn) .from_wire != from_wire) continue ;
1547
-
1548
- int to_wire = conn_vector. at (iconn) .to_wire ;
1549
- int to_layer = conn_vector. at (iconn) .to_wire_layer ;
1550
- /* Get the index of the switch connecting the two wires */
1551
- int src_switch = conn_vector[iconn] .switch_ind ;
1552
- /* Get the index of the switch connecting the two wires in two layers */
1553
- int src_switch_betwen_layers = conn_vector[iconn] .switch_ind_between_layers ;
1554
-
1555
- if (to_layer == layer) { // track-to-track connection within the same layer
1539
+ if (sb_conn_map. count (sb_coord) > 0 ) {
1540
+ // Reference to the connections vector which lists all destination wires for a given source wire
1541
+ // at a specific coordinate sb_coord
1542
+ const std::vector<t_switchblock_edge>& sb_edges = sb_conn_map. at ( sb_coord) ;
1543
+
1544
+ // Go through the connections...
1545
+ for (const t_switchblock_edge& sb_edge : sb_edges ) {
1546
+ if (sb_edge .from_wire != from_wire) continue ;
1547
+
1548
+ int to_wire = sb_edge .to_wire ;
1549
+ int to_layer = sb_edge .to_wire_layer ;
1550
+ // Get the index of the switch connecting the two wires
1551
+ int src_switch = sb_edge .switch_ind ;
1552
+ // Get the index of the switch connecting the two wires in two layers
1553
+ int src_switch_betwen_layers = sb_edge .switch_ind_between_layers ;
1554
+
1555
+ if (to_layer == layer) { // track-to-track connection within the same layer
1556
1556
RRNodeId to_node = rr_graph_builder.node_lookup ().find_node (to_layer, to_x, to_y, to_chan_type, to_wire);
1557
1557
1558
1558
if (!to_node) {
1559
1559
continue ;
1560
1560
}
1561
- // Apply any switch overrides
1561
+
1562
+ // Apply any switch overrides
1562
1563
if (should_apply_switch_override (switch_override)) {
1563
1564
src_switch = switch_override;
1564
1565
}
@@ -1567,34 +1568,32 @@ static void get_switchblocks_edges(RRGraphBuilder& rr_graph_builder,
1567
1568
++edge_count;
1568
1569
1569
1570
if (device_ctx.arch_switch_inf [src_switch].directionality () == BI_DIRECTIONAL) {
1570
- // Add reverse edge since bi-directional
1571
+ // Add reverse edge since bidirectional
1571
1572
rr_edges_to_create.emplace_back (to_node, from_rr_node, src_switch, false );
1572
1573
++edge_count;
1573
1574
}
1574
- } else { // track-to_track connection crossing layer
1575
+ } else { // track-to_track connection crossing layer
1575
1576
VTR_ASSERT (to_layer != layer);
1576
- // check if current connection is valid, since switch block pattern is very general,
1577
- // we might see invalid layer in connection, so we just skip those
1578
- if ((layer < 0 || layer >= device_ctx.grid .get_num_layers ()) || (to_layer < 0 || to_layer >= device_ctx.grid .get_num_layers ())) {
1577
+ // Check if current connection is valid, since switch block pattern is very general,
1578
+ // we might see invalid layer in connection, so we just skip those
1579
+ if ((layer < 0 || layer >= device_ctx.grid .get_num_layers ())
1580
+ || (to_layer < 0 || to_layer >= device_ctx.grid .get_num_layers ())) {
1579
1581
continue ;
1580
1582
}
1581
1583
1582
1584
if (tile_x != to_x || tile_y != to_y) {
1583
1585
continue ;
1584
1586
}
1585
1587
1586
- /*
1587
- * In order to connect two tracks in different layers, we need to follow these three steps:
1588
- * 1) connect "from_tracks" to extra "chanx" node in the same switch blocks
1589
- * 2) connect extra "chanx" node located in from_layer to another extra "chanx" node located in to_layer
1590
- * 3) connect "chanx" node located in to_layer to "to_track"
1591
- *
1592
- * +-------------+ +-------------+ +--------------+ +--------------+
1593
- * | from_wire | -----> | extra_chanx | ------> | extra_chanx | ------> | to_wire |
1594
- * | (src_layer) | | (src_layer) | | (dest_layer) | | (dest_layer) |
1595
- * +-------------+ +-------------+ +--------------+ +--------------+
1596
- *
1597
- * */
1588
+ // In order to connect two tracks in different layers, we need to follow these three steps:
1589
+ // 1) connect "from_tracks" to extra "chanx" node in the same switch blocks
1590
+ // 2) connect extra "chanx" node located in from_layer to another extra "chanx" node located in to_layer
1591
+ // 3) connect "chanx" node located in to_layer to "to_track"
1592
+ // +-------------+ +-------------+ +--------------+ +--------------+
1593
+ // | from_wire | -----> | extra_chanx | ------> | extra_chanx | ------> | to_wire |
1594
+ // | (src_layer) | | (src_layer) | | (dest_layer) | | (dest_layer) |
1595
+ // +-------------+ +-------------+ +--------------+ +--------------+
1596
+
1598
1597
int offset = num_of_3d_conns_custom_SB[tile_x][tile_y] / custom_3d_sb_fanin_fanout;
1599
1598
RRNodeId track_to_chanx_node = rr_graph_builder.node_lookup ().find_node (layer, tile_x, tile_y, e_rr_type::CHANX, max_chan_width + offset);
1600
1599
RRNodeId diff_layer_chanx_node = rr_graph_builder.node_lookup ().find_node (to_layer, tile_x, tile_y, e_rr_type::CHANX, max_chan_width + offset);
@@ -1604,21 +1603,21 @@ static void get_switchblocks_edges(RRGraphBuilder& rr_graph_builder,
1604
1603
continue ;
1605
1604
}
1606
1605
1607
- // Apply any switch overrides
1606
+ // Apply any switch overrides
1608
1607
if (should_apply_switch_override (switch_override)) {
1609
1608
src_switch = switch_override;
1610
1609
}
1611
1610
1612
- // add edge between source node at from layer to intermediate node
1611
+ // Add edge between source node at from layer to intermediate node
1613
1612
rr_edges_to_create.emplace_back (from_rr_node, track_to_chanx_node, delayless_switch, false );
1614
1613
++edge_count;
1615
1614
1616
- // add edge between intermediate node to destination node at to layer
1617
- // might add the same edge more than once
1615
+ // Add edge between intermediate node to destination node at to layer
1616
+ // might add the same edge more than once, but redundant edges will be removed before updating the RR graph
1618
1617
des_3d_rr_edges_to_create.emplace_back (diff_layer_chanx_node, chanx_to_track_node, src_switch_betwen_layers, false );
1619
1618
++edge_count;
1620
1619
1621
- // we only add the following edge between intermediate nodes once for the first 3D connection for each pair of intermediate nodes
1620
+ // We only add the following edge between intermediate nodes once for the first 3D connection for each pair of intermediate nodes
1622
1621
if (num_of_3d_conns_custom_SB[tile_x][tile_y] % custom_3d_sb_fanin_fanout == 0 ) {
1623
1622
rr_edges_to_create.emplace_back (track_to_chanx_node, diff_layer_chanx_node, delayless_switch, false );
1624
1623
++edge_count;
@@ -1642,7 +1641,7 @@ static int get_track_to_chan_seg(RRGraphBuilder& rr_graph_builder,
1642
1641
const int switch_override,
1643
1642
const int custom_3d_sb_fanin_fanout,
1644
1643
const int delayless_switch,
1645
- t_sb_connection_map* sb_conn_map,
1644
+ const t_sb_connection_map& sb_conn_map,
1646
1645
vtr::NdMatrix<int , 2 >& num_of_3d_conns_custom_SB,
1647
1646
RRNodeId from_rr_node,
1648
1647
t_rr_edge_info_set& rr_edges_to_create,
@@ -1651,7 +1650,7 @@ static int get_track_to_chan_seg(RRGraphBuilder& rr_graph_builder,
1651
1650
int to_x, to_y;
1652
1651
int tile_x, tile_y;
1653
1652
1654
- /* get x/y coordinates from seg/chan coordinates */
1653
+ // Get x/y coordinates from seg/chan coordinates
1655
1654
if (e_rr_type::CHANX == to_chan_type) {
1656
1655
to_x = tile_x = to_seg;
1657
1656
to_y = tile_y = to_chan;
@@ -1688,7 +1687,7 @@ static int get_track_to_chan_seg(RRGraphBuilder& rr_graph_builder,
1688
1687
des_3d_rr_edges_to_create,
1689
1688
edge_count);
1690
1689
1691
- // check sb_conn_map for connections between two layers
1690
+ // Check sb_conn_map for connections between two layers
1692
1691
for (e_side to_another_die_side : {ABOVE, UNDER}) {
1693
1692
get_switchblocks_edges (rr_graph_builder,
1694
1693
tile_x,
@@ -1798,9 +1797,9 @@ static int get_unidir_track_to_chan_seg(RRGraphBuilder& rr_graph_builder,
1798
1797
rr_edges_to_create.emplace_back (from_rr_node, to_node, iswitch, false );
1799
1798
++count;
1800
1799
1801
- auto & device_ctx = g_vpr_ctx.device ();
1800
+ const auto & device_ctx = g_vpr_ctx.device ();
1802
1801
if (device_ctx.arch_switch_inf [iswitch].directionality () == BI_DIRECTIONAL) {
1803
- // Add reverse edge since bi-directional
1802
+ // Add reverse edge since bidirectional
1804
1803
rr_edges_to_create.emplace_back (to_node, from_rr_node, iswitch, false );
1805
1804
++count;
1806
1805
}
0 commit comments