@@ -318,6 +318,7 @@ static e_find_affected_blocks_result identify_macro_self_swap_affected_macros(st
318
318
static e_find_affected_blocks_result record_macro_self_swaps (const int imacro, t_pl_offset swap_offset);
319
319
320
320
bool is_legal_swap_to_location (ClusterBlockId blk, t_pl_loc to);
321
+ bool is_legal_blk_swap (t_pl_loc from, t_pl_loc to);
321
322
322
323
std::set<t_pl_loc> determine_locations_emptied_by_move ();
323
324
@@ -1683,23 +1684,38 @@ bool is_legal_swap_to_location(ClusterBlockId blk, t_pl_loc to) {
1683
1684
auto blk_type_from = cluster_ctx.clb_nlist .block_type (blk);
1684
1685
auto blk_type_to = device_ctx.grid [to.x ][to.y ].type ;
1685
1686
1686
- // First check is to see if `from` type can be placed in `to` type
1687
+ // Check is to see if `from` type can be placed in `to` type
1687
1688
if (!blk_type_from->is_available_tile_index (blk_type_to->index )) {
1688
1689
return false ;
1689
1690
}
1690
1691
1691
1692
t_pl_loc from = place_ctx.block_locs [blk].loc ;
1693
+ if (!is_legal_blk_swap (from, to)) {
1694
+ return false ;
1695
+ }
1696
+
1697
+ return true ;
1698
+ }
1699
+
1700
+ bool is_legal_blk_swap (t_pl_loc from, t_pl_loc to) {
1701
+ // Make sure that when swapping, the block in the `to` location
1702
+ // can be moved in the `from` location
1703
+
1704
+ auto & device_ctx = g_vpr_ctx.device ();
1705
+ auto & cluster_ctx = g_vpr_ctx.clustering ();
1706
+ auto & place_ctx = g_vpr_ctx.placement ();
1707
+
1692
1708
ClusterBlockId blk_to = place_ctx.grid_blocks [to.x ][to.y ].blocks [to.z ];
1693
1709
1694
1710
// In case `blk_to` is empty we can skip the second check
1695
1711
if (blk_to == EMPTY_BLOCK_ID) {
1696
1712
return true ;
1697
1713
}
1698
1714
1699
- blk_type_from = device_ctx.grid [from.x ][from.y ].type ;
1700
- blk_type_to = cluster_ctx.clb_nlist .block_type (blk_to);
1715
+ auto blk_type_from = device_ctx.grid [from.x ][from.y ].type ;
1716
+ auto blk_type_to = cluster_ctx.clb_nlist .block_type (blk_to);
1701
1717
1702
- // Second check is to see if `to` type can be placed in `from` type
1718
+ // Check is to see if `to` type can be placed in `from` type
1703
1719
if (!blk_type_to->is_available_tile_index (blk_type_from->index )) {
1704
1720
return false ;
1705
1721
}
@@ -2187,7 +2203,7 @@ static bool find_to(t_type_ptr to_type, t_type_ptr from_type, float rlim, const
2187
2203
VTR_ASSERT_MSG (device_ctx.grid [to.x ][to.y ].width_offset == 0 , " Should be at block base location" );
2188
2204
VTR_ASSERT_MSG (device_ctx.grid [to.x ][to.y ].height_offset == 0 , " Should be at block base location" );
2189
2205
2190
- return true ;
2206
+ return is_legal_blk_swap (from, to) ;
2191
2207
}
2192
2208
2193
2209
static e_swap_result assess_swap (double delta_c, double t) {
0 commit comments