diff --git a/openfpga/src/repack/lb_router.cpp b/openfpga/src/repack/lb_router.cpp index 277548e18..c1b67b804 100644 --- a/openfpga/src/repack/lb_router.cpp +++ b/openfpga/src/repack/lb_router.cpp @@ -39,6 +39,15 @@ LbRouter::LbRouter(const LbRRGraph& lb_rr_graph, t_logical_block_type_ptr lb_typ /************************************************** * Public Accessors *************************************************/ +LbRouter::net_range LbRouter::nets() const { + return vtr::make_range(lb_net_ids_.begin(), lb_net_ids_.end()); +} + +AtomNetId LbRouter::net_atom_net_id(const NetId& net) const { + VTR_ASSERT(true == valid_net_id(net)); + return lb_net_atom_net_ids_[net]; +} + std::vector LbRouter::find_congested_rr_nodes(const LbRRGraph& lb_rr_graph) const { /* Validate if the rr_graph is the one we used to initialize the router */ VTR_ASSERT(true == matched_lb_rr_graph(lb_rr_graph)); diff --git a/openfpga/src/repack/lb_router.h b/openfpga/src/repack/lb_router.h index bf96a5958..c1d82ca1c 100644 --- a/openfpga/src/repack/lb_router.h +++ b/openfpga/src/repack/lb_router.h @@ -29,6 +29,9 @@ class LbRouter { public: /* Strong ids */ struct net_id_tag; typedef vtr::StrongId NetId; + public: /* Types and ranges */ + typedef vtr::vector::const_iterator net_iterator; + typedef vtr::Range net_range; public: /* Intra-Logic Block Routing Data Structures (by instance) */ /************************************************************************** * Describes the status of a logic cluster_ctx.blocks routing resource node @@ -163,6 +166,12 @@ class LbRouter { LbRouter(const LbRRGraph& lb_rr_graph, t_logical_block_type_ptr lb_type); public : /* Public accessors */ + /* Return the ids for all the nets to be routed */ + net_range nets() const; + + /* Return the atom net id for a net to be routed */ + AtomNetId net_atom_net_id(const NetId& net) const; + /** * Find all the routing resource nodes that are over-used, which they are used more than their capacity * This function is call to collect the nodes and router can reroute these net diff --git a/openfpga/src/repack/lb_router_utils.cpp b/openfpga/src/repack/lb_router_utils.cpp index 221f5a640..c106cd9f7 100644 --- a/openfpga/src/repack/lb_router_utils.cpp +++ b/openfpga/src/repack/lb_router_utils.cpp @@ -66,4 +66,34 @@ LbRouter::NetId add_lb_router_net_to_route(LbRouter& lb_router, return lb_net; } +/*************************************************************************************** + * Load the routing results (routing tree) from lb router to + * a physical pb data structure + ***************************************************************************************/ +void save_lb_router_results_to_physical_pb(PhysicalPb& phy_pb, + const LbRouter& lb_router, + const LbRRGraph& lb_rr_graph) { + /* Get mapping routing nodes per net */ + for (const LbRouter::NetId& net : lb_router.nets()) { + std::vector routed_nodes = lb_router.net_routed_nodes(net); + for (const LbRRNodeId& node : routed_nodes) { + t_pb_graph_pin* pb_graph_pin = lb_rr_graph.node_pb_graph_pin(node); + if (nullptr == pb_graph_pin) { + continue; + } + /* Find the pb id */ + const PhysicalPbId& pb_id = phy_pb.find_pb(pb_graph_pin->parent_node); + VTR_ASSERT(true == phy_pb.valid_pb_id(pb_id)); + + const AtomNetId& atom_net = lb_router.net_atom_net_id(net); + + if (AtomNetId::INVALID() == phy_pb.pb_graph_pin_atom_net(pb_id, pb_graph_pin)) { + phy_pb.set_pb_graph_pin_atom_net(pb_id, pb_graph_pin, atom_net); + } else { + VTR_ASSERT(atom_net == phy_pb.pb_graph_pin_atom_net(pb_id, pb_graph_pin)); + } + } + } +} + } /* end namespace openfpga */ diff --git a/openfpga/src/repack/lb_router_utils.h b/openfpga/src/repack/lb_router_utils.h index 6a92201eb..129796e7d 100644 --- a/openfpga/src/repack/lb_router_utils.h +++ b/openfpga/src/repack/lb_router_utils.h @@ -7,6 +7,7 @@ #include "atom_netlist.h" #include "lb_rr_graph.h" #include "lb_router.h" +#include "physical_pb.h" /******************************************************************** * Function declaration @@ -22,6 +23,10 @@ LbRouter::NetId add_lb_router_net_to_route(LbRouter& lb_router, const AtomContext& atom_ctx, const AtomNetId& atom_net_id); +void save_lb_router_results_to_physical_pb(PhysicalPb& phy_pb, + const LbRouter& lb_router, + const LbRRGraph& lb_rr_graph); + } /* end namespace openfpga */ #endif diff --git a/openfpga/src/repack/repack.cpp b/openfpga/src/repack/repack.cpp index e4df2986d..371d4ab46 100644 --- a/openfpga/src/repack/repack.cpp +++ b/openfpga/src/repack/repack.cpp @@ -293,6 +293,7 @@ void repack_cluster(const AtomContext& atom_ctx, atom_ctx, device_annotation); /* TODO: save routing results */ + save_lb_router_results_to_physical_pb(phy_pb, lb_router, lb_rr_graph); VTR_LOGV(verbose, "Saved results in physical pb\n"); /* Add the pb to clustering context */