Add comments to lb router and extract a private function for routing a single net
This commit is contained in:
parent
cd50155e29
commit
a1f19e776e
|
@ -202,44 +202,17 @@ void LbRouter::set_physical_pb_modes(const LbRRGraph& lb_rr_graph,
|
|||
}
|
||||
}
|
||||
|
||||
bool LbRouter::try_route(const LbRRGraph& lb_rr_graph,
|
||||
bool LbRouter::try_route_net(const LbRRGraph& lb_rr_graph,
|
||||
const AtomNetlist& atom_nlist,
|
||||
const NetId& net_idx,
|
||||
t_expansion_node& exp_node,
|
||||
std::unordered_map<const t_pb_graph_node*, const t_mode*>& mode_map,
|
||||
const int& verbosity) {
|
||||
/* Validate if the rr_graph is the one we used to initialize the router */
|
||||
VTR_ASSERT(true == matched_lb_rr_graph(lb_rr_graph));
|
||||
|
||||
/* Ensure each net to be routed is valid */
|
||||
for (const NetId& net : lb_net_ids_) {
|
||||
VTR_ASSERT(true == check_net(lb_rr_graph, atom_nlist, net));
|
||||
}
|
||||
|
||||
is_routed_ = false;
|
||||
|
||||
bool is_impossible = false;
|
||||
|
||||
mode_status_.is_mode_conflict = false;
|
||||
mode_status_.try_expand_all_modes = false;
|
||||
|
||||
t_expansion_node exp_node;
|
||||
|
||||
reset_explored_node_tb();
|
||||
|
||||
/* Reset current routing */
|
||||
reset_net_rt();
|
||||
reset_routing_status();
|
||||
|
||||
std::unordered_map<const t_pb_graph_node*, const t_mode*> mode_map;
|
||||
|
||||
/* Iteratively remove congestion until a successful route is found.
|
||||
* Cap the total number of iterations tried so that if a solution does not exist, then the router won't run indefinitely */
|
||||
pres_con_fac_ = params_.pres_fac;
|
||||
for (int iter = 0; iter < params_.max_iterations && !is_routed_ && !is_impossible; iter++) {
|
||||
unsigned int inet;
|
||||
/* Iterate across all nets internal to logic block */
|
||||
for (inet = 0; inet < lb_net_ids_.size() && !is_impossible; inet++) {
|
||||
NetId net_idx = NetId(inet);
|
||||
if (is_skip_route_net(lb_rr_graph, lb_net_rt_trees_[net_idx])) {
|
||||
continue;
|
||||
return true;
|
||||
}
|
||||
|
||||
commit_remove_rt(lb_rr_graph, lb_net_rt_trees_[net_idx], RT_REMOVE, mode_map);
|
||||
|
@ -248,7 +221,7 @@ bool LbRouter::try_route(const LbRRGraph& lb_rr_graph,
|
|||
add_source_to_rt(net_idx);
|
||||
|
||||
/* Route each sink of net */
|
||||
for (unsigned int isink = 1; isink < lb_net_terminals_[net_idx].size() && !is_impossible; isink++) {
|
||||
for (size_t isink = 1; isink < lb_net_terminals_[net_idx].size() && !is_impossible; ++isink) {
|
||||
pq_.clear();
|
||||
/* Get lowest cost next node, repeat until a path is found or if it is impossible to route */
|
||||
|
||||
|
@ -287,12 +260,62 @@ bool LbRouter::try_route(const LbRRGraph& lb_rr_graph,
|
|||
}
|
||||
}
|
||||
|
||||
/* If routing succeed so far, we will try to save(commit) results
|
||||
* to route tree.
|
||||
* During this process, we will check if there is any
|
||||
* nodes using different modes under the same pb_type
|
||||
* If so, we have conflicts and routing is considered to be failure
|
||||
*/
|
||||
if (!is_impossible) {
|
||||
commit_remove_rt(lb_rr_graph, lb_net_rt_trees_[net_idx], RT_COMMIT, mode_map);
|
||||
if (mode_status_.is_mode_conflict) {
|
||||
is_impossible = true;
|
||||
}
|
||||
}
|
||||
|
||||
return !is_impossible;
|
||||
}
|
||||
|
||||
bool LbRouter::try_route(const LbRRGraph& lb_rr_graph,
|
||||
const AtomNetlist& atom_nlist,
|
||||
const int& verbosity) {
|
||||
/* Validate if the rr_graph is the one we used to initialize the router */
|
||||
VTR_ASSERT(true == matched_lb_rr_graph(lb_rr_graph));
|
||||
|
||||
/* Ensure each net to be routed is valid */
|
||||
for (const NetId& net : lb_net_ids_) {
|
||||
VTR_ASSERT(true == check_net(lb_rr_graph, atom_nlist, net));
|
||||
}
|
||||
|
||||
is_routed_ = false;
|
||||
|
||||
bool is_impossible = false;
|
||||
|
||||
mode_status_.is_mode_conflict = false;
|
||||
mode_status_.try_expand_all_modes = false;
|
||||
|
||||
t_expansion_node exp_node;
|
||||
|
||||
reset_explored_node_tb();
|
||||
|
||||
/* Reset current routing */
|
||||
reset_net_rt();
|
||||
reset_routing_status();
|
||||
|
||||
std::unordered_map<const t_pb_graph_node*, const t_mode*> mode_map;
|
||||
|
||||
/* Iteratively remove congestion until a successful route is found.
|
||||
* Cap the total number of iterations tried so that if a solution does not exist, then the router won't run indefinitely */
|
||||
pres_con_fac_ = params_.pres_fac;
|
||||
for (int iter = 0; iter < params_.max_iterations && !is_routed_ && !is_impossible; iter++) {
|
||||
unsigned int inet;
|
||||
/* Iterate across all nets internal to logic block */
|
||||
for (inet = 0; inet < lb_net_ids_.size() && !is_impossible; inet++) {
|
||||
NetId net_idx = NetId(inet);
|
||||
|
||||
if (false == try_route_net(lb_rr_graph, atom_nlist, net_idx, exp_node, mode_map, verbosity)) {
|
||||
is_impossible = true;
|
||||
}
|
||||
}
|
||||
|
||||
if (!is_impossible) {
|
||||
|
|
|
@ -320,6 +320,13 @@ class LbRouter {
|
|||
const bool& try_other_modes,
|
||||
const int& verbosity);
|
||||
|
||||
bool try_route_net(const LbRRGraph& lb_rr_graph,
|
||||
const AtomNetlist& atom_nlist,
|
||||
const NetId& net_idx,
|
||||
t_expansion_node& exp_node,
|
||||
std::unordered_map<const t_pb_graph_node*, const t_mode*>& mode_map,
|
||||
const int& verbosity);
|
||||
|
||||
private : /* Private validators */
|
||||
/**
|
||||
* Validate if the rr_graph is the one we used to initialize the router
|
||||
|
|
Loading…
Reference in New Issue