@@ -1835,12 +1835,19 @@ static e_swap_result try_swap(float t,
1835
1835
VTR_ASSERT (cluster_from_type->is_available_tile_index (grid_from_type->index ));
1836
1836
1837
1837
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 ());
1842
1838
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
+ }
1844
1851
}
1845
1852
1846
1853
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
2145
2152
int min_cy, max_cy;
2146
2153
int delta_cx;
2147
2154
2148
- // Determin the valid compressed grid location ranges
2155
+ // Determine the valid compressed grid location ranges
2149
2156
if (to_type == from_type) {
2150
2157
min_cx = std::max (0 , cx_from - rlim_x);
2151
2158
max_cx = std::min<int >(to_compressed_block_grid.compressed_to_grid_x .size () - 1 , cx_from + rlim_x);
0 commit comments