Skip to content

Commit bbc3140

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

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

@@ -1683,23 +1684,38 @@ bool is_legal_swap_to_location(ClusterBlockId blk, t_pl_loc to) {
16831684
auto blk_type_from = cluster_ctx.clb_nlist.block_type(blk);
16841685
auto blk_type_to = device_ctx.grid[to.x][to.y].type;
16851686

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
16871688
if (!blk_type_from->is_available_tile_index(blk_type_to->index)) {
16881689
return false;
16891690
}
16901691

16911692
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+
16921708
ClusterBlockId blk_to = place_ctx.grid_blocks[to.x][to.y].blocks[to.z];
16931709

16941710
// In case `blk_to` is empty we can skip the second check
16951711
if (blk_to == EMPTY_BLOCK_ID) {
16961712
return true;
16971713
}
16981714

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);
17011717

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
17031719
if (!blk_type_to->is_available_tile_index(blk_type_from->index)) {
17041720
return false;
17051721
}
@@ -2187,7 +2203,7 @@ static bool find_to(t_type_ptr to_type, t_type_ptr from_type, float rlim, const
21872203
VTR_ASSERT_MSG(device_ctx.grid[to.x][to.y].width_offset == 0, "Should be at block base location");
21882204
VTR_ASSERT_MSG(device_ctx.grid[to.x][to.y].height_offset == 0, "Should be at block base location");
21892205

2190-
return true;
2206+
return is_legal_blk_swap(from, to);
21912207
}
21922208

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

0 commit comments

Comments
 (0)