@@ -399,6 +399,116 @@ bool Resizer::removeBuffer(Instance* buffer,
399
399
return buffer_removed;
400
400
}
401
401
402
+ bool Resizer::canRemoveBuffer (Instance* buffer, bool honorDontTouchFixed)
403
+ {
404
+ LibertyCell* lib_cell = network_->libertyCell (buffer);
405
+ if (!lib_cell || !lib_cell->isBuffer ()) {
406
+ return false ;
407
+ }
408
+ // Do not remove buffers connected to input/output ports
409
+ // because verilog netlists use the net name for the port.
410
+ if (bufferBetweenPorts (buffer)) {
411
+ return false ;
412
+ }
413
+ dbInst* db_inst = db_network_->staToDb (buffer);
414
+ if (honorDontTouchFixed) {
415
+ if (db_inst->isDoNotTouch () || db_inst->isFixed ()) {
416
+ return false ;
417
+ }
418
+ }
419
+ LibertyPort *in_port, *out_port;
420
+ lib_cell->bufferPorts (in_port, out_port);
421
+ Pin* in_pin = db_network_->findPin (buffer, in_port);
422
+ Pin* out_pin = db_network_->findPin (buffer, out_port);
423
+ Net* in_net = db_network_->net (in_pin);
424
+ Net* out_net = db_network_->net (out_pin);
425
+ dbNet* in_db_net = db_network_->staToDb (in_net);
426
+ dbNet* out_db_net = db_network_->staToDb (out_net);
427
+ // honor net dont-touch on input net or output net
428
+ if (honorDontTouchFixed) {
429
+ if (in_db_net->isDoNotTouch () || out_db_net->isDoNotTouch ()) {
430
+ return false ;
431
+ }
432
+ }
433
+ bool out_net_ports = hasPort (out_net);
434
+ Net *removed;
435
+ if (out_net_ports) {
436
+ if (hasPort (in_net)) {
437
+ return false ;
438
+ }
439
+ removed = in_net;
440
+ } else {
441
+ // default or out_net_ports
442
+ // Default to in_net surviving so drivers (cached in dbNetwork)
443
+ // do not change.
444
+ removed = out_net;
445
+ }
446
+ return (!sdc_->isConstrained (in_pin) && !sdc_->isConstrained (out_pin)
447
+ && !sdc_->isConstrained (removed) && !sdc_->isConstrained (buffer));
448
+ }
449
+
450
+ void Resizer::removeBuffer2 (Instance* buffer, bool recordJournal)
451
+ {
452
+ LibertyCell* lib_cell = network_->libertyCell (buffer);
453
+ // Do not remove buffers connected to input/output ports
454
+ // because verilog netlists use the net name for the port.
455
+ dbInst* db_inst = db_network_->staToDb (buffer);
456
+ if (db_inst->isDoNotTouch ()) {
457
+ // remove instance dont touch
458
+ db_inst->setDoNotTouch (false );
459
+ }
460
+ if (db_inst->isFixed ()) {
461
+ // change FIXED to PLACED just in case
462
+ db_inst->setPlacementStatus (odb::dbPlacementStatus::PLACED);
463
+ }
464
+ LibertyPort *in_port, *out_port;
465
+ lib_cell->bufferPorts (in_port, out_port);
466
+ Pin* in_pin = db_network_->findPin (buffer, in_port);
467
+ Pin* out_pin = db_network_->findPin (buffer, out_port);
468
+ Net* in_net = db_network_->net (in_pin);
469
+ Net* out_net = db_network_->net (out_pin);
470
+ dbNet* in_db_net = db_network_->staToDb (in_net);
471
+ dbNet* out_db_net = db_network_->staToDb (out_net);
472
+ if (in_db_net->isDoNotTouch () || out_db_net->isDoNotTouch ()) {
473
+ // remove net dont touch for manual ECO
474
+ in_db_net->setDoNotTouch (false );
475
+ out_db_net->setDoNotTouch (false );
476
+ }
477
+ bool out_net_ports = hasPort (out_net);
478
+ Net *survivor, *removed;
479
+ if (out_net_ports) {
480
+ survivor = out_net;
481
+ removed = in_net;
482
+ } else {
483
+ // default or out_net_ports
484
+ // Default to in_net surviving so drivers (cached in dbNetwork)
485
+ // do not change.
486
+ survivor = in_net;
487
+ removed = out_net;
488
+ }
489
+
490
+ if (recordJournal) {
491
+ journalRemoveBuffer (buffer);
492
+ }
493
+ debugPrint (
494
+ logger_, RSZ, " remove_buffer" , 1 , " remove {}" , db_network_->name (buffer));
495
+
496
+ if (removed) {
497
+ odb::dbNet* db_survivor = db_network_->staToDb (survivor);
498
+ odb::dbNet* db_removed = db_network_->staToDb (removed);
499
+ db_survivor->mergeNet (db_removed);
500
+
501
+ sta_->disconnectPin (in_pin);
502
+ sta_->disconnectPin (out_pin);
503
+ sta_->deleteInstance (buffer);
504
+
505
+ sta_->deleteNet (removed);
506
+ parasitics_invalid_.erase (removed);
507
+ }
508
+ parasiticsInvalid (survivor);
509
+ updateParasitics ();
510
+ }
511
+
402
512
void Resizer::ensureLevelDrvrVertices ()
403
513
{
404
514
if (!level_drvr_vertices_valid_) {
0 commit comments