From d4e19edc7148e3b93bfd61663808043322bb888b Mon Sep 17 00:00:00 2001 From: tangxifan Date: Mon, 27 Feb 2023 22:31:16 -0800 Subject: [PATCH] [core] finishing up clock rr_graph appending --- .../src/base/clock_network.cpp | 35 +++++++++++++++++++ .../src/base/clock_network.h | 6 ++++ .../src/annotation/append_clock_rr_graph.cpp | 5 ++- .../utils/openfpga_physical_tile_utils.cpp | 3 +- 4 files changed, 47 insertions(+), 2 deletions(-) diff --git a/libs/libclkarchopenfpga/src/base/clock_network.cpp b/libs/libclkarchopenfpga/src/base/clock_network.cpp index ad0848137..2615000bb 100644 --- a/libs/libclkarchopenfpga/src/base/clock_network.cpp +++ b/libs/libclkarchopenfpga/src/base/clock_network.cpp @@ -4,6 +4,8 @@ #include "vtr_assert.h" #include "vtr_log.h" +#include "openfpga_tokenizer.h" +#include "openfpga_port_parser.h" namespace openfpga { // Begin namespace openfpga @@ -235,6 +237,39 @@ std::vector ClockNetwork::spine_taps(const ClockSpineId& spine_id) return spine_taps_[spine_id]; } +std::vector ClockNetwork::spine_flatten_taps(const ClockSpineId& spine_id) const { + VTR_ASSERT(valid_spine_id(spine_id)); + std::vector flatten_taps; + for (const std::string& tap_name : spine_taps_[spine_id]) { + StringToken tokenizer(tap_name); + std::vector pin_tokens = tokenizer.split("."); + if (pin_tokens.size() != 2) { + VTR_LOG_ERROR("Invalid pin name '%s'. Expect .\n", pin_name.c_str()); + exit(1); + } + PortParser tile_parser(pin_tokens[0]); + BasicPort tile_info = tile_parser.port(); + PortParser pin_parser(pin_tokens[1]); + BasicPort pin_info = pin_parser.port(); + if (!tile_info.is_valid()) { + VTR_LOG_ERROR("Invalid pin name '%s' whose subtile index is not valid\n", pin_name.c_str()); + exit(1); + } + if (!pin_info.is_valid()) { + VTR_LOG_ERROR("Invalid pin name '%s' whose pin index is not valid\n", pin_name.c_str()); + exit(1); + } + for (size_t& tile_idx : tile_info.pins()) { + std::string flatten_tile_str = tile_info.get_name() + "[" + std::to_string(tile_idx) + "]"; + for (size_t& pin_idx : pin_info.pins()) { + std::string flatten_pin_str = pin_info.get_name() + "[" + std::to_string(pin_idx) + "]"; + flatten_taps.push_back(flatten_tile_str + "." + flatten_pin_str); + } + } + } + return flatten_taps; +} + ClockSpineId ClockNetwork::find_spine(const std::string& name) const { auto result = spine_name2id_map_.find(name); if (result == spine_name2id_map_.end()) { diff --git a/libs/libclkarchopenfpga/src/base/clock_network.h b/libs/libclkarchopenfpga/src/base/clock_network.h index 9a9cd154a..53e3259c5 100644 --- a/libs/libclkarchopenfpga/src/base/clock_network.h +++ b/libs/libclkarchopenfpga/src/base/clock_network.h @@ -104,7 +104,13 @@ class ClockNetwork { vtr::Point spine_switch_point( const ClockSpineId& spine_id, const ClockSwitchPointId& switch_point_id) const; + /* Return the original list of tap pins that is in storage; useful for parsers */ std::vector spine_taps(const ClockSpineId& spine_id) const; + /* Return the list of flatten tap pins. For example: clb[0:1].clk[2:3] is flatten to + * { clb[0].clk[2], clb[1].clk[2], clb[0].clk[3], clb[1].clk[3] } + * Useful to build clock routing resource graph + */ + std::vector spine_flatten_taps(const ClockSpineId& spine_id) const; /* Find a spine with a given name, if not found, return an valid id, otherwise * return an invalid one */ ClockSpineId find_spine(const std::string& name) const; diff --git a/openfpga/src/annotation/append_clock_rr_graph.cpp b/openfpga/src/annotation/append_clock_rr_graph.cpp index eb501bda1..a2277afa3 100644 --- a/openfpga/src/annotation/append_clock_rr_graph.cpp +++ b/openfpga/src/annotation/append_clock_rr_graph.cpp @@ -363,9 +363,12 @@ void try_find_and_add_clock_track2ipin_node(std::vector& des_nodes, const ClockTreeId& clk_tree, const ClockTreePinId& clk_pin) { t_physical_tile_type_ptr grid_type = grids[grid_coord.x()][grid_coord.y()].type; - for (std::string tap_pin_name : clk_ntwk.tap_pin_name(clk_tree, clk_pin)) { + for (std::string tap_pin_name : clk_ntwk.tap_pin_names(clk_tree, clk_pin)) { /* tap pin name could be 'io[5:5].a2f[0]' */ int grid_pin_idx = find_physical_tile_pin_index(grid_type, tap_pin_name); + if (grid_pin_idx == grid_type->num_pins) { + continue; + } RRNodeId des_node = rr_graph_view.node_lookup().find_node(grid_coord.x(), grid_coord.y(), IPIN, grid_pin_idx, pin_side); if (rr_graph_view.valid_node(des_node)) { des_nodes.push_back(des_node); diff --git a/openfpga/src/utils/openfpga_physical_tile_utils.cpp b/openfpga/src/utils/openfpga_physical_tile_utils.cpp index 148808173..18e019ca3 100644 --- a/openfpga/src/utils/openfpga_physical_tile_utils.cpp +++ b/openfpga/src/utils/openfpga_physical_tile_utils.cpp @@ -125,7 +125,8 @@ std::set find_physical_io_tile_located_sides( * which corresponds to the pin 'a2f[1]' of the 5th subtile 'io' in the physical tile *******************************************************************/ int find_physical_tile_pin_index(t_physical_tile_type_ptr physical_tile, std::string pin_name) { - int pin_idx = -1; + /* Deposit an invalid value */ + int pin_idx = physical_tile->num_pins; /* precheck: return unfound pin if the tile name does not match */ StringToken tokenizer(pin_name); std::vector pin_tokens = tokenizer.split(".");