@@ -86,7 +86,7 @@ static int num_linked_f_pointer_allocated = 0;
8686 * */
8787
8888/* ******************* Subroutines local to route_common.c *******************/
89- static t_trace_branch traceback_branch (int node, std::unordered_set<int >& main_branch_visited);
89+ static t_trace_branch traceback_branch (int node, int target_net_pin_index, std::unordered_set<int >& main_branch_visited);
9090static std::pair<t_trace*, t_trace*> add_trace_non_configurable (t_trace* head, t_trace* tail, int node, std::unordered_set<int >& visited);
9191static std::pair<t_trace*, t_trace*> add_trace_non_configurable_recurr (int node, std::unordered_set<int >& visited, int depth = 0 );
9292
@@ -484,26 +484,28 @@ void init_route_structs(int bb_factor) {
484484 route_ctx.net_status .resize (cluster_ctx.clb_nlist .nets ().size ());
485485}
486486
487- t_trace* update_traceback (t_heap* hptr, ClusterNetId net_id) {
488- /* This routine adds the most recently finished wire segment to the *
489- * traceback linked list. The first connection starts with the net SOURCE *
490- * and begins at the structure pointed to by route_ctx.trace[net_id].head. *
491- * Each connection ends with a SINK. After each SINK, the next connection *
492- * begins (if the net has more than 2 pins). The first element after the *
493- * SINK gives the routing node on a previous piece of the routing, which is *
494- * the link from the existing net to this new piece of the net. *
495- * In each traceback I start at the end of a path and trace back through *
496- * its predecessors to the beginning. I have stored information on the *
497- * predecesser of each node to make traceback easy -- this sacrificies some *
498- * memory for easier code maintenance. This routine returns a pointer to *
499- * the first "new" node in the traceback (node not previously in trace). */
487+ /* This routine adds the most recently finished wire segment to the *
488+ * traceback linked list. The first connection starts with the net SOURCE *
489+ * and begins at the structure pointed to by route_ctx.trace[net_id].head. *
490+ * Each connection ends with a SINK. After each SINK, the next connection *
491+ * begins (if the net has more than 2 pins). The first element after the *
492+ * SINK gives the routing node on a previous piece of the routing, which is *
493+ * the link from the existing net to this new piece of the net. *
494+ * In each traceback I start at the end of a path, which is a SINK with *
495+ * target_net_pin_index (net pin index corresponding to the SINK, ranging *
496+ * from 1 to fanout), and trace back through its predecessors to the *
497+ * beginning. I have stored information on the predecesser of each node to *
498+ * make traceback easy -- this sacrificies some memory for easier code *
499+ * maintenance. This routine returns a pointer to the first "new" node in *
500+ * the traceback (node not previously in trace). */
501+ t_trace* update_traceback (t_heap* hptr, int target_net_pin_index, ClusterNetId net_id) {
500502 auto & route_ctx = g_vpr_ctx.mutable_routing ();
501503
502504 auto & trace_nodes = route_ctx.trace_nodes [net_id];
503505
504506 VTR_ASSERT_SAFE (validate_trace_nodes (route_ctx.trace [net_id].head , trace_nodes));
505507
506- t_trace_branch branch = traceback_branch (hptr->index , trace_nodes);
508+ t_trace_branch branch = traceback_branch (hptr->index , target_net_pin_index, trace_nodes);
507509
508510 VTR_ASSERT_SAFE (validate_trace_nodes (branch.head , trace_nodes));
509511
@@ -520,9 +522,10 @@ t_trace* update_traceback(t_heap* hptr, ClusterNetId net_id) {
520522 return (ret_ptr);
521523}
522524
523- // Traces back a new routing branch starting from the specified 'node' and working backwards to any existing routing.
525+ // Traces back a new routing branch starting from the specified SINK 'node' with target_net_pin_index, which is the
526+ // net pin index corresponding to the SINK (ranging from 1 to fanout), and working backwards to any existing routing.
524527// Returns the new branch, and also updates trace_nodes for any new nodes which are included in the branches traceback.
525- static t_trace_branch traceback_branch (int node, std::unordered_set<int >& trace_nodes) {
528+ static t_trace_branch traceback_branch (int node, int target_net_pin_index, std::unordered_set<int >& trace_nodes) {
526529 auto & device_ctx = g_vpr_ctx.device ();
527530 auto & route_ctx = g_vpr_ctx.routing ();
528531
@@ -537,6 +540,7 @@ static t_trace_branch traceback_branch(int node, std::unordered_set<int>& trace_
537540 t_trace* branch_head = alloc_trace_data ();
538541 t_trace* branch_tail = branch_head;
539542 branch_head->index = node;
543+ branch_head->net_pin_index = target_net_pin_index; // The first node is the SINK node, so store its net pin index
540544 branch_head->iswitch = OPEN;
541545 branch_head->next = nullptr ;
542546
@@ -551,6 +555,7 @@ static t_trace_branch traceback_branch(int node, std::unordered_set<int>& trace_
551555 // Add the current node to the head of traceback
552556 t_trace* prev_ptr = alloc_trace_data ();
553557 prev_ptr->index = inode;
558+ prev_ptr->net_pin_index = OPEN; // Net pin index is invalid for Non-SINK nodes
554559 prev_ptr->iswitch = device_ctx.rr_nodes .edge_switch (iedge);
555560 prev_ptr->next = branch_head;
556561 branch_head = prev_ptr;
@@ -731,11 +736,16 @@ void mark_ends(ClusterNetId net_id) {
731736 }
732737}
733738
734- void mark_remaining_ends (const std::vector<int >& remaining_sinks) {
739+ void mark_remaining_ends (ClusterNetId net_id, const std::vector<int >& remaining_sinks) {
735740 // like mark_ends, but only performs it for the remaining sinks of a net
741+ int inode;
742+
736743 auto & route_ctx = g_vpr_ctx.mutable_routing ();
737- for (int sink_node : remaining_sinks)
738- ++route_ctx.rr_node_route_inf [sink_node].target_flag ;
744+
745+ for (int sink_pin : remaining_sinks) {
746+ inode = route_ctx.net_rr_terminals [net_id][sink_pin];
747+ ++route_ctx.rr_node_route_inf [inode].target_flag ;
748+ }
739749}
740750
741751void drop_traceback_tail (ClusterNetId net_id) {
@@ -1182,6 +1192,7 @@ alloc_trace_data() {
11821192 trace_free_head->next = nullptr ;
11831193 }
11841194 temp_ptr = trace_free_head;
1195+ temp_ptr->net_pin_index = OPEN; // default
11851196 trace_free_head = trace_free_head->next ;
11861197 num_trace_allocated++;
11871198 return (temp_ptr);
@@ -1276,6 +1287,11 @@ void print_route(FILE* fp, const vtr::vector<ClusterNetId, t_traceback>& traceba
12761287 * used in the routing. */
12771288 fprintf (fp, " Switch: %d" , tptr->iswitch );
12781289
1290+ // Save net pin index for sinks
1291+ if (rr_type == SINK) {
1292+ fprintf (fp, " Net_pin_index: %d" , tptr->net_pin_index );
1293+ }
1294+
12791295 fprintf (fp, " \n " );
12801296
12811297 tptr = tptr->next ;
0 commit comments