From 80fa6f8a0a2994bec31a791679146f2a59620543 Mon Sep 17 00:00:00 2001 From: tangxifan Date: Tue, 18 Feb 2020 22:08:51 -0700 Subject: [PATCH] refactored skip nets in LbRouter --- openfpga/src/repack/lb_router.cpp | 53 +++++++++++++++++++++++++++---- openfpga/src/repack/lb_router.h | 6 +++- 2 files changed, 51 insertions(+), 8 deletions(-) diff --git a/openfpga/src/repack/lb_router.cpp b/openfpga/src/repack/lb_router.cpp index 16c7f8f35..267d8d3f9 100644 --- a/openfpga/src/repack/lb_router.cpp +++ b/openfpga/src/repack/lb_router.cpp @@ -80,14 +80,32 @@ LbRouter::t_trace* LbRouter::find_node_in_rt(t_trace* rt, const LbRRNodeId& rt_i /************************************************** * Private mutators *************************************************/ -void LbRouter::reset_explored_node_tb() { - for (t_explored_node_stats& explored_node : explored_node_tb_) { - explored_node.prev_index = LbRRNodeId::INVALID(); - explored_node.explored_id = OPEN; - explored_node.inet = OPEN; - explored_node.enqueue_id = OPEN; - explored_node.enqueue_cost = 0; +bool LbRouter::is_skip_route_net(const LbRRGraph& lb_rr_graph, + t_trace* rt) { + /* Validate if the rr_graph is the one we used to initialize the router */ + VTR_ASSERT(true == matched_lb_rr_graph(lb_rr_graph)); + + if (rt == nullptr) { + return false; /* Net is not routed, therefore must route net */ } + + LbRRNodeId inode = rt->current_node; + + /* Determine if node is overused */ + if (routing_status_[inode].occ > lb_rr_graph.node_capacity(inode)) { + /* Conflict between this net and another net at this node, reroute net */ + return false; + } + + /* Recursively check that rest of route tree does not have a conflict */ + for (unsigned int i = 0; i < rt->next_nodes.size(); i++) { + if (!is_skip_route_net(lb_rr_graph, &rt->next_nodes[i])) { + return false; + } + } + + /* No conflict, this net's current route is legal, skip routing this net */ + return true; } bool LbRouter::add_to_rt(t_trace* rt, const LbRRNodeId& node_index, const int& irt_net) { @@ -123,6 +141,13 @@ bool LbRouter::add_to_rt(t_trace* rt, const LbRRNodeId& node_index, const int& i return false; } +void LbRouter::add_source_to_rt(const int& inet) { + /* TODO: Validate net id */ + VTR_ASSERT(nullptr == lb_nets_[inet].rt_tree); + lb_nets_[inet].rt_tree = new t_trace; + lb_nets_[inet].rt_tree->current_node = lb_nets_[inet].terminals[0]; +} + void LbRouter::expand_rt_rec(t_trace* rt, const LbRRNodeId& prev_index, reservable_pq, compare_expansion_node>& pq, @@ -276,4 +301,18 @@ bool LbRouter::matched_lb_rr_graph(const LbRRGraph& lb_rr_graph) const { && (explored_node_tb_.size() == lb_rr_graph.nodes().size()) ); } +/************************************************** + * Private Initializer and cleaner + *************************************************/ +void LbRouter::reset_explored_node_tb() { + for (t_explored_node_stats& explored_node : explored_node_tb_) { + explored_node.prev_index = LbRRNodeId::INVALID(); + explored_node.explored_id = OPEN; + explored_node.inet = OPEN; + explored_node.enqueue_id = OPEN; + explored_node.enqueue_cost = 0; + } +} + + } /* end namespace openfpga */ diff --git a/openfpga/src/repack/lb_router.h b/openfpga/src/repack/lb_router.h index 1d07954df..92aca94c1 100644 --- a/openfpga/src/repack/lb_router.h +++ b/openfpga/src/repack/lb_router.h @@ -200,8 +200,9 @@ class LbRouter { t_trace* find_node_in_rt(t_trace* rt, const LbRRNodeId& rt_index); private : /* Private mutators */ - void reset_explored_node_tb(); + bool is_skip_route_net(const LbRRGraph& lb_rr_graph, t_trace* rt); bool add_to_rt(t_trace* rt, const LbRRNodeId& node_index, const int& irt_net); + void add_source_to_rt(const int& inet); void expand_rt_rec(t_trace* rt, const LbRRNodeId& prev_index, reservable_pq, compare_expansion_node>& pq, @@ -231,6 +232,9 @@ class LbRouter { */ bool matched_lb_rr_graph(const LbRRGraph& lb_rr_graph) const; + private : /* Private initializer and cleaner */ + void reset_explored_node_tb(); + private : /* Stores all data needed by intra-logic cluster_ctx.blocks router */ /* Logical Netlist Info */ std::vector lb_nets_; /* Pointer to vector of intra logic cluster_ctx.blocks nets and their connections */