diff --git a/openfpga/src/repack/repack.cpp b/openfpga/src/repack/repack.cpp index 577dd00cd..562a41f44 100644 --- a/openfpga/src/repack/repack.cpp +++ b/openfpga/src/repack/repack.cpp @@ -11,6 +11,7 @@ #include "build_physical_lb_rr_graph.h" #include "lb_router.h" #include "lb_router_utils.h" +#include "pb_graph_utils.h" #include "pb_type_utils.h" #include "physical_pb_utils.h" #include "repack.h" @@ -290,7 +291,7 @@ static std::vector find_pb_route_by_atom_net( if (pb_route_indices.empty()) { for (int pin : candidate_pool) { - if (pb->pb_route.at(pin).pb_graph_pin->parent_node->is_root() && source_pb_pin->port->type == pb->pb_route.at(pin).pb_graph_pin->port->type) { + if (pb->pb_route.at(pin).pb_graph_pin->parent_node->is_root() && is_pb_graph_pins_share_interc(source_pb_pin, pb->pb_route.at(pin).pb_graph_pin)) { pb_route_indices.push_back(pin); } } diff --git a/openfpga/src/utils/pb_graph_utils.cpp b/openfpga/src/utils/pb_graph_utils.cpp index 4b80bd596..4746535fd 100644 --- a/openfpga/src/utils/pb_graph_utils.cpp +++ b/openfpga/src/utils/pb_graph_utils.cpp @@ -70,4 +70,28 @@ t_interconnect* pb_graph_pin_interc(t_pb_graph_pin* pb_graph_pin, return interc; } +/******************************************************************** + * This function identifies if two pb graph pins share at least one interconnect model + * The two pins should be in the same type of port, for example, both are inputs. + * Each pin may drive a number of outgoing edges while each edge represents different interconnect model + * By iterating over outgoing edges for each pin, common interconnect model may be found + *******************************************************************/ +bool is_pb_graph_pins_share_interc(const t_pb_graph_pin* pinA, const t_pb_graph_pin* pinB) { + if (pinA->port->type != pinB->port->type) { + return false; + } + std::vector pinA_interc_list; + for (auto out_edge : pinA->output_edges) { + if (pinA_interc_list.end() == std::find(pinA_interc_list.begin(), pinA_interc_list.end(), out_edge->interconnect)) { + pinA_interc_list.push_back(out_edge->interconnect); + } + } + for (auto out_edge : pinB->output_edges) { + if (pinA_interc_list.end() != std::find(pinA_interc_list.begin(), pinA_interc_list.end(), out_edge->interconnect)) { + return true; + } + } + return false; +} + } /* end namespace openfpga */ diff --git a/openfpga/src/utils/pb_graph_utils.h b/openfpga/src/utils/pb_graph_utils.h index 209f87b9f..cbe2a096d 100644 --- a/openfpga/src/utils/pb_graph_utils.h +++ b/openfpga/src/utils/pb_graph_utils.h @@ -22,6 +22,8 @@ std::vector pb_graph_pin_inputs( t_interconnect* pb_graph_pin_interc(t_pb_graph_pin* pb_graph_pin, t_mode* selected_mode); +bool is_pb_graph_pins_share_interc(const t_pb_graph_pin* pinA, const t_pb_graph_pin* pinB); + } /* end namespace openfpga */ #endif