diff --git a/parmys/parmys-plugin/core/subtractor.cc b/parmys/parmys-plugin/core/subtractor.cc index 03c259f95ad..a8f20afb0eb 100644 --- a/parmys/parmys-plugin/core/subtractor.cc +++ b/parmys/parmys-plugin/core/subtractor.cc @@ -501,7 +501,7 @@ void split_adder_for_sub(nnode_t *nodeo, int a, int b, int sizea, int sizeb, int if ((flag == 0 || count > 1) && !configuration.adder_cin_global) { // connect the a[0] of first adder node to ground, and b[0] of first adder node to vcc - connect_nodes(netlist->gnd_node, 0, node[0], 0); + connect_nodes(netlist->vcc_node, 0, node[0], 0); connect_nodes(netlist->vcc_node, 0, node[0], sizea); // hang the first sumout node[0]->output_pins[1] = allocate_npin(); @@ -522,8 +522,19 @@ void split_adder_for_sub(nnode_t *nodeo, int a, int b, int sizea, int sizeb, int if (node[i]->input_pins[j] == NULL) { if (nodeo->num_input_port_sizes != 3 && i * sizea + j < a) connect_nodes(netlist->gnd_node, 0, node[i], j); - else - connect_nodes(netlist->pad_node, 0, node[i], j); + else{ + if (i == count - 1){ + // Connect GND and VCC as inputs for last adder node + if (j == 0){ + connect_nodes(netlist->gnd_node, 0, node[i], j); + } + else if (j == 1) + connect_nodes(netlist->vcc_node, 0, node[i], j); + } + else{ + connect_nodes(netlist->pad_node, 0, node[i], j); + } + } } } } @@ -573,7 +584,7 @@ void split_adder_for_sub(nnode_t *nodeo, int a, int b, int sizea, int sizeb, int node[count - 1]->output_pins[0]->name = append_string("", "%s~dummy_output~%d~%d", node[(count - 1)]->name, (count - 1), 0); // connect_nodes(node[count - 1], (node[(count - 1)]->num_output_pins - 1), netlist->gnd_node, 0); // } - + /* Freeing the old node! */ cleanup_sub_old_node(nodeo, netlist); @@ -628,27 +639,51 @@ void iterate_adders_for_sub(netlist_t *netlist) if (num >= min_threshold_adder) { // how many subtractors base on a can split - if ((a + 1) % sizea == 0) - counta = (a + offset) / sizea; - else - counta = (a + 1) / sizea + 1; - // how many subtractors base on b can split - if ((b + 1) % sizeb == 0) - countb = (b + offset) / sizeb; - else - countb = (b + 1) / sizeb + 1; - // how many subtractors need to be split - if (counta >= countb) - count = counta; + if (num >= min_threshold_adder && num >= min_add) { + // if the first cin in a chain is fed by a global input (offset = 0) the adder width is the + // input width + 1 (to pass the last cout -> sumout) divided by size of the adder input ports + // otherwise (offset = 1) a dummy adder is added to the chain to feed the first cin with gnd + // how many adders a can split + counta = (a + 1) / sizea + offset; + // how many adders b can split + countb = (b + 1) / sizeb + offset; + // how many adders need to be split + if (counta >= countb) + count = counta; + else + count = countb; + subchaintotal++; + split_adder_for_sub(node, a, b, sizea, sizeb, 1, 1, count, netlist); + } + // Store the node into processed_adder_list if the threshold is bigger than num else - count = countb; - subchaintotal++; - - split_adder_for_sub(node, a, b, sizea, sizeb, 1, 1, count, netlist); + processed_adder_list = insert_in_vptr_list(processed_adder_list, node); } - // Store the node into processed_adder_list if the threshold is bigger than num else - processed_adder_list = insert_in_vptr_list(processed_adder_list, node); + processed_adder_list = insert_in_vptr_list(processed_adder_list, node); + // if (num >= min_threshold_adder) { + // // how many subtractors base on a can split + // if ((a + 1) % sizea == 0) + // counta = (a + offset) / sizea; + // else + // counta = (a + 1) / sizea + 1; + // // how many subtractors base on b can split + // if ((b + 1) % sizeb == 0) + // countb = (b + offset) / sizeb; + // else + // countb = (b + 1) / sizeb + 1; + // // how many subtractors need to be split + // if (counta >= countb) + // count = counta; + // else + // count = countb; + // subchaintotal++; + + // split_adder_for_sub(node, a, b, sizea, sizeb, 1, 1, count, netlist); + // } + // // Store the node into processed_adder_list if the threshold is bigger than num + // else + // processed_adder_list = insert_in_vptr_list(processed_adder_list, node); } } diff --git a/parmys/parmys-plugin/netlist/netlist_utils.cc b/parmys/parmys-plugin/netlist/netlist_utils.cc index 9c3fb060b4f..b2092d81f56 100644 --- a/parmys/parmys-plugin/netlist/netlist_utils.cc +++ b/parmys/parmys-plugin/netlist/netlist_utils.cc @@ -1392,7 +1392,7 @@ void equalize_ports_size(nnode_t *&node, uintptr_t traverse_mark_number, netlist return; /* new port size */ - int new_out_size = port_a_size; + int new_out_size = port_y_size; /* creating the new node */ nnode_t *new_node = (port_b_size == -1) ? make_1port_gate(node->type, port_a_size, new_out_size, node, traverse_mark_number) @@ -1469,4 +1469,4 @@ void delete_npin(npin_t *pin) } // CLEAN UP free_npin(pin); -} \ No newline at end of file +}