@@ -746,17 +746,47 @@ void Resizer::findBuffers()
746746 }
747747}
748748
749+ LibertyCell* Resizer::findLowestDriveBuffer (LibertyCell* buffer_cell)
750+ {
751+ // Prefer user-specified buffer cell if provided.
752+ if (buffer_cell) {
753+ logger_->info (RSZ, 31 , " Using the given buffer: {}" , buffer_cell->name ());
754+ return buffer_cell;
755+ }
756+
757+ // Otherwise, find the weakest buffer with the lowest drive resistance.
758+ findBuffers (); // updates buffer_lowest_drive_
759+
760+ // No buffer?
761+ if (buffer_lowest_drive_ == nullptr ) {
762+ logger_->error (RSZ, 23 , " No buffers found." );
763+ return nullptr ;
764+ }
765+
766+ logger_->info (
767+ RSZ, 52 ,
768+ " Using the buffer with the lowest driving resistance: {}" ,
769+ buffer_lowest_drive_->name ());
770+ return buffer_lowest_drive_;
771+ }
772+
749773bool Resizer::isLinkCell (LibertyCell* cell) const
750774{
751775 return network_->findLibertyCell (cell->name ()) == cell;
752776}
753777
754778// //////////////////////////////////////////////////////////////
755779
756- void Resizer::bufferInputs ()
780+ void Resizer::bufferInputs (LibertyCell* buffer_cell )
757781{
758782 init ();
759- findBuffers ();
783+
784+ // find the buffer to use
785+ LibertyCell* buffer_to_use = findLowestDriveBuffer (buffer_cell);
786+ if (buffer_to_use == nullptr ) {
787+ return ;
788+ }
789+
760790 sta_->ensureClkNetwork ();
761791 inserted_buffer_count_ = 0 ;
762792 buffer_moved_into_core_ = false ;
@@ -776,14 +806,14 @@ void Resizer::bufferInputs()
776806 // Hands off special nets.
777807 && !db_network_->isSpecial (net) && hasPins (net)) {
778808 // repair_design will resize to target slew.
779- bufferInput (pin, buffer_lowest_drive_ );
809+ bufferInput (pin, buffer_to_use );
780810 }
781811 }
782812 }
783813
814+ logger_->info (
815+ RSZ, 27 , " Inserted {} input buffers." , inserted_buffer_count_);
784816 if (inserted_buffer_count_ > 0 ) {
785- logger_->info (
786- RSZ, 27 , " Inserted {} input buffers." , inserted_buffer_count_);
787817 level_drvr_vertices_valid_ = false ;
788818 }
789819}
@@ -972,10 +1002,16 @@ Instance* Resizer::bufferInput(const Pin* top_pin, LibertyCell* buffer_cell)
9721002 return buffer;
9731003}
9741004
975- void Resizer::bufferOutputs ()
1005+ void Resizer::bufferOutputs (LibertyCell* buffer_cell )
9761006{
9771007 init ();
978- findBuffers ();
1008+
1009+ // find the buffer to use
1010+ LibertyCell* buffer_to_use = findLowestDriveBuffer (buffer_cell);
1011+ if (buffer_to_use == nullptr ) {
1012+ return ;
1013+ }
1014+
9791015 inserted_buffer_count_ = 0 ;
9801016 buffer_moved_into_core_ = false ;
9811017
@@ -995,14 +1031,14 @@ void Resizer::bufferOutputs()
9951031 // drivers.
9961032 && !hasTristateOrDontTouchDriver (net) && !vertex->isConstant ()
9971033 && hasPins (net)) {
998- bufferOutput (pin, buffer_lowest_drive_ );
1034+ bufferOutput (pin, buffer_to_use );
9991035 }
10001036 }
10011037 }
10021038
1039+ logger_->info (
1040+ RSZ, 28 , " Inserted {} output buffers." , inserted_buffer_count_);
10031041 if (inserted_buffer_count_ > 0 ) {
1004- logger_->info (
1005- RSZ, 28 , " Inserted {} output buffers." , inserted_buffer_count_);
10061042 level_drvr_vertices_valid_ = false ;
10071043 }
10081044}
@@ -1056,6 +1092,7 @@ void Resizer::bufferOutput(const Pin* top_pin, LibertyCell* buffer_cell)
10561092 sta_->disconnectPin (const_cast <Pin*>(top_pin));
10571093
10581094 LibertyPort *input, *output;
1095+ assert (buffer_cell);
10591096 buffer_cell->bufferPorts (input, output);
10601097
10611098 string buffer_name = makeUniqueInstName (" output" );
0 commit comments