Skip to content

Commit 295def9

Browse files
navidjafarofalirezazd
authored andcommitted
init branch
1 parent 3ecf1a3 commit 295def9

File tree

2 files changed

+17
-17
lines changed

2 files changed

+17
-17
lines changed

odin_ii/src/core/subtractions.cpp

+15-15
Original file line numberDiff line numberDiff line change
@@ -451,13 +451,13 @@ void split_adder_for_sub(nnode_t* nodeo, int a, int b, int sizea, int sizeb, int
451451
}
452452
}
453453

454-
for (i = offset; i < count; i++) {
454+
for (i = offset; i < count - 1; i++) {
455455
num = (b + 1) - i * sizeb;
456456
if (num > sizeb)
457457
num = sizeb;
458458

459459
for (j = 0; j < num; j++) {
460-
if (i == count - 1 && flag == 1) {
460+
if (i == count - 2 && flag == 1) {
461461
/* If the input pin of not gate connects to gnd, replacing the input pin and the not gate with vcc;
462462
* if the input pin of not gate connects to vcc, replacing the input pin and the not gate with gnd.*/
463463
/* 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
501501
}
502502

503503
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);
506506
connect_nodes(netlist->vcc_node, 0, node[0], sizea);
507507
//hang the first sumout
508508
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
573573
// Pad outputs with a unique and descriptive name to avoid collisions.
574574
node[count - 1]->output_pins[0]->name = append_string("", "%s~dummy_output~%d~%d", node[(count - 1)]->name, (count - 1), 0);
575575
//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);
576578
//}
577579

578580
/* Freeing the old node! */
@@ -626,17 +628,15 @@ void iterate_adders_for_sub(netlist_t* netlist) {
626628
b = node->input_port_sizes[0];
627629
num = (a >= b) ? a : b;
628630

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
640640
// how many subtractors need to be split
641641
if (counta >= countb)
642642
count = counta;

odin_ii/src/netlist/netlist_create_from_ast.cpp

+2-2
Original file line numberDiff line numberDiff line change
@@ -3599,8 +3599,8 @@ signal_list_t* create_operation_node(ast_node_t* op, signal_list_t** input_lists
35993599
break;
36003600
case MINUS: // -
36013601
/* subtract the largest bit width + the other input padded with 0's ... concern for 2's comp */
3602-
output_port_width = max_input_port_width;
3603-
input_port_width = output_port_width;
3602+
output_port_width = max_input_port_width + 1;
3603+
input_port_width = max_input_port_width;
36043604
sub_list = insert_in_vptr_list(sub_list, operation_node);
36053605

36063606
break;

0 commit comments

Comments
 (0)