Skip to content

Commit

Permalink
init branch
Browse files Browse the repository at this point in the history
  • Loading branch information
navidjafarof authored and alirezazd committed May 12, 2023
1 parent 188cfb5 commit 76bb293
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 17 deletions.
30 changes: 15 additions & 15 deletions odin_ii/src/core/subtractions.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -451,13 +451,13 @@ void split_adder_for_sub(nnode_t* nodeo, int a, int b, int sizea, int sizeb, int
}
}

for (i = offset; i < count; i++) {
for (i = offset; i < count - 1; i++) {
num = (b + 1) - i * sizeb;
if (num > sizeb)
num = sizeb;

for (j = 0; j < num; j++) {
if (i == count - 1 && flag == 1) {
if (i == count - 2 && flag == 1) {
/* If the input pin of not gate connects to gnd, replacing the input pin and the not gate with vcc;
* if the input pin of not gate connects to vcc, replacing the input pin and the not gate with gnd.*/
/* connecting untouched nets in the netlist creation to the pad node */
Expand Down Expand Up @@ -501,8 +501,8 @@ 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 the a[0] of first adder node to vcc, and b[0] of first adder node to vcc
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();
Expand Down Expand Up @@ -573,6 +573,8 @@ void split_adder_for_sub(nnode_t* nodeo, int a, int b, int sizea, int sizeb, int
// Pad outputs with a unique and descriptive name to avoid collisions.
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);
connect_nodes(netlist->vcc_node, 0, node[count - 1], 0);
connect_nodes(netlist->gnd_node, 0, node[count - 1], sizea);
//}

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

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;
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
// how many subtractors need to be split
if (counta >= countb)
count = counta;
Expand Down
4 changes: 2 additions & 2 deletions odin_ii/src/netlist/netlist_create_from_ast.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -3599,8 +3599,8 @@ signal_list_t* create_operation_node(ast_node_t* op, signal_list_t** input_lists
break;
case MINUS: // -
/* subtract the largest bit width + the other input padded with 0's ... concern for 2's comp */
output_port_width = max_input_port_width;
input_port_width = output_port_width;
output_port_width = max_input_port_width + 1;
input_port_width = max_input_port_width;
sub_list = insert_in_vptr_list(sub_list, operation_node);

break;
Expand Down

0 comments on commit 76bb293

Please sign in to comment.