|
12 | 12 | #include "rr_graph_switch_utils.h" |
13 | 13 | #include "check_rr_graph.h" |
14 | 14 |
|
| 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 | + |
15 | 25 | static void set_clusters_pin_chains(const ClusteredNetlist& clb_nlist, |
16 | 26 | vtr::vector<ClusterBlockId, t_cluster_pin_chain>& pin_chains, |
17 | 27 | bool is_flat); |
@@ -179,6 +189,53 @@ static void add_pin_chain(const std::vector<int>& pin_chain, |
179 | 189 | std::vector<std::vector<t_pin_chain_node>>& all_chains, |
180 | 190 | bool is_new_chain); |
181 | 191 |
|
| 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_inst_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& sub_tile: physical_tile->sub_tiles) { |
| 206 | + if (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_inst_num_pins = (sub_tile.num_phy_pins / sub_tile.capacity.total()); |
| 213 | + int rel_cap = sub_tile_index - 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_inst_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 += sub_tile.num_phy_pins; |
| 222 | + } |
| 223 | + } |
| 224 | + |
| 225 | + VTR_ASSERT(found_sub_tile); |
| 226 | + std::vector<int> pin_num_vec(cluster_sub_tile_inst_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 | + |
182 | 239 | static void set_clusters_pin_chains(const ClusteredNetlist& clb_nlist, |
183 | 240 | vtr::vector<ClusterBlockId, t_cluster_pin_chain>& pin_chains, |
184 | 241 | bool is_flat) { |
|
0 commit comments