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
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@
#include "side_manager.h"

#include "vpr_utils.h"
#include "physical_types_util.h"
#include "rr_graph_view_util.h"
#include "tileable_rr_graph_utils.h"
#include "rr_graph_builder_utils.h"
Expand Down Expand Up @@ -1723,49 +1724,67 @@ void build_direct_connections_for_one_gsb(const RRGraphView& rr_graph,
/* get every opin in the range */
for (int opin = min_index; opin <= max_index; ++opin) {
int offset = opin - min_index;
//Capacity location determined by pin number relative to pins per capacity instance
auto [z, relative_opin] = get_capacity_location_from_physical_pin(grid_type, opin);
VTR_ASSERT(z >= 0 && z < grid_type->capacity);

if ((to_grid_coordinate.x() < grids.width() - 1)
&& (to_grid_coordinate.y() < grids.height() - 1)) {
int ipin = UNDEFINED;
int relative_ipin = UNDEFINED;
if (clb_to_clb_directs[i].to_clb_pin_start_index
> clb_to_clb_directs[i].to_clb_pin_end_index) {
if (true == swap) {
ipin = clb_to_clb_directs[i].to_clb_pin_end_index + offset;
relative_ipin = clb_to_clb_directs[i].to_clb_pin_end_index + offset;
} else {
ipin = clb_to_clb_directs[i].to_clb_pin_start_index - offset;
relative_ipin = clb_to_clb_directs[i].to_clb_pin_start_index - offset;
}
} else {
if (true == swap) {
ipin = clb_to_clb_directs[i].to_clb_pin_end_index - offset;
relative_ipin = clb_to_clb_directs[i].to_clb_pin_end_index - offset;
} else {
ipin = clb_to_clb_directs[i].to_clb_pin_start_index + offset;
relative_ipin = clb_to_clb_directs[i].to_clb_pin_start_index + offset;
}
}

/* Get the pin index in the rr_graph */
t_physical_tile_loc from_tile_loc(from_grid_coordinate.x(), from_grid_coordinate.y(), layer);
int from_grid_width_ofs = grids.get_width_offset(from_tile_loc);
int from_grid_height_ofs = grids.get_height_offset(from_tile_loc);
t_physical_tile_loc to_tile_loc(to_grid_coordinate.x(), to_grid_coordinate.y(), layer);
int to_grid_width_ofs = grids.get_width_offset(to_tile_loc);
int to_grid_height_ofs = grids.get_height_offset(to_tile_loc);

/* Find the side of grid pins, the pin location should be unique!
* Pin location is required by searching a node in rr_graph
*/
std::vector<e_side> opin_grid_side = find_grid_pin_sides(grids, layer, from_grid_coordinate.x(), from_grid_coordinate.y(), opin);
VTR_ASSERT(1 == opin_grid_side.size());

std::vector<e_side> ipin_grid_side = find_grid_pin_sides(grids, layer, to_grid_coordinate.x(), to_grid_coordinate.y(), ipin);
VTR_ASSERT(1 == ipin_grid_side.size());
std::vector<e_side> opin_grid_side = find_grid_pin_sides(grids, layer, from_grid_coordinate.x() + grid_type->pin_width_offset[opin], from_grid_coordinate.y() + grid_type->pin_height_offset[opin], opin);
if (1 != opin_grid_side.size()) {
VPR_FATAL_ERROR(VPR_ERROR_ARCH, "[Arch LINE %d] From pin (index=%d) of direct connection '%s' does not exist on any side of the programmable block '%s'.\n", directs[i].line, opin, directs[i].from_pin.c_str());
}

/* directs[i].sub_tile_offset is added to from_capacity(z) to get the target_capacity */
int to_subtile_cap = z + directs[i].sub_tile_offset;
/* Iterate over all sub_tiles to get the sub_tile which the target_cap belongs to. */
const t_sub_tile* to_sub_tile = nullptr;
for (const t_sub_tile& sub_tile : to_grid_type->sub_tiles) {
if (sub_tile.capacity.is_in_range(to_subtile_cap)) {
to_sub_tile = &sub_tile;
break;
}
}
VTR_ASSERT(to_sub_tile != nullptr);
if (relative_ipin >= to_sub_tile->num_phy_pins) continue;
// If this block has capacity > 1 then the pins of z position > 0 are offset
// by the number of pins per capacity instance
int ipin = get_physical_pin_from_capacity_location(to_grid_type, relative_ipin, to_subtile_cap);
std::vector<e_side> ipin_grid_side = find_grid_pin_sides(grids, layer, to_grid_coordinate.x() + to_grid_type->pin_width_offset[ipin], to_grid_coordinate.y() + to_grid_type->pin_height_offset[ipin], ipin);
if (1 != ipin_grid_side.size()) {
VPR_FATAL_ERROR(VPR_ERROR_ARCH, "[Arch LINE %d] To pin (index=%d) of direct connection '%s' does not exist on any side of the programmable block '%s'.\n", directs[i].line, relative_ipin, directs[i].to_pin.c_str());
}

RRNodeId opin_node_id = rr_graph.node_lookup().find_node(layer,
from_grid_coordinate.x() - from_grid_width_ofs,
from_grid_coordinate.y() - from_grid_height_ofs,
from_grid_coordinate.x() + grid_type->pin_width_offset[opin],
from_grid_coordinate.y() + grid_type->pin_height_offset[opin],
e_rr_type::OPIN, opin, opin_grid_side[0]);
RRNodeId ipin_node_id = rr_graph.node_lookup().find_node(layer,
to_grid_coordinate.x() - to_grid_width_ofs,
to_grid_coordinate.y() - to_grid_height_ofs,
to_grid_coordinate.x() + to_grid_type->pin_width_offset[ipin],
to_grid_coordinate.y() + to_grid_type->pin_height_offset[ipin],
e_rr_type::IPIN, ipin, ipin_grid_side[0]);

/* add edges to the opin_node */
Expand Down
Loading