@@ -451,13 +451,13 @@ void split_adder_for_sub(nnode_t* nodeo, int a, int b, int sizea, int sizeb, int
451
451
}
452
452
}
453
453
454
- for (i = offset; i < count; i++) {
454
+ for (i = offset; i < count - 1 ; i++) {
455
455
num = (b + 1 ) - i * sizeb;
456
456
if (num > sizeb)
457
457
num = sizeb;
458
458
459
459
for (j = 0 ; j < num; j++) {
460
- if (i == count - 1 && flag == 1 ) {
460
+ if (i == count - 2 && flag == 1 ) {
461
461
/* If the input pin of not gate connects to gnd, replacing the input pin and the not gate with vcc;
462
462
* if the input pin of not gate connects to vcc, replacing the input pin and the not gate with gnd.*/
463
463
/* connecting untouched nets in the netlist creation to the pad node */
@@ -501,8 +501,8 @@ void split_adder_for_sub(nnode_t* nodeo, int a, int b, int sizea, int sizeb, int
501
501
}
502
502
503
503
if ((flag == 0 || count > 1 ) && !configuration.adder_cin_global ) {
504
- // connect the a[0] of first adder node to ground , and b[0] of first adder node to vcc
505
- connect_nodes (netlist->gnd_node , 0 , node[0 ], 0 );
504
+ // connect the a[0] of first adder node to vcc , and b[0] of first adder node to vcc
505
+ connect_nodes (netlist->vcc_node , 0 , node[0 ], 0 );
506
506
connect_nodes (netlist->vcc_node , 0 , node[0 ], sizea);
507
507
// hang the first sumout
508
508
node[0 ]->output_pins [1 ] = allocate_npin ();
@@ -573,6 +573,8 @@ void split_adder_for_sub(nnode_t* nodeo, int a, int b, int sizea, int sizeb, int
573
573
// Pad outputs with a unique and descriptive name to avoid collisions.
574
574
node[count - 1 ]->output_pins [0 ]->name = append_string (" " , " %s~dummy_output~%d~%d" , node[(count - 1 )]->name , (count - 1 ), 0 );
575
575
// connect_nodes(node[count - 1], (node[(count - 1)]->num_output_pins - 1), netlist->gnd_node, 0);
576
+ connect_nodes (netlist->vcc_node , 0 , node[count - 1 ], 0 );
577
+ connect_nodes (netlist->gnd_node , 0 , node[count - 1 ], sizea);
576
578
// }
577
579
578
580
/* Freeing the old node! */
@@ -626,17 +628,15 @@ void iterate_adders_for_sub(netlist_t* netlist) {
626
628
b = node->input_port_sizes [0 ];
627
629
num = (a >= b) ? a : b;
628
630
629
- if (num >= min_threshold_adder) {
630
- // how many subtractors base on a can split
631
- if ((a + 1 ) % sizea == 0 )
632
- counta = (a + offset) / sizea;
633
- else
634
- counta = (a + 1 ) / sizea + 1 ;
635
- // how many subtractors base on b can split
636
- if ((b + 1 ) % sizeb == 0 )
637
- countb = (b + offset) / sizeb;
638
- else
639
- countb = (b + 1 ) / sizeb + 1 ;
631
+ if (num >= min_threshold_adder && num >= min_add) {
632
+ // if the first cin in a chain is fed by a global input (offset = 0) the adder width is the
633
+ // input width + 1 (to pass the last cout -> sumout) divided by size of the adder input ports
634
+ // otherwise (offset = 1) a dummy adder is added to the chain to feed the first cin with gnd
635
+ // how many adders a can split
636
+ counta = (a + 1 ) / sizea + offset;
637
+ // how many adders b can split
638
+ countb = (b + 1 ) / sizeb + offset;
639
+ // how many adders need to be split
640
640
// how many subtractors need to be split
641
641
if (counta >= countb)
642
642
count = counta;
0 commit comments