Skip to content

Commit a59408a

Browse files
committed
vpr: corrected bug in equivalent placement
Signed-off-by: Alessandro Comodi <[email protected]>
1 parent e1200cd commit a59408a

File tree

1 file changed

+21
-5
lines changed

1 file changed

+21
-5
lines changed

vpr/src/place/place.cpp

Lines changed: 21 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -318,6 +318,7 @@ static e_find_affected_blocks_result identify_macro_self_swap_affected_macros(st
318318
static e_find_affected_blocks_result record_macro_self_swaps(const int imacro, t_pl_offset swap_offset);
319319

320320
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);
321322

322323
std::set<t_pl_loc> determine_locations_emptied_by_move();
323324

@@ -1675,23 +1676,38 @@ bool is_legal_swap_to_location(ClusterBlockId blk, t_pl_loc to) {
16751676
auto blk_type_from = cluster_ctx.clb_nlist.block_type(blk);
16761677
auto blk_type_to = device_ctx.grid[to.x][to.y].type;
16771678

1678-
// First check is to see if `from` type can be placed in `to` type
1679+
// Check is to see if `from` type can be placed in `to` type
16791680
if (!blk_type_from->is_available_tile_index(blk_type_to->index)) {
16801681
return false;
16811682
}
16821683

16831684
t_pl_loc from = place_ctx.block_locs[blk].loc;
1685+
if (!is_legal_blk_swap(from, to)) {
1686+
return false;
1687+
}
1688+
1689+
return true;
1690+
}
1691+
1692+
bool is_legal_blk_swap(t_pl_loc from, t_pl_loc to) {
1693+
// Make sure that when swapping, the block in the `to` location
1694+
// can be moved in the `from` location
1695+
1696+
auto& device_ctx = g_vpr_ctx.device();
1697+
auto& cluster_ctx = g_vpr_ctx.clustering();
1698+
auto& place_ctx = g_vpr_ctx.placement();
1699+
16841700
ClusterBlockId blk_to = place_ctx.grid_blocks[to.x][to.y].blocks[to.z];
16851701

16861702
// In case `blk_to` is empty we can skip the second check
16871703
if (blk_to == EMPTY_BLOCK_ID) {
16881704
return true;
16891705
}
16901706

1691-
blk_type_from = device_ctx.grid[from.x][from.y].type;
1692-
blk_type_to = cluster_ctx.clb_nlist.block_type(blk_to);
1707+
auto blk_type_from = device_ctx.grid[from.x][from.y].type;
1708+
auto blk_type_to = cluster_ctx.clb_nlist.block_type(blk_to);
16931709

1694-
// Second check is to see if `to` type can be placed in `from` type
1710+
// Check is to see if `to` type can be placed in `from` type
16951711
if (!blk_type_to->is_available_tile_index(blk_type_from->index)) {
16961712
return false;
16971713
}
@@ -2179,7 +2195,7 @@ static bool find_to(t_type_ptr to_type, t_type_ptr from_type, float rlim, const
21792195
VTR_ASSERT_MSG(device_ctx.grid[to.x][to.y].width_offset == 0, "Should be at block base location");
21802196
VTR_ASSERT_MSG(device_ctx.grid[to.x][to.y].height_offset == 0, "Should be at block base location");
21812197

2182-
return true;
2198+
return is_legal_blk_swap(from, to);
21832199
}
21842200

21852201
static e_swap_result assess_swap(double delta_c, double t) {

0 commit comments

Comments
 (0)