Skip to content

Commit b51b50f

Browse files
add get_root_location + pass t_physical_tile_loc instead of 3 integers
1 parent 5cae764 commit b51b50f

14 files changed

+418
-581
lines changed

libs/libarchfpga/src/device_grid.h

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -53,7 +53,8 @@ class DeviceGrid {
5353
void clear();
5454

5555
/**
56-
* @brief Return the number of instances of the specified tile type on the specified layer. If the layer_num is -1, return the total number of instances of the specified tile type on all layers.
56+
* @brief Return the number of instances of the specified tile type on the specified layer.
57+
* If the layer_num is -1, return the total number of instances of the specified tile type on all layers.
5758
* @note This function should be used if count_instances() is called in the constructor.
5859
*/
5960
size_t num_instances(t_physical_tile_type_ptr type, int layer_num) const;
@@ -83,6 +84,16 @@ class DeviceGrid {
8384
return get_width_offset(tile_loc) == 0 && get_height_offset(tile_loc) == 0;
8485
}
8586

87+
///@brief Given a location, return the root location (bottom-left corner) of the tile instance
88+
inline t_physical_tile_loc get_root_location(const t_physical_tile_loc& tile_loc) const {
89+
t_physical_tile_loc root_loc;
90+
root_loc.layer_num = tile_loc.layer_num;
91+
root_loc.x = tile_loc.x - get_width_offset(tile_loc);
92+
root_loc.y = tile_loc.y - get_height_offset(tile_loc);
93+
return root_loc;
94+
}
95+
96+
8697
///@brief Returns a rectangle which represents the bounding box of the tile at the given location.
8798
inline vtr::Rect<int> get_tile_bb(const t_physical_tile_loc& tile_loc) const {
8899
t_physical_tile_type_ptr tile_type = get_physical_type(tile_loc);

libs/libarchfpga/src/physical_types_util.cpp

Lines changed: 10 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -78,7 +78,6 @@ static std::vector<int> get_pb_pin_src_pins(t_physical_tile_type_ptr physical_ty
7878
const t_pb_graph_pin* pin);
7979

8080
/**
81-
*
8281
* @param physical_type physical tile which pin belongs to
8382
* @param sub_tile sub_tile in which physical tile located
8483
* @param logical_block logical block mapped to the sub_tile
@@ -108,20 +107,12 @@ static t_pb_graph_pin* get_mutable_tile_pin_pb_pin(t_physical_tile_type* physica
108107
int pin_physical_num);
109108

110109
/**
111-
*
112-
* @param physical_tile
113-
* @param class_physical_num
114110
* @return A vector containing all of the parent pb_graph_nodes and the pb_graph_node of the class_physical_num itself
115111
*/
116112
static std::vector<const t_pb_graph_node*> get_sink_hierarchical_parents(t_physical_tile_type_ptr physical_tile,
117113
int class_physical_num);
118114

119115
/**
120-
*
121-
* @param physical_tile
122-
* @param pin_physcial_num
123-
* @param ref_sink_num
124-
* @param sink_grp
125116
* @return Return zero if the ref_sink_num is not reachable by pin_physical_num, otherwise return the number sinks in sink_grp
126117
* reachable by pin_physical_num
127118
*/
@@ -618,21 +609,21 @@ bool is_opin(int ipin, t_physical_tile_type_ptr type) {
618609
return false;
619610
}
620611

621-
bool is_pin_conencted_to_layer(t_physical_tile_type_ptr type, int ipin, int from_layer, int to_layer, int num_of_avail_layer) {
622-
if (type->is_empty()) { //if type is empty, there is no pins
612+
bool is_pin_conencted_to_layer(t_physical_tile_type_ptr type, int ipin, int from_layer, int to_layer, unsigned num_of_avail_layer) {
613+
// if type is empty, there is no pins
614+
if (type->is_empty()) {
623615
return false;
624616
}
625-
//ipin should be a valid pin in physical type
617+
618+
// ipin should be a valid pin in physical type
626619
VTR_ASSERT(ipin < type->num_pins);
627-
int pin_layer = from_layer + type->pin_layer_offset[ipin];
628-
//if pin_offset specifies a layer that doesn't exist in arch file, we do a wrap around
620+
unsigned pin_layer = from_layer + type->pin_layer_offset[ipin];
621+
// if pin_offset specifies a layer that doesn't exist in arch file, we do a wrap around
629622
pin_layer = (pin_layer < num_of_avail_layer) ? pin_layer : pin_layer % num_of_avail_layer;
630-
if (from_layer == to_layer || pin_layer == to_layer) {
623+
if (from_layer == to_layer || int(pin_layer) == to_layer) {
631624
return true;
632-
} else {
633-
return false;
634625
}
635-
//not reachable
626+
636627
return false;
637628
}
638629

@@ -643,7 +634,7 @@ std::string block_type_pin_index_to_name(t_physical_tile_type_ptr type, int pin_
643634
std::string pin_name = type->name;
644635

645636
int sub_tile_index, inst_num, logical_num, pb_type_idx;
646-
std::tie<int, int, int, int, int>(pin_index, sub_tile_index, inst_num, logical_num, pb_type_idx) = get_pin_index_for_inst(type, pin_physical_num, is_flat);
637+
std::tie(pin_index, sub_tile_index, inst_num, logical_num, pb_type_idx) = get_pin_index_for_inst(type, pin_physical_num, is_flat);
647638
if (type->sub_tiles[sub_tile_index].capacity.total() > 1) {
648639
pin_name += "[" + std::to_string(inst_num) + "]";
649640
}

libs/libarchfpga/src/physical_types_util.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -116,7 +116,7 @@
116116
bool is_opin(int ipin, t_physical_tile_type_ptr type);
117117

118118
///@brief Returns true if the specified pin is located at "from_layer" and it is connected to "to_layer"
119-
bool is_pin_conencted_to_layer(t_physical_tile_type_ptr type, int ipin, int from_layer, int to_layer, int num_of_avail_layer);
119+
bool is_pin_conencted_to_layer(t_physical_tile_type_ptr type, int ipin, int from_layer, int to_layer, unsigned num_of_avail_layer);
120120

121121
/**
122122
* @brief Returns the corresponding physical pin based on the input parameters:

vpr/src/route/overuse_report.cpp

Lines changed: 20 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -43,17 +43,13 @@ static void log_single_overused_node_status(int overuse_index, RRNodeId inode);
4343
*
4444
* @param os The output stream to write the information to.
4545
* @param physical_type The physical type of the block.
46-
* @param layer The layer number of the block.
47-
* @param root_x The x coordinate of the root of the block.
48-
* @param root_y The y coordinate of the root of the block.
46+
* @param root_loc The coordinates of the root of the block.
4947
* @param pin_physical_num The physical number of the pin.
5048
* @param rr_node_to_net_map A map of RR nodes to the nets that pass through them.
5149
*/
5250
static void print_block_pins_nets(std::ostream& os,
5351
t_physical_tile_type_ptr physical_type,
54-
int layer,
55-
int root_x,
56-
int root_y,
52+
const t_physical_tile_loc& root_loc,
5753
int pin_physical_num,
5854
const std::map<RRNodeId, std::set<ParentNetId>>& rr_node_to_net_map);
5955
/**
@@ -231,31 +227,29 @@ static void report_overused_ipin_opin(std::ostream& os,
231227
const auto& rr_graph = device_ctx.rr_graph;
232228
const auto& place_ctx = g_vpr_ctx.placement();
233229

234-
auto grid_x = rr_graph.node_xlow(node_id);
235-
auto grid_y = rr_graph.node_ylow(node_id);
236-
auto grid_layer = rr_graph.node_layer(node_id);
230+
t_physical_tile_loc grid_loc;
231+
grid_loc.x = rr_graph.node_xlow(node_id);
232+
grid_loc.y = rr_graph.node_ylow(node_id);
233+
grid_loc.layer_num = rr_graph.node_layer(node_id);
234+
const t_physical_tile_type_ptr physical_type = device_ctx.grid.get_physical_type(grid_loc);
237235

238-
VTR_ASSERT_MSG(
239-
grid_x == rr_graph.node_xhigh(node_id) && grid_y == rr_graph.node_yhigh(node_id),
240-
"Non-track RR node should not span across multiple grid blocks.");
236+
VTR_ASSERT_MSG(grid_loc.x == rr_graph.node_xhigh(node_id) && grid_loc.y == rr_graph.node_yhigh(node_id),
237+
"Non-track RR node should not span across multiple grid blocks.");
241238

242239
os << "Pin physical number = " << rr_graph.node_pin_num(node_id) << '\n';
243240
if (is_inter_cluster_node(rr_graph, node_id)) {
244241
os << "On Tile Pin"
245242
<< "\n";
246243
} else {
247-
auto pb_type_name = get_pb_graph_node_from_pin_physical_num(device_ctx.grid.get_physical_type({grid_x, grid_y, grid_layer}),
244+
auto pb_type_name = get_pb_graph_node_from_pin_physical_num(device_ctx.grid.get_physical_type(grid_loc),
248245
rr_graph.node_ptc_num(node_id))
249246
->pb_type->name;
250-
auto pb_pin = get_pb_pin_from_pin_physical_num(device_ctx.grid.get_physical_type({grid_x, grid_y, grid_layer}),
251-
rr_graph.node_ptc_num(node_id));
247+
auto pb_pin = get_pb_pin_from_pin_physical_num(physical_type, rr_graph.node_ptc_num(node_id));
252248
os << "Intra-Tile Pin - Port : " << pb_pin->port->name << " - PB Type : " << std::string(pb_type_name) << "\n";
253249
}
254250
print_block_pins_nets(os,
255-
device_ctx.grid.get_physical_type({grid_x, grid_y, grid_layer}),
256-
grid_layer,
257-
grid_x - device_ctx.grid.get_width_offset({grid_x, grid_y, grid_layer}),
258-
grid_y - device_ctx.grid.get_height_offset({grid_x, grid_y, grid_layer}),
251+
physical_type,
252+
device_ctx.grid.get_root_location(grid_loc),
259253
rr_graph.node_ptc_num(node_id),
260254
rr_node_to_net_map);
261255
os << "Side = " << rr_graph.node_side_string(node_id) << "\n\n";
@@ -264,19 +258,19 @@ static void report_overused_ipin_opin(std::ostream& os,
264258
const auto& clb_nlist = g_vpr_ctx.clustering().clb_nlist;
265259
const auto& grid_info = place_ctx.grid_blocks();
266260

267-
os << "Grid location: X = " << grid_x << ", Y = " << grid_y << '\n';
268-
os << "Number of blocks currently occupying this grid location = " << grid_info.get_usage({grid_x, grid_y, grid_layer}) << '\n';
261+
os << "Grid location: X = " << grid_loc.x << ", Y = " << grid_loc.y << '\n';
262+
os << "Number of blocks currently occupying this grid location = " << grid_info.get_usage(grid_loc) << '\n';
269263

270264
size_t iblock = 0;
271-
for (int isubtile = 0; isubtile < (int)grid_info.num_blocks_at_location({grid_x, grid_y, grid_layer}); ++isubtile) {
265+
for (int isubtile = 0; isubtile < (int)grid_info.num_blocks_at_location(grid_loc); ++isubtile) {
272266
//Check if there is a valid block at this subtile location
273-
if (grid_info.is_sub_tile_empty({grid_x, grid_y, grid_layer}, isubtile)) {
267+
if (grid_info.is_sub_tile_empty(grid_loc, isubtile)) {
274268
continue;
275269
}
276270

277271
//Print out the block index, name and type
278272
// TODO: Needs to be updated when RR Graph Nodes know their layer_num
279-
ClusterBlockId block_id = grid_info.block_at_location({grid_x, grid_y, isubtile, grid_layer});
273+
ClusterBlockId block_id = grid_info.block_at_location({grid_loc, isubtile});
280274
os << "Block #" << iblock << ": ";
281275
os << "Block name = " << clb_nlist.block_pb(block_id)->name << ", ";
282276
os << "Block type = " << clb_nlist.block_type(block_id)->name << '\n';
@@ -459,9 +453,7 @@ static void log_single_overused_node_status(int overuse_index, RRNodeId node_id)
459453

460454
static void print_block_pins_nets(std::ostream& os,
461455
t_physical_tile_type_ptr physical_type,
462-
int layer,
463-
int root_x,
464-
int root_y,
456+
const t_physical_tile_loc& root_loc,
465457
int pin_physical_num,
466458
const std::map<RRNodeId, std::set<ParentNetId>>& rr_node_to_net_map) {
467459
const auto& rr_graph = g_vpr_ctx.device().rr_graph;
@@ -489,7 +481,7 @@ static void print_block_pins_nets(std::ostream& os,
489481

490482
for (int pin = pin_num_range.low; pin <= pin_num_range.high; pin++) {
491483
e_rr_type rr_type = (get_pin_type_from_pin_physical_num(physical_type, pin) == e_pin_type::DRIVER) ? e_rr_type::OPIN : e_rr_type::IPIN;
492-
RRNodeId node_id = get_pin_rr_node_id(rr_graph.node_lookup(), physical_type, layer, root_x, root_y, pin);
484+
RRNodeId node_id = get_pin_rr_node_id(rr_graph.node_lookup(), physical_type, root_loc, pin);
493485
// When flat router is enabled, RR Node chains collapse into a single node. Thus, when
494486
// looking up the RR Node ID, it may return an invalid node ID. In this case, we skip
495487
// this pin.

vpr/src/route/route_utils.cpp

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -460,7 +460,12 @@ vtr::vector<ParentNetId, std::vector<std::unordered_map<RRNodeId, int>>> set_net
460460
std::for_each(sink_grp.begin(), sink_grp.end(), [&rr_graph](int& sink_rr_num) {
461461
sink_rr_num = rr_graph.node_ptc_num(RRNodeId(sink_rr_num));
462462
});
463-
auto physical_type = device_ctx.grid.get_physical_type({blk_loc.loc.x, blk_loc.loc.y, blk_loc.loc.layer});
463+
464+
t_physical_tile_loc grid_loc;
465+
grid_loc.x = blk_loc.loc.x;
466+
grid_loc.y = blk_loc.loc.y;
467+
grid_loc.layer_num = blk_loc.loc.layer;
468+
t_physical_tile_type_ptr physical_type = device_ctx.grid.get_physical_type(grid_loc);
464469
// Get the choke points of the sink corresponds to pin_count given the sink group
465470
auto sink_choking_spots = get_sink_choking_points(physical_type,
466471
rr_graph.node_ptc_num(RRNodeId(net_rr_terminal[net_id][pin_count])),
@@ -471,9 +476,7 @@ vtr::vector<ParentNetId, std::vector<std::unordered_map<RRNodeId, int>>> set_net
471476
int num_reachable_sinks = choking_spot.second;
472477
auto pin_rr_node_id = get_pin_rr_node_id(rr_graph.node_lookup(),
473478
physical_type,
474-
blk_loc.loc.layer,
475-
blk_loc.loc.x,
476-
blk_loc.loc.y,
479+
grid_loc,
477480
pin_physical_num);
478481
if (pin_rr_node_id != RRNodeId::INVALID()) {
479482
choking_spots[net_id][pin_count].insert(std::make_pair(pin_rr_node_id, num_reachable_sinks));

0 commit comments

Comments
 (0)