Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion libs/libarchfpga/src/switchblock_types.h
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,8 @@ enum e_directionality {
/**
* @brief At the intersection of routing channels, left, right, top and bottom specify the x- and y-directed channels
* while above and under specify the switch block wires one a layer above or below the current one. above and below
* are only used for multi-layer FPGAs.
* are only used for multi-layer FPGAs. Note that the order of 2D sides is important, as it corresponds to the bit
* order in t_rr_node_data::dir_side_.sides.
*/
enum e_side : unsigned char {
TOP = 0,
Expand Down
15 changes: 15 additions & 0 deletions libs/librrgraph/src/base/check_rr_graph.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -473,6 +473,8 @@ void check_rr_node(const RRGraphView& rr_graph,

e_pin_type class_type = e_pin_type::OPEN;
int class_num_pins = -1;
std::vector<e_side> rr_graph_sides;
std::vector<e_side> arch_side_vec;
switch (rr_type) {
case e_rr_type::SOURCE:
case e_rr_type::SINK:
Expand Down Expand Up @@ -511,6 +513,19 @@ void check_rr_node(const RRGraphView& rr_graph,
VPR_FATAL_ERROR(VPR_ERROR_ROUTE,
"in check_rr_node: inode %d (type %d) has a capacity of %d.\n", inode, rr_type, capacity);
}
rr_graph_sides = rr_graph.node_sides(rr_node);
std::tie(std::ignore, std::ignore, arch_side_vec) = get_pin_coordinates(type, ptc_num, std::vector<e_side>(TOTAL_2D_SIDES.begin(), TOTAL_2D_SIDES.end()));
// sides in the architecture are a superset of the sides for a pin in RR Graph. We iterate over the sides stored
// in the RR Graph to ensure that all of them also exist in the architecture.
for (size_t i = 0; i < rr_graph_sides.size(); i++) {
if (std::find(arch_side_vec.begin(), arch_side_vec.end(), rr_graph_sides[i]) == arch_side_vec.end()) {
VPR_FATAL_ERROR(VPR_ERROR_ROUTE,
"in check_rr_node: inode %d (type %d) has a different side '%s' in the RR graph and the architecture.\n",
inode,
rr_type,
TOTAL_2D_SIDE_STRINGS[rr_graph_sides[i]]);
}
}
break;

case e_rr_type::CHANX:
Expand Down
13 changes: 12 additions & 1 deletion libs/librrgraph/src/base/rr_graph_storage.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -631,6 +631,17 @@ const std::string& t_rr_graph_storage::node_direction_string(RRNodeId id) const
return CONST_DIRECTION_STRING[int_direction];
}


const std::vector<e_side> t_rr_graph_storage::node_sides(RRNodeId id) const {
std::vector<e_side> sides;
for (const e_side& side : TOTAL_2D_SIDES) {
if (is_node_on_specific_side(id, side)) {
sides.push_back(side);
}
}
return sides;
}

const char* t_rr_graph_storage::node_side_string(RRNodeId id) const {
for (const e_side& side : TOTAL_2D_SIDES) {
if (is_node_on_specific_side(id, side)) {
Expand Down Expand Up @@ -807,7 +818,7 @@ void t_rr_graph_storage::set_node_direction(RRNodeId id, Direction new_direction

void t_rr_graph_storage::add_node_side(RRNodeId id, e_side new_side) {
if (node_type(id) != e_rr_type::IPIN && node_type(id) != e_rr_type::OPIN) {
VTR_LOG_ERROR("Attempted to set RR node 'side' for non-channel type '%s'", node_type_string(id));
VTR_LOG_ERROR("Attempted to set RR node 'side' for non-pin type '%s'", node_type_string(id));
}
std::bitset<NUM_2D_SIDES> side_bits = node_storage_[id].dir_side_.sides;
side_bits[size_t(new_side)] = true;
Expand Down
3 changes: 3 additions & 0 deletions libs/librrgraph/src/base/rr_graph_storage.h
Original file line number Diff line number Diff line change
Expand Up @@ -220,6 +220,9 @@ class t_rr_graph_storage {
id, side);
}

/** @brief Get the sides where the node locates on. */
const std::vector<e_side> node_sides(RRNodeId id) const;

/* FIXME: This function should be DEPRECATED!
* Developers can easily use the following codes with more flexibility
*
Expand Down
5 changes: 5 additions & 0 deletions libs/librrgraph/src/base/rr_graph_view.h
Original file line number Diff line number Diff line change
Expand Up @@ -432,6 +432,11 @@ class RRGraphView {
return node_storage_.is_node_on_specific_side(node, side);
}

/** @brief Get the sides where the node locates on. */
inline const std::vector<e_side> node_sides(RRNodeId node) const {
return node_storage_.node_sides(node);
}

/** @brief Return a string representing the side of a routing resource node.
*/
inline const char* node_side_string(RRNodeId node) const {
Expand Down
3 changes: 3 additions & 0 deletions vpr/src/util/vpr_utils.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1679,6 +1679,9 @@ RRNodeId get_pin_rr_node_id(const RRSpatialLookup& rr_spatial_lookup,
std::tie(x_offset, y_offset, pin_sides) = get_pin_coordinates(physical_tile, pin_physical_num, std::vector<e_side>(TOTAL_2D_SIDES.begin(), TOTAL_2D_SIDES.end()));
VTR_ASSERT(!x_offset.empty());
RRNodeId node_id = RRNodeId::INVALID();
// Pin sides from get_pin_coordinates are those specified in the architecture. However, when
// adding pins to the RR Graph, not all sides may be included (depending on the block’s location).
// Therefore, we iterate over all sides to find a valid node id.
for (int coord_idx = 0; coord_idx < (int)pin_sides.size(); coord_idx++) {
node_id = rr_spatial_lookup.find_node(root_loc.layer_num,
root_loc.x + x_offset[coord_idx],
Expand Down