Merge branch 'refactoring' into dev

This commit is contained in:
tangxifan 2020-02-22 22:11:27 -07:00
commit 0a01e71ba0
5 changed files with 54 additions and 0 deletions

View File

@ -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<LbRRNodeId> 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));

View File

@ -29,6 +29,9 @@ class LbRouter {
public: /* Strong ids */
struct net_id_tag;
typedef vtr::StrongId<net_id_tag> NetId;
public: /* Types and ranges */
typedef vtr::vector<NetId, NetId>::const_iterator net_iterator;
typedef vtr::Range<net_iterator> 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

View File

@ -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<LbRRNodeId> 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 */

View File

@ -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

View File

@ -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 */