@@ -513,14 +513,33 @@ odb::dbInst* LatencyBalancer::createDelayBuffer(odb::dbNet* driverNet,
513513 // creat a new input net
514514 std::string newNetName
515515 = " delaynet_" + std::to_string (delayBufIndex_) + " _" + clockName;
516- odb::dbNet* newNet = odb::dbNet::create (block, newNetName.c_str ());
516+
517+ // hierarchy fix, make the net in the right scope
518+ sta::Pin* driver = nullptr ;
519+ odb::dbModule* module = network_->getNetDriverParentModule (
520+ network_->dbToSta (driverNet), driver);
521+ if (module == nullptr ) {
522+ // if none put in top level
523+ module = block->getTopModule ();
524+ }
525+ sta::Instance* scope
526+ = (module == nullptr || (module == block->getTopModule ()))
527+ ? network_->topInstance ()
528+ : (sta::Instance*) (module ->getModInst ());
529+ odb::dbNet* newNet = network_->staToDb (network_->makeNet (
530+ newNetName.c_str (), scope, odb::dbNameUniquifyType::IF_NEEDED));
531+
517532 newNet->setSigType (odb::dbSigType::CLOCK);
518533
519534 // create a new delay buffer
520535 std::string newBufName
521536 = " delaybuf_" + std::to_string (delayBufIndex_++) + " _" + clockName;
522537 odb::dbMaster* master = db_->findMaster (options_->getRootBuffer ().c_str ());
523- odb::dbInst* newBuf = odb::dbInst::create (block, master, newBufName.c_str ());
538+
539+ // fix: make buffer in same hierarchical module as driver
540+
541+ odb::dbInst* newBuf
542+ = odb::dbInst::create (block, master, newBufName.c_str (), false , module );
524543
525544 newBuf->setSourceType (odb::dbSourceType::TIMING);
526545 newBuf->setLocation (locX, locY);
0 commit comments