Skip to content

Commit 3c0fe91

Browse files
add is_root_location to grid
1 parent 787c613 commit 3c0fe91

File tree

3 files changed

+18
-29
lines changed

3 files changed

+18
-29
lines changed

libs/libarchfpga/src/device_grid.h

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -80,6 +80,10 @@ class DeviceGrid {
8080
inline int get_height_offset(const t_physical_tile_loc& tile_loc) const {
8181
return grid_[tile_loc.layer_num][tile_loc.x][tile_loc.y].height_offset;
8282
}
83+
///@brief Returns true if the given location is the root location (bottom left corner) of a tile.
84+
inline bool is_root_location(const t_physical_tile_loc& tile_loc) const {
85+
return get_width_offset(tile_loc) == 0 && get_height_offset(tile_loc) == 0;
86+
}
8387

8488
///@brief Returns a rectangle which represents the bounding box of the tile at the given location.
8589
inline vtr::Rect<int> get_tile_bb(const t_physical_tile_loc& tile_loc) const {

libs/librrgraph/src/base/rr_node_types.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -66,7 +66,7 @@ typedef uint16_t t_edge_size;
6666
/**
6767
* @brief An iterator that dereferences to an edge index
6868
*
69-
* Used inconjunction with vtr::Range to return ranges of edge indices
69+
* Used in conjunction with vtr::Range to return ranges of edge indices
7070
*/
7171
class edge_idx_iterator {
7272
public:
@@ -101,7 +101,7 @@ typedef vtr::Range<edge_idx_iterator> edge_idx_range;
101101
typedef std::vector<std::map<int, int>> t_arch_switch_fanin;
102102

103103
/*
104-
* Reistance/Capacitance data for an RR Nodes
104+
* Resistance/Capacitance data for an RR Nodes
105105
*
106106
* In practice many RR nodes have the same values, so they are fly-weighted
107107
* to keep t_rr_node small. Each RR node holds an rc_index which allows

vpr/src/route/rr_graph2.cpp

Lines changed: 12 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -1269,17 +1269,14 @@ static void load_block_rr_indices(RRGraphBuilder& rr_graph_builder,
12691269
for (int x = 0; x < (int)grid.width(); x++) {
12701270
for (int y = 0; y < (int)grid.height(); y++) {
12711271
//Process each block from its root location
1272-
if (grid.get_width_offset({x, y, layer}) == 0 && grid.get_height_offset({x, y, layer}) == 0) {
1273-
t_physical_tile_type_ptr physical_type = grid.get_physical_type({x,
1274-
y,
1275-
layer});
1272+
if (grid.is_root_location({x, y, layer})) {
1273+
t_physical_tile_type_ptr physical_type = grid.get_physical_type({x, y, layer});
1274+
12761275
//Assign indices for SINKs and SOURCEs
12771276
// Note that SINKS/SOURCES have no side, so we always use side 0
1278-
std::vector<int> class_num_vec;
1279-
std::vector<int> pin_num_vec;
1277+
std::vector<int> class_num_vec = get_tile_root_classes(physical_type);
1278+
std::vector<int> pin_num_vec = get_tile_root_pins(physical_type);
12801279

1281-
class_num_vec = get_tile_root_classes(physical_type);
1282-
pin_num_vec = get_tile_root_pins(physical_type);
12831280
add_classes_spatial_lookup(rr_graph_builder,
12841281
physical_type,
12851282
class_num_vec,
@@ -1376,17 +1373,14 @@ static void add_pins_spatial_lookup(RRGraphBuilder& rr_graph_builder,
13761373
}
13771374
}
13781375

1379-
for (auto pin_num : pin_num_vec) {
1376+
for (const int pin_num : pin_num_vec) {
13801377
bool assigned_to_rr_node = false;
1381-
std::vector<int> x_offset;
1382-
std::vector<int> y_offset;
1383-
std::vector<e_side> pin_sides;
1384-
std::tie(x_offset, y_offset, pin_sides) = get_pin_coordinates(physical_type_ptr, pin_num, wanted_sides);
1385-
auto pin_type = get_pin_type_from_pin_physical_num(physical_type_ptr, pin_num);
1378+
const auto [x_offset, y_offset, pin_sides] = get_pin_coordinates(physical_type_ptr, pin_num, wanted_sides);
1379+
e_pin_type pin_type = get_pin_type_from_pin_physical_num(physical_type_ptr, pin_num);
13861380
for (int pin_coord_idx = 0; pin_coord_idx < (int)pin_sides.size(); pin_coord_idx++) {
13871381
int x_tile = root_x + x_offset[pin_coord_idx];
13881382
int y_tile = root_y + y_offset[pin_coord_idx];
1389-
auto side = pin_sides[pin_coord_idx];
1383+
e_side side = pin_sides[pin_coord_idx];
13901384
if (pin_type == DRIVER) {
13911385
rr_graph_builder.node_lookup().add_node(RRNodeId(*index), layer, x_tile, y_tile, OPIN, pin_num, side);
13921386
assigned_to_rr_node = true;
@@ -1429,8 +1423,8 @@ static void add_classes_spatial_lookup(RRGraphBuilder& rr_graph_builder,
14291423
}
14301424
}
14311425

1432-
for (auto class_num : class_num_vec) {
1433-
auto class_type = get_class_type_from_class_physical_num(physical_type_ptr, class_num);
1426+
for (const int class_num : class_num_vec) {
1427+
e_pin_type class_type = get_class_type_from_class_physical_num(physical_type_ptr, class_num);
14341428
e_rr_type node_type = SINK;
14351429
if (class_type == DRIVER) {
14361430
node_type = SOURCE;
@@ -1451,16 +1445,7 @@ static void add_classes_spatial_lookup(RRGraphBuilder& rr_graph_builder,
14511445
}
14521446
}
14531447

1454-
/* As the rr_indices builders modify a local copy of indices, use the local copy in the builder
1455-
* TODO: these building functions should only talk to a RRGraphBuilder object
1456-
* The biggest and fatal issue is
1457-
* - the rr_graph2.h is included in the rr_graph_storage.h,
1458-
* which is included in the rr_graph_builder.h
1459-
* If we include rr_graph_builder.h in rr_graph2.h, this creates a loop
1460-
* for C++ compiler to identify data structures, which cannot be solved!!!
1461-
* This will block us when putting the RRGraphBuilder object as an input arguement
1462-
* of this function
1463-
*/
1448+
/* As the rr_indices builders modify a local copy of indices, use the local copy in the builder */
14641449
void alloc_and_load_rr_node_indices(RRGraphBuilder& rr_graph_builder,
14651450
const t_chan_width* nodes_per_chan,
14661451
const DeviceGrid& grid,

0 commit comments

Comments
 (0)