Skip to content

Commit 19b6018

Browse files
committed
[vpr][route] move get_cluster_block_pins from util to rr_graph_intra_cluster
1 parent fbf951b commit 19b6018

File tree

3 files changed

+57
-56
lines changed

3 files changed

+57
-56
lines changed

vpr/src/route/rr_graph_generation/rr_graph_intra_cluster.cpp

Lines changed: 57 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,16 @@
1212
#include "rr_graph_switch_utils.h"
1313
#include "check_rr_graph.h"
1414

15+
/**
16+
* @brief Returns the list of pins (both cluster-level and intra-cluster-level) of the given cluster block.
17+
* @param physical_tile The physical tile type that the cluster block is mapped to.
18+
* @param cluster_blk_id The cluster block ID.
19+
* @param sub_tile_index The sub-tile absolute index (in comparison to relative index which is the index among sub-tiles of the same type) in the physical tile type.
20+
*/
21+
static std::vector<int> get_cluster_block_pins(t_physical_tile_type_ptr physical_tile,
22+
ClusterBlockId cluster_blk_id,
23+
int sub_tile_index);
24+
1525
static void set_clusters_pin_chains(const ClusteredNetlist& clb_nlist,
1626
vtr::vector<ClusterBlockId, t_cluster_pin_chain>& pin_chains,
1727
bool is_flat);
@@ -179,6 +189,53 @@ static void add_pin_chain(const std::vector<int>& pin_chain,
179189
std::vector<std::vector<t_pin_chain_node>>& all_chains,
180190
bool is_new_chain);
181191

192+
static std::vector<int> get_cluster_block_pins(t_physical_tile_type_ptr physical_tile,
193+
ClusterBlockId cluster_blk_id,
194+
int sub_tile_index) {
195+
// To get the list of pins, we first add the pins on the tile-level, then add the pins on the intra-tile-level.
196+
197+
// A counter to keep track of number of tile-level pins for the sub-tiles before the current sub-tile.
198+
int seen_sub_tiles_num_cluser_pins = 0;
199+
// The number of tile-level pins for the sub-tile instance that the cluster block is mapped to.
200+
int cluster_sub_tile_isnt_num_pins;
201+
// A flag to check if the sub-tile instance that the cluster block is mapped to has been found.
202+
bool found_sub_tile = false;
203+
204+
// Iterate over all the sub-tiles to find the sub-tile instance that the cluster block is mapped to.
205+
for (const t_sub_tile& tmp_sub_tile: physical_tile->sub_tiles) {
206+
if (tmp_sub_tile.capacity.is_in_range(sub_tile_index)) {
207+
// This sub-tile type is the one that the cluster block is mapped to.
208+
found_sub_tile = true;
209+
// The number of tile-level pins for all isntances of the same sub-tile type is the same. Thus,
210+
// we can the the number of tile-level pins for the sub-tile instance by dividing the total number of pins
211+
// for the given sub-tile type by the number of instances.
212+
cluster_sub_tile_isnt_num_pins = (tmp_sub_tile.num_phy_pins / tmp_sub_tile.capacity.total());
213+
int rel_cap = sub_tile_index - tmp_sub_tile.capacity.low;
214+
// Add the number of tile-level pins for the instances before the current sub-tile instance to the counter.
215+
seen_sub_tiles_num_cluser_pins += rel_cap * cluster_sub_tile_isnt_num_pins;
216+
break;
217+
} else {
218+
// This sub-tile type is not the one that the cluster block is mapped to.
219+
// Add the number of tile-level pins for this sub-tile type to the counter
220+
// and continue to the next sub-tile type.
221+
seen_sub_tiles_num_cluser_pins += tmp_sub_tile.num_phy_pins;
222+
}
223+
}
224+
225+
VTR_ASSERT(found_sub_tile);
226+
std::vector<int> pin_num_vec(cluster_sub_tile_isnt_num_pins);
227+
// Pin numbers are assigned such that each instance’s tile-level pins
228+
// occupy a continuous range equal to the total number of tile-level pins for that instance.
229+
// Since we know the starting index, we use std::iota to generate that range.
230+
std::iota(pin_num_vec.begin(), pin_num_vec.end(), seen_sub_tiles_num_cluser_pins);
231+
232+
// Add the intra-cluster-level pins to the list.
233+
std::vector<int> internal_pins = get_cluster_internal_pins(cluster_blk_id);
234+
pin_num_vec.insert(pin_num_vec.end(), internal_pins.begin(), internal_pins.end());
235+
236+
return pin_num_vec;
237+
}
238+
182239
static void set_clusters_pin_chains(const ClusteredNetlist& clb_nlist,
183240
vtr::vector<ClusterBlockId, t_cluster_pin_chain>& pin_chains,
184241
bool is_flat) {

vpr/src/util/vpr_utils.cpp

Lines changed: 0 additions & 47 deletions
Original file line numberDiff line numberDiff line change
@@ -1906,53 +1906,6 @@ std::vector<int> get_cluster_netlist_intra_tile_pins_at_loc(const t_physical_til
19061906
return pin_num_vec;
19071907
}
19081908

1909-
std::vector<int> get_cluster_block_pins(t_physical_tile_type_ptr physical_tile,
1910-
ClusterBlockId cluster_blk_id,
1911-
int abs_cap) {
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 t_sub_tile& 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-
}
1941-
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);
1948-
1949-
// Add the intra-cluster-level pins to the list.
1950-
std::vector<int> internal_pins = get_cluster_internal_pins(cluster_blk_id);
1951-
pin_num_vec.insert(pin_num_vec.end(), internal_pins.begin(), internal_pins.end());
1952-
1953-
return pin_num_vec;
1954-
}
1955-
19561909
t_arch_switch_inf create_internal_arch_sw(float delay) {
19571910
t_arch_switch_inf arch_switch_inf;
19581911
arch_switch_inf.set_type(e_switch_type::MUX);

vpr/src/util/vpr_utils.h

Lines changed: 0 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -328,15 +328,6 @@ std::vector<int> get_cluster_netlist_intra_tile_pins_at_loc(const t_physical_til
328328
const vtr::vector<ClusterBlockId, t_cluster_pin_chain>& pin_chains,
329329
const vtr::vector<ClusterBlockId, std::unordered_set<int>>& pin_chains_num,
330330
t_physical_tile_type_ptr physical_type);
331-
/**
332-
* @brief Returns the list of pins (both cluster-level and intra-cluster-level) of the given cluster block.
333-
* @param physical_tile The physical tile type that the cluster block is mapped to.
334-
* @param cluster_blk_id The cluster block ID.
335-
* @param abs_cap The absolute capacity number of the sub-tile that the cluster block is mapped to.
336-
*/
337-
std::vector<int> get_cluster_block_pins(t_physical_tile_type_ptr physical_tile,
338-
ClusterBlockId cluster_blk_id,
339-
int abs_cap);
340331

341332
t_arch_switch_inf create_internal_arch_sw(float delay);
342333

0 commit comments

Comments
 (0)