@@ -45,6 +45,7 @@ int subchaintotal = 0;
45
45
int * sub = NULL ;
46
46
47
47
void init_split_adder_for_sub (nnode_t * node, nnode_t * ptr, int a, int sizea, int b, int sizeb, int cin, int cout, int index, int flag);
48
+ static void cleanup_sub_old_node (nnode_t * nodeo, netlist_t * netlist);
48
49
49
50
/* ---------------------------------------------------------------------------
50
51
* (function: report_sub_distribution)
@@ -405,6 +406,11 @@ void split_adder_for_sub(nnode_t* nodeo, int a, int b, int sizea, int sizeb, int
405
406
for (i = 0 ; i < b; i++) {
406
407
/* If the input pin of not gate connects to gnd, replacing the input pin and the not gate with vcc;
407
408
* if the input pin of not gate connects to vcc, replacing the input pin and the not gate with gnd.*/
409
+ /* connecting untouched nets in the netlist creation to the pad node */
410
+ if (not_node[i]->input_pins [0 ]->net ->num_driver_pins == 0 ) {
411
+ /* join untouched net with pad net */
412
+ join_nets (netlist->pad_net , not_node[i]->input_pins [0 ]->net );
413
+ }
408
414
oassert (not_node[i]->input_pins [0 ]->net ->num_driver_pins == 1 );
409
415
if (not_node[i]->input_pins [0 ]->net ->driver_pins [0 ]->node ->type == GND_NODE) {
410
416
connect_nodes (netlist->vcc_node , 0 , node[0 ], (lefta + i));
@@ -426,6 +432,11 @@ void split_adder_for_sub(nnode_t* nodeo, int a, int b, int sizea, int sizeb, int
426
432
for (i = 0 ; i < num; i++) {
427
433
/* If the input pin of not gate connects to gnd, replacing the input pin and the not gate with vcc;
428
434
* if the input pin of not gate connects to vcc, replacing the input pin and the not gate with gnd.*/
435
+ /* connecting untouched nets in the netlist creation to the pad node */
436
+ if (not_node[i]->input_pins [0 ]->net ->num_driver_pins == 0 ) {
437
+ /* join untouched net with pad net */
438
+ join_nets (netlist->pad_net , not_node[i]->input_pins [0 ]->net );
439
+ }
429
440
oassert (not_node[i]->input_pins [0 ]->net ->num_driver_pins == 1 );
430
441
if (not_node[i]->input_pins [0 ]->net ->driver_pins [0 ]->node ->type == GND_NODE) {
431
442
connect_nodes (netlist->vcc_node , 0 , node[0 ], (sizea + i + 1 ));
@@ -449,6 +460,10 @@ void split_adder_for_sub(nnode_t* nodeo, int a, int b, int sizea, int sizeb, int
449
460
if (i == count - 1 && flag == 1 ) {
450
461
/* If the input pin of not gate connects to gnd, replacing the input pin and the not gate with vcc;
451
462
* if the input pin of not gate connects to vcc, replacing the input pin and the not gate with gnd.*/
463
+ /* connecting untouched nets in the netlist creation to the pad node */
464
+ if (not_node[(i * sizeb + j - 1 )]->input_pins [0 ]->net ->num_driver_pins == 0 ) {
465
+ join_nets (netlist->pad_net , not_node[(i * sizeb + j - 1 )]->input_pins [0 ]->net );
466
+ }
452
467
oassert (not_node[(i * sizeb + j - 1 )]->input_pins [0 ]->net ->num_driver_pins == 1 );
453
468
if (not_node[(i * sizeb + j - 1 )]->input_pins [0 ]->net ->driver_pins [0 ]->node ->type == GND_NODE) {
454
469
connect_nodes (netlist->vcc_node , 0 , node[i], (lefta + j));
@@ -464,6 +479,11 @@ void split_adder_for_sub(nnode_t* nodeo, int a, int b, int sizea, int sizeb, int
464
479
/* If the input pin of not gate connects to gnd, replacing the input pin and the not gate with vcc;
465
480
* if the input pin of not gate connects to vcc, replacing the input pin and the not gate with gnd.*/
466
481
const int index = i * sizeb + j - offset;
482
+ /* connecting untouched nets in the netlist creation to the pad node */
483
+ if (not_node[index]->input_pins [0 ]->net ->num_driver_pins == 0 ) {
484
+ /* join untouched net with pad net */
485
+ join_nets (netlist->pad_net , not_node[index]->input_pins [0 ]->net );
486
+ }
467
487
oassert (not_node[index]->input_pins [0 ]->net ->num_driver_pins == 1 );
468
488
if (not_node[index]->input_pins [0 ]->net ->driver_pins [0 ]->node ->type == GND_NODE) {
469
489
connect_nodes (netlist->vcc_node , 0 , node[i], (sizea + j));
@@ -555,15 +575,9 @@ void split_adder_for_sub(nnode_t* nodeo, int a, int b, int sizea, int sizeb, int
555
575
// connect_nodes(node[count - 1], (node[(count - 1)]->num_output_pins - 1), netlist->gnd_node, 0);
556
576
// }
557
577
558
- /* Probably more to do here in freeing the old node! */
559
- vtr::free (nodeo->name );
560
- vtr::free (nodeo->input_port_sizes );
561
- vtr::free (nodeo->output_port_sizes );
578
+ /* Freeing the old node! */
579
+ cleanup_sub_old_node (nodeo, netlist);
562
580
563
- /* Free arrays NOT the pins since relocated! */
564
- vtr::free (nodeo->input_pins );
565
- vtr::free (nodeo->output_pins );
566
- vtr::free (nodeo);
567
581
vtr::free (node);
568
582
vtr::free (not_node);
569
583
return ;
@@ -654,3 +668,57 @@ void clean_adders_for_sub() {
654
668
processed_adder_list = delete_in_vptr_list (processed_adder_list);
655
669
return ;
656
670
}
671
+
672
+ /* *
673
+ * -------------------------------------------------------------------------
674
+ * (function: cleanup_sub_old_node)
675
+ *
676
+ * @brief <clean up nodeo, a high level MINUS node>
677
+ * In split_adder_for_sub function, nodeo is splitted to small adders/subtractors,
678
+ * while because of the complexity of input pin connections they have not been
679
+ * remapped to new nodes, they just copied and added to new nodes. This function
680
+ * will detach input pins from the nodeo. Moreover, it will connect the net of
681
+ * unconnected output signals to the GND node, detach the pin from nodeo and
682
+ * free the output pins to avoid memory leak.
683
+ *
684
+ * @param nodeo representing the old subtraction node
685
+ * @param netlist representing the current netlist
686
+ *-----------------------------------------------------------------------*/
687
+ static void cleanup_sub_old_node (nnode_t * nodeo, netlist_t * netlist) {
688
+ int i;
689
+ /* Disconnecting input pins from the old node side */
690
+ for (i = 0 ; i < nodeo->num_input_pins ; i++) {
691
+ nodeo->input_pins [i] = NULL ;
692
+ }
693
+
694
+ /* connecting the extra output pins to the gnd node */
695
+ for (i = 0 ; i < nodeo->num_output_pins ; i++) {
696
+ npin_t * output_pin = nodeo->output_pins [i];
697
+
698
+ if (output_pin && output_pin->node ) {
699
+ /* for now we just pass the signals directly through */
700
+ npin_t * zero_pin = get_zero_pin (netlist);
701
+ int idx_2_buffer = zero_pin->pin_net_idx ;
702
+
703
+ // Dont eliminate the buffer if there are multiple drivers or the AST included it
704
+ if (output_pin->net ->num_driver_pins <= 1 ) {
705
+ /* join all fanouts of the output net with the input pins net */
706
+ join_nets (zero_pin->net , output_pin->net );
707
+
708
+ /* erase the pointer to this buffer */
709
+ zero_pin->net ->fanout_pins [idx_2_buffer] = NULL ;
710
+ }
711
+
712
+ free_nnet (output_pin->net );
713
+
714
+ free_npin (zero_pin);
715
+ free_npin (output_pin);
716
+
717
+ /* Disconnecting output pins from the old node side */
718
+ nodeo->output_pins [i] = NULL ;
719
+ }
720
+ }
721
+
722
+ // CLEAN UP
723
+ free_nnode (nodeo);
724
+ }
0 commit comments