Skip to content

Commit 17fab9f

Browse files
Merge pull request verilog-to-routing#3113 from verilog-to-routing/atom_pin_to_rr_node_id
[VPR][Utils] Add helper function to get RRNodeId from AtomPinId
2 parents b8091a0 + 9522030 commit 17fab9f

File tree

4 files changed

+49
-3
lines changed

4 files changed

+49
-3
lines changed

libs/libarchfpga/src/physical_types.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -709,6 +709,7 @@ struct t_physical_tile_type {
709709

710710
std::unordered_map<int, std::unordered_map<t_logical_block_type_ptr, t_pb_graph_pin*>> on_tile_pin_num_to_pb_pin; // [root_pin_physical_num][logical_block] -> t_pb_graph_pin*
711711
std::unordered_map<int, t_pb_graph_pin*> pin_num_to_pb_pin; // [intra_tile_pin_physical_num] -> t_pb_graph_pin
712+
std::unordered_map<const t_pb_graph_pin*, int> pb_pin_to_pin_num; // [t_pb_graph_pin*] -> intra_tile_pin_physical_num
712713

713714
std::vector<t_fc_specification> fc_specs;
714715

vpr/src/base/SetupVPR.cpp

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -899,9 +899,11 @@ static void add_logical_pin_to_physical_tile(int physical_pin_offset,
899899
t_logical_block_type_ptr logical_block_ptr,
900900
t_physical_tile_type* physical_type) {
901901
for (auto logical_pin_pair : logical_block_ptr->pin_logical_num_to_pb_pin_mapping) {
902-
auto pin_logical_num = logical_pin_pair.first;
903-
auto pb_pin = logical_pin_pair.second;
904-
physical_type->pin_num_to_pb_pin.insert(std::make_pair(pin_logical_num + physical_pin_offset, pb_pin));
902+
int pin_logical_num = logical_pin_pair.first;
903+
t_pb_graph_pin* pb_pin = logical_pin_pair.second;
904+
int pin_physical_num = pin_logical_num + physical_pin_offset;
905+
physical_type->pin_num_to_pb_pin.insert({pin_physical_num, pb_pin});
906+
physical_type->pb_pin_to_pin_num.insert({pb_pin, pin_physical_num});
905907
}
906908
}
907909

vpr/src/util/vpr_utils.cpp

Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1720,6 +1720,41 @@ RRNodeId get_class_rr_node_id(const RRSpatialLookup& rr_spatial_lookup,
17201720
return rr_spatial_lookup.find_node(layer, i, j, node_type, class_physical_num);
17211721
}
17221722

1723+
RRNodeId get_atom_pin_rr_node_id(AtomPinId atom_pin_id) {
1724+
auto& atom_nlist = g_vpr_ctx.atom().netlist();
1725+
auto& atom_lookup = g_vpr_ctx.atom().lookup();
1726+
auto& place_ctx = g_vpr_ctx.placement();
1727+
auto& device_ctx = g_vpr_ctx.device();
1728+
1729+
/*
1730+
* To get the RRNodeId for an atom pin, we need to:
1731+
* 1. Find the atom block that the pin belongs to
1732+
* 2. Find the cluster block that the atom block is a part of
1733+
* 3. Find the physical tile that the cluster block is located on
1734+
* 4. Find the physical pin number of the atom pin (corresponds to ptc number of the RR node)
1735+
* 5. Call get_pin_rr_node_id to get the RRNodeId for the pin
1736+
*/
1737+
1738+
AtomBlockId atom_blk_id = atom_nlist.pin_block(atom_pin_id);
1739+
ClusterBlockId clb_blk_id = atom_lookup.atom_clb(atom_blk_id);
1740+
1741+
t_pl_loc clb_blk_loc = place_ctx.block_locs()[clb_blk_id].loc;
1742+
1743+
t_physical_tile_type_ptr physical_tile = device_ctx.grid.get_physical_type({clb_blk_loc.x, clb_blk_loc.y, clb_blk_loc.layer});
1744+
1745+
const t_pb_graph_pin* atom_pb_pin = atom_lookup.atom_pin_pb_graph_pin(atom_pin_id);
1746+
int pin_physical_num = physical_tile->pb_pin_to_pin_num.at(atom_pb_pin);
1747+
1748+
RRNodeId rr_node_id = get_pin_rr_node_id(device_ctx.rr_graph.node_lookup(),
1749+
physical_tile,
1750+
clb_blk_loc.layer,
1751+
clb_blk_loc.x,
1752+
clb_blk_loc.y,
1753+
pin_physical_num);
1754+
1755+
return rr_node_id;
1756+
}
1757+
17231758
bool node_in_same_physical_tile(RRNodeId node_first, RRNodeId node_second) {
17241759
const auto& device_ctx = g_vpr_ctx.device();
17251760
const auto& rr_graph = device_ctx.rr_graph;

vpr/src/util/vpr_utils.h

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -248,6 +248,14 @@ RRNodeId get_pin_rr_node_id(const RRSpatialLookup& rr_spatial_lookup,
248248
const int root_j,
249249
int pin_physical_num);
250250

251+
/**
252+
* @brief Returns the RR node ID for the given atom pin ID.
253+
* **Warning**: This function should be called only if flat-router is enabled,
254+
* since, otherwise, the routing resources inside clusters are not added to the RR graph.
255+
* @param atom_pin_id The atom pin ID.
256+
*/
257+
RRNodeId get_atom_pin_rr_node_id(AtomPinId atom_pin_id);
258+
251259
RRNodeId get_class_rr_node_id(const RRSpatialLookup& rr_spatial_lookup,
252260
t_physical_tile_type_ptr physical_tile,
253261
const int layer,

0 commit comments

Comments
 (0)