@@ -442,6 +442,44 @@ void combine_nets(nnet_t* output_net, nnet_t* input_net, netlist_t* netlist) {
442
442
free_nnet (output_net);
443
443
}
444
444
445
+ /* ---------------------------------------------------------------------------------------------
446
+ * (function: combine_nets_with_spot_copy)
447
+ * // output net is a net with a driver
448
+ * // input net is a net with all the fanouts
449
+ * In addition to combining two nets, it will change the value of
450
+ * all input nets driven by the output_net previously.
451
+ *-------------------------------------------------------------------------------------------*/
452
+ void combine_nets_with_spot_copy (nnet_t * output_net, nnet_t * input_net, long sc_spot_output, netlist_t * netlist) {
453
+ long in_net_idx;
454
+ long idx_array_size = 0 ;
455
+ long * idx_array = NULL ;
456
+
457
+ // check to see if any matching input_net exist, then save its index
458
+ for (in_net_idx = 0 ; in_net_idx < input_nets_sc->size ; in_net_idx++) {
459
+ if (input_nets_sc->data [in_net_idx] == output_net) {
460
+ idx_array = (long *)vtr::realloc (idx_array, sizeof (long *) * (idx_array_size + 1 ));
461
+ idx_array[idx_array_size] = in_net_idx;
462
+ idx_array_size += 1 ;
463
+ }
464
+ }
465
+
466
+ combine_nets (output_net, input_net, netlist);
467
+ output_net = NULL ;
468
+ /* since the driver net is deleted, copy the spot of the input_net over */
469
+ output_nets_sc->data [sc_spot_output] = (void *)input_net;
470
+
471
+ // copy the spot of input_nets for other inputs driven by the output_net
472
+ for (in_net_idx = 0 ; in_net_idx < idx_array_size; in_net_idx++) {
473
+ char * net_name = input_nets_sc->string [idx_array[in_net_idx]];
474
+ input_nets_sc->data [idx_array[in_net_idx]] = (void *)input_net;
475
+ // check to see if there is any matching output net too.
476
+ if ((sc_spot_output = sc_lookup_string (output_nets_sc, net_name)) != -1 )
477
+ output_nets_sc->data [sc_spot_output] = (void *)input_net;
478
+ }
479
+
480
+ vtr::free (idx_array);
481
+ }
482
+
445
483
/* ---------------------------------------------------------------------------------------------
446
484
* (function: join_nets)
447
485
* Copies the fanouts from input net into net
@@ -480,6 +518,71 @@ void join_nets(nnet_t* join_to_net, nnet_t* other_net) {
480
518
}
481
519
}
482
520
521
+ /* ---------------------------------------------------------------------------------------------
522
+ * (function: integrate_nets)
523
+ * processing the integration of the input net, named with the
524
+ * full_name string (if not exist in input_nets_sc then use driver_net),
525
+ * with the alias net (a related module/function/task instance connection).
526
+ *-------------------------------------------------------------------------------------------*/
527
+ void integrate_nets (char * alias_name, char * full_name, nnet_t * driver_net) {
528
+ long sc_spot_output;
529
+ long sc_spot_input_old;
530
+ long sc_spot_input_new;
531
+
532
+ sc_spot_input_old = sc_lookup_string (input_nets_sc, alias_name);
533
+ oassert (sc_spot_input_old != -1 );
534
+
535
+ /* CMM - Check if this pin should be driven by the top level VCC or GND drivers */
536
+ if (strstr (full_name, ONE_VCC_CNS)) {
537
+ join_nets (verilog_netlist->one_net , (nnet_t *)input_nets_sc->data [sc_spot_input_old]);
538
+ free_nnet ((nnet_t *)input_nets_sc->data [sc_spot_input_old]);
539
+ input_nets_sc->data [sc_spot_input_old] = (void *)verilog_netlist->one_net ;
540
+ } else if (strstr (full_name, ZERO_GND_ZERO)) {
541
+ join_nets (verilog_netlist->zero_net , (nnet_t *)input_nets_sc->data [sc_spot_input_old]);
542
+ free_nnet ((nnet_t *)input_nets_sc->data [sc_spot_input_old]);
543
+ input_nets_sc->data [sc_spot_input_old] = (void *)verilog_netlist->zero_net ;
544
+ }
545
+ /* check if the instantiation pin exists. */
546
+ else if ((sc_spot_output = sc_lookup_string (output_nets_sc, full_name)) == -1 ) {
547
+ /* IF - no driver, then assume that it needs to be aliased to move up as an input */
548
+ if ((sc_spot_input_new = sc_lookup_string (input_nets_sc, full_name)) == -1 ) {
549
+ /* if this input is not yet used in this module then we'll add it */
550
+ sc_spot_input_new = sc_add_string (input_nets_sc, full_name);
551
+
552
+ if (driver_net == NULL ) {
553
+ /* copy the pin to the old spot */
554
+ input_nets_sc->data [sc_spot_input_new] = input_nets_sc->data [sc_spot_input_old];
555
+ } else {
556
+ /* copy the pin to the old spot */
557
+ input_nets_sc->data [sc_spot_input_new] = (void *)driver_net;
558
+ nnet_t * old_in_net = (nnet_t *)input_nets_sc->data [sc_spot_input_old];
559
+ join_nets ((nnet_t *)input_nets_sc->data [sc_spot_input_new], old_in_net);
560
+ // net = NULL;
561
+ old_in_net = free_nnet (old_in_net);
562
+ input_nets_sc->data [sc_spot_input_old] = (void *)driver_net;
563
+ }
564
+ } else {
565
+ /* already exists so we'll join the nets */
566
+ combine_nets ((nnet_t *)input_nets_sc->data [sc_spot_input_old], (nnet_t *)input_nets_sc->data [sc_spot_input_new], verilog_netlist);
567
+ input_nets_sc->data [sc_spot_input_old] = NULL ;
568
+ }
569
+ } else {
570
+ /* ELSE - we've found a matching net, so add this pin to the net */
571
+ nnet_t * out_net = (nnet_t *)output_nets_sc->data [sc_spot_output];
572
+ nnet_t * in_net = (nnet_t *)input_nets_sc->data [sc_spot_input_old];
573
+
574
+ if ((out_net != in_net) && (out_net->combined == true )) {
575
+ /* if they haven't been combined already, then join the inputs and output */
576
+ join_nets (out_net, in_net);
577
+ in_net = free_nnet (in_net);
578
+ /* since the driver net is deleted, copy the spot of the in_net over */
579
+ input_nets_sc->data [sc_spot_input_old] = (void *)out_net;
580
+ } else if ((out_net != in_net) && (out_net->combined == false )) {
581
+ // merge the out_net into the in_net and alter related string cache data for all nets driven by the out_net
582
+ combine_nets_with_spot_copy (out_net, in_net, sc_spot_output, verilog_netlist);
583
+ }
584
+ }
585
+ }
483
586
/* ---------------------------------------------------------------------------------------------
484
587
* (function: remap_pin_to_new_net)
485
588
*-------------------------------------------------------------------------------------------*/
0 commit comments