Skip to content

Commit cbc1a13

Browse files
committed
[vpr][utils] fix get_cluster_block_pins for the case when a tile has sub-tiles of different types
1 parent 0727c50 commit cbc1a13

File tree

1 file changed

+36
-6
lines changed

1 file changed

+36
-6
lines changed

vpr/src/util/vpr_utils.cpp

Lines changed: 36 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1909,17 +1909,47 @@ std::vector<int> get_cluster_netlist_intra_tile_pins_at_loc(const t_physical_til
19091909
std::vector<int> get_cluster_block_pins(t_physical_tile_type_ptr physical_tile,
19101910
ClusterBlockId cluster_blk_id,
19111911
int abs_cap) {
1912-
int max_num_pin = get_tile_total_num_pin(physical_tile) / physical_tile->capacity;
1913-
int num_tile_pin_per_inst = physical_tile->num_pins / physical_tile->capacity;
1914-
std::vector<int> pin_num_vec(num_tile_pin_per_inst);
1915-
std::iota(pin_num_vec.begin(), pin_num_vec.end(), abs_cap * num_tile_pin_per_inst);
1912+
// To get the list of pins, we first add the pins on the tile-level, then add the pins on the intra-tile-level.
1913+
1914+
// A counter to keep track of number of tile-level pins for the sub-tiles before the current sub-tile.
1915+
int seen_sub_tiles_num_cluser_pins = 0;
1916+
// The number of tile-level pins for the sub-tile instance that the cluster block is mapped to.
1917+
int cluster_sub_tile_isnt_num_pins;
1918+
// A flag to check if the sub-tile instance that the cluster block is mapped to has been found.
1919+
bool found_sub_tile = false;
1920+
1921+
// Iterate over all the sub-tiles to find the sub-tile instance that the cluster block is mapped to.
1922+
for (const auto& tmp_sub_tile: physical_tile->sub_tiles) {
1923+
if (tmp_sub_tile.capacity.is_in_range(abs_cap)) {
1924+
// This sub-tile type is the one that the cluster block is mapped to.
1925+
found_sub_tile = true;
1926+
// The number of tile-level pins for all isntances of the same sub-tile type is the same. Thus,
1927+
// we can the the number of tile-level pins for the sub-tile instance by dividing the total number of pins
1928+
// for the given sub-tile type by the number of instances.
1929+
cluster_sub_tile_isnt_num_pins = (tmp_sub_tile.num_phy_pins / tmp_sub_tile.capacity.total());
1930+
int rel_cap = abs_cap - tmp_sub_tile.capacity.low;
1931+
// Add the number of tile-level pins for the instances before the current sub-tile instance to the counter.
1932+
seen_sub_tiles_num_cluser_pins += rel_cap * cluster_sub_tile_isnt_num_pins;
1933+
break;
1934+
} else {
1935+
// This sub-tile type is not the one that the cluster block is mapped to.
1936+
// Add the number of tile-level pins for this sub-tile type to the counter
1937+
// and continue to the next sub-tile type.
1938+
seen_sub_tiles_num_cluser_pins += tmp_sub_tile.num_phy_pins;
1939+
}
1940+
}
19161941

1917-
pin_num_vec.reserve(max_num_pin);
1942+
VTR_ASSERT(found_sub_tile);
1943+
std::vector<int> pin_num_vec(cluster_sub_tile_isnt_num_pins);
1944+
// Pin numbers are assigned such that each instance’s tile-level pins
1945+
// occupy a continuous range equal to the total number of tile-level pins for that instance.
1946+
// Since we know the starting index, we use std::iota to generate that range.
1947+
std::iota(pin_num_vec.begin(), pin_num_vec.end(), seen_sub_tiles_num_cluser_pins);
19181948

1949+
// Add the intra-cluster-level pins to the list.
19191950
auto internal_pins = get_cluster_internal_pins(cluster_blk_id);
19201951
pin_num_vec.insert(pin_num_vec.end(), internal_pins.begin(), internal_pins.end());
19211952

1922-
pin_num_vec.shrink_to_fit();
19231953
return pin_num_vec;
19241954
}
19251955

0 commit comments

Comments
 (0)