@@ -352,7 +352,6 @@ bool MBFF::IsClearPin(dbITerm* iterm)
352352{
353353 dbInst* inst = iterm->getInst ();
354354 const sta::Cell* cell = network_->dbToSta (inst->getMaster ());
355- const sta::LibertyCell* lib_cell = getLibertyCell (cell);
356355 const sta::Pin* pin = network_->dbToSta (iterm);
357356 if (pin == nullptr ) {
358357 return false ;
@@ -361,11 +360,41 @@ bool MBFF::IsClearPin(dbITerm* iterm)
361360 if (lib_port == nullptr ) {
362361 return false ;
363362 }
363+
364+ const sta::LibertyCell* lib_cell = network_->libertyCell (cell);
365+ if (lib_cell == nullptr ) {
366+ return false ;
367+ }
368+
369+ // Check the lib cell if the port is a clear.
364370 for (const sta::Sequential* seq : lib_cell->sequentials ()) {
365371 if (seq->clear () && seq->clear ()->hasPort (lib_port)) {
366372 return true ;
367373 }
368374 }
375+
376+ // If it exists, check the test lib cell if the port is a clear.
377+ const sta::LibertyCell* test_cell = lib_cell->testCell ();
378+ if (test_cell == nullptr ) {
379+ return false ;
380+ }
381+
382+ // Find the equivalent lib_port on the test cell by name.
383+ //
384+ // TODO: NA - Make retrieving the port on the lib cell possible without doing
385+ // a name match each time
386+ const sta::LibertyPort* test_lib_port
387+ = test_cell->findLibertyPort (lib_port->name ());
388+ if (test_lib_port == nullptr ) {
389+ return false ;
390+ }
391+
392+ for (const sta::Sequential* seq : test_cell->sequentials ()) {
393+ if (seq->clear () && seq->clear ()->hasPort (test_lib_port)) {
394+ return true ;
395+ }
396+ }
397+
369398 return false ;
370399}
371400
@@ -385,7 +414,6 @@ bool MBFF::IsPresetPin(dbITerm* iterm)
385414{
386415 dbInst* inst = iterm->getInst ();
387416 const sta::Cell* cell = network_->dbToSta (inst->getMaster ());
388- const sta::LibertyCell* lib_cell = getLibertyCell (cell);
389417 const sta::Pin* pin = network_->dbToSta (iterm);
390418 if (pin == nullptr ) {
391419 return false ;
@@ -394,11 +422,41 @@ bool MBFF::IsPresetPin(dbITerm* iterm)
394422 if (lib_port == nullptr ) {
395423 return false ;
396424 }
425+
426+ const sta::LibertyCell* lib_cell = network_->libertyCell (cell);
427+ if (lib_cell == nullptr ) {
428+ return false ;
429+ }
430+
431+ // Check the lib cell if the port is a preset.
397432 for (const sta::Sequential* seq : lib_cell->sequentials ()) {
398433 if (seq->preset () && seq->preset ()->hasPort (lib_port)) {
399434 return true ;
400435 }
401436 }
437+
438+ // If it exists, check the test lib cell if the port is a preset.
439+ const sta::LibertyCell* test_cell = lib_cell->testCell ();
440+ if (test_cell == nullptr ) {
441+ return false ;
442+ }
443+
444+ // Find the equivalent lib_port on the test cell by name.
445+ //
446+ // TODO: NA - Make retrieving the port on the lib cell possible without doing
447+ // a name match each time
448+ const sta::LibertyPort* test_lib_port
449+ = test_cell->findLibertyPort (lib_port->name ());
450+ if (test_lib_port == nullptr ) {
451+ return false ;
452+ }
453+
454+ for (const sta::Sequential* seq : test_cell->sequentials ()) {
455+ if (seq->preset () && seq->preset ()->hasPort (test_lib_port)) {
456+ return true ;
457+ }
458+ }
459+
402460 return false ;
403461}
404462
0 commit comments