Skip to content

Commit 7865d32

Browse files
committed
equivalent tiles: corrected equivalent placement in func find_to
Signed-off-by: Alessandro Comodi <[email protected]>
1 parent c0847bc commit 7865d32

File tree

1 file changed

+13
-6
lines changed

1 file changed

+13
-6
lines changed

vpr/src/place/place.cpp

Lines changed: 13 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1835,12 +1835,19 @@ static e_swap_result try_swap(float t,
18351835
VTR_ASSERT(cluster_from_type->is_available_tile_index(grid_from_type->index));
18361836

18371837
t_type_ptr to_block_type = cluster_ctx.clb_nlist.block_type(b_from);
1838-
int rand_block_type = vtr::irand(to_block_type->num_equivalent_tiles);
1839-
if (rand_block_type != 0) {
1840-
auto result = to_block_type->equivalent_tiles.find(rand_block_type-1);
1841-
VTR_ASSERT(result != to_block_type->equivalent_tiles.end());
18421838

1843-
to_block_type = result->second;
1839+
1840+
// Find random equivalent type (could be of the same type as the `from` one)
1841+
if (to_block_type->num_equivalent_tiles > 0) {
1842+
int irand_block_type = std::rand() % (to_block_type->num_equivalent_tiles + 1);
1843+
1844+
// If random index is 0 do not use an equivalent tile.
1845+
if (irand_block_type > 0) {
1846+
auto result = to_block_type->equivalent_tiles.find(irand_block_type - 1);
1847+
VTR_ASSERT(result != to_block_type->equivalent_tiles.end());
1848+
1849+
to_block_type = result->second;
1850+
}
18441851
}
18451852

18461853
VTR_ASSERT(cluster_from_type->is_available_tile_index(to_block_type->index));
@@ -2145,7 +2152,7 @@ static bool find_to(t_type_ptr to_type, t_type_ptr from_type, float rlim, const
21452152
int min_cy, max_cy;
21462153
int delta_cx;
21472154

2148-
//Determin the valid compressed grid location ranges
2155+
//Determine the valid compressed grid location ranges
21492156
if (to_type == from_type) {
21502157
min_cx = std::max(0, cx_from - rlim_x);
21512158
max_cx = std::min<int>(to_compressed_block_grid.compressed_to_grid_x.size() - 1, cx_from + rlim_x);

0 commit comments

Comments
 (0)