Skip to content

Commit 45e7cf4

Browse files
committed
[ODIN]: Connecting undriven nets to the pad node in resolving subtraction node
Signed-off-by: Seyed Alireza Damghani <[email protected]>
1 parent 2659048 commit 45e7cf4

File tree

1 file changed

+76
-8
lines changed

1 file changed

+76
-8
lines changed

ODIN_II/SRC/subtractions.cpp

Lines changed: 76 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -45,6 +45,7 @@ int subchaintotal = 0;
4545
int* sub = NULL;
4646

4747
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);
4849

4950
/*---------------------------------------------------------------------------
5051
* (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
405406
for (i = 0; i < b; i++) {
406407
/* If the input pin of not gate connects to gnd, replacing the input pin and the not gate with vcc;
407408
* 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+
}
408414
oassert(not_node[i]->input_pins[0]->net->num_driver_pins == 1);
409415
if (not_node[i]->input_pins[0]->net->driver_pins[0]->node->type == GND_NODE) {
410416
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
426432
for (i = 0; i < num; i++) {
427433
/* If the input pin of not gate connects to gnd, replacing the input pin and the not gate with vcc;
428434
* 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+
}
429440
oassert(not_node[i]->input_pins[0]->net->num_driver_pins == 1);
430441
if (not_node[i]->input_pins[0]->net->driver_pins[0]->node->type == GND_NODE) {
431442
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
449460
if (i == count - 1 && flag == 1) {
450461
/* If the input pin of not gate connects to gnd, replacing the input pin and the not gate with vcc;
451462
* 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+
}
452467
oassert(not_node[(i * sizeb + j - 1)]->input_pins[0]->net->num_driver_pins == 1);
453468
if (not_node[(i * sizeb + j - 1)]->input_pins[0]->net->driver_pins[0]->node->type == GND_NODE) {
454469
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
464479
/* If the input pin of not gate connects to gnd, replacing the input pin and the not gate with vcc;
465480
* if the input pin of not gate connects to vcc, replacing the input pin and the not gate with gnd.*/
466481
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+
}
467487
oassert(not_node[index]->input_pins[0]->net->num_driver_pins == 1);
468488
if (not_node[index]->input_pins[0]->net->driver_pins[0]->node->type == GND_NODE) {
469489
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
555575
//connect_nodes(node[count - 1], (node[(count - 1)]->num_output_pins - 1), netlist->gnd_node, 0);
556576
//}
557577

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);
562580

563-
/* Free arrays NOT the pins since relocated! */
564-
vtr::free(nodeo->input_pins);
565-
vtr::free(nodeo->output_pins);
566-
vtr::free(nodeo);
567581
vtr::free(node);
568582
vtr::free(not_node);
569583
return;
@@ -654,3 +668,57 @@ void clean_adders_for_sub() {
654668
processed_adder_list = delete_in_vptr_list(processed_adder_list);
655669
return;
656670
}
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

Comments
 (0)