diff --git a/src/dbSta/src/dbNetwork.cc b/src/dbSta/src/dbNetwork.cc index ec3c3c14155..843b0c40566 100644 --- a/src/dbSta/src/dbNetwork.cc +++ b/src/dbSta/src/dbNetwork.cc @@ -707,14 +707,11 @@ const char* dbNetwork::name(const Cell* cell) const // (b) bus port (which has many singletons inside it) // (c) bundle port -- todo (which has many singletons inside it). // -// This iterator goes through the ports via the lowest level connections: -// the singleton modbterms . To see what is inside the -// aggregated ports (eg bus port/bundle port) we use the member -// Iterator. (Though this iterator simply skips them). +// This iterator uses the odb generate iterator dbModulePortItr +// which has knowledge of he underlying port types and skips +// over their contents. // // -// TODO: remove the traversal at the lowest level. -// class dbModulePortIterator : public CellPortIterator { @@ -732,8 +729,8 @@ class dbModulePortIterator : public CellPortIterator dbModulePortIterator::dbModulePortIterator(dbModule* cell) { - iter_ = cell->getModBTerms().begin(); - end_ = cell->getModBTerms().end(); + iter_ = cell->getPorts().begin(); + end_ = cell->getPorts().end(); module_ = cell; } @@ -748,13 +745,6 @@ bool dbModulePortIterator::hasNext() Port* dbModulePortIterator::next() { dbModBTerm* ret = *iter_; - if (ret->isBusPort()) { - dbBusPort* bus_port = ret->getBusPort(); - // todo: remove this using custom iterator - for (int i = 0; i < bus_port->getSize(); i++) { - iter_++; - } - } iter_++; return (reinterpret_cast(ret)); } diff --git a/src/odb/include/odb/db.h b/src/odb/include/odb/db.h index 365f489d9cd..61cc66f6d04 100644 --- a/src/odb/include/odb/db.h +++ b/src/odb/include/odb/db.h @@ -7181,11 +7181,6 @@ class dbBusPort : public dbObject int from_ix, int to_ix); - private: - // dbModuleBusPortModBTermItr* _members_iter=nullptr; - // reallocate the bus port so all members sequential. - void Realloc(); - // User Code End dbBusPort }; @@ -7710,6 +7705,9 @@ class dbModule : public dbObject dbSet getChildren(); dbSet getModInsts(); dbSet getModNets(); + // Get the ports of a module (STA world uses ports, which contain members). + dbSet getPorts(); + // Get the leaf level connections on a module (flat connected view). dbSet getModBTerms(); dbModBTerm* getModBTerm(uint id); dbSet getInsts(); @@ -7723,8 +7721,6 @@ class dbModule : public dbObject int getModInstCount(); int getDbInstCount(); - void staSetCell(void* cell); - void* getStaCell(); const dbModBTerm* getHeadDbModBTerm() const; static dbModule* create(dbBlock* block, const char* name); diff --git a/src/odb/src/codeGenerator/schema.json b/src/odb/src/codeGenerator/schema.json index c4791a2ba3f..7a1970c34fc 100644 --- a/src/odb/src/codeGenerator/schema.json +++ b/src/odb/src/codeGenerator/schema.json @@ -1,6 +1,16 @@ { "classes_dir": "schema", "iterators":[ + { + "name": "dbModulePortItr", + "parentObject": "dbModBTerm", + "tableName": "modbterm_tbl", + "reversible": "true", + "orderReversed": "true", + "flags":["private"], + "sequential": 0, + "includes": ["dbModBTerm.h", "dbModule.h", "dbBusPort.h", "dbBlock.h"] + }, { "name": "dbModuleModBTermItr", "parentObject": "dbModBTerm", diff --git a/src/odb/src/codeGenerator/schema/chip/dbModule.json b/src/odb/src/codeGenerator/schema/chip/dbModule.json index 507d2398439..f7f1754abd9 100644 --- a/src/odb/src/codeGenerator/schema/chip/dbModule.json +++ b/src/odb/src/codeGenerator/schema/chip/dbModule.json @@ -1,6 +1,7 @@ { "name":"dbModule", "type":"dbObject", + "needs_non_default_destructor" : "true", "fields":[ { "name":"_name", @@ -43,7 +44,7 @@ "schema":"db_schema_update_hierarchy" } ], - "cpp_includes":["dbBlock.h","dbHashTable.hpp", "dbModBTerm.h", "dbModInst.h", "dbInst.h"], + "cpp_includes":["dbBlock.h","dbHashTable.hpp", "dbModBTerm.h", "dbModInst.h", "dbInst.h", "dbModulePortItr.h"], "h_includes": [ "dbVector.h", "odb/dbSet.h" diff --git a/src/odb/src/db/CMakeLists.txt b/src/odb/src/db/CMakeLists.txt index 8b591316991..128aa341cbc 100644 --- a/src/odb/src/db/CMakeLists.txt +++ b/src/odb/src/db/CMakeLists.txt @@ -142,6 +142,7 @@ add_library(db dbModuleModNetItr.cpp dbModuleModNetModBTermItr.cpp dbModuleModNetModITermItr.cpp + dbModulePortItr.cpp dbNetTrackItr.cpp dbRegionGroupItr.cpp # Generator Code End cpp diff --git a/src/odb/src/db/dbBusPort.cpp b/src/odb/src/db/dbBusPort.cpp index e2e71c02fb1..bf26c1670b1 100644 --- a/src/odb/src/db/dbBusPort.cpp +++ b/src/odb/src/db/dbBusPort.cpp @@ -299,7 +299,6 @@ dbModBTerm* dbBusPort::getBusIndexedElement(int index) const return cur; } } - return nullptr; } @@ -369,38 +368,6 @@ dbSet dbBusPort::getBusPortMembers() return dbSet(this, obj->_members_iter); } -// -// TODO future pull request: Reallocate the bus to preserve sequential db -// ordering This to be added as part of "scaffolding functions" -// -void dbBusPort::Realloc() -{ - /* - _dbBusPort* obj = (_dbBusPort*) this; - _dbBlock* block = (_dbBlock*) obj->getOwner(); - dbModule* parentModule (_dbModule*) obj -> getParent(); - if (obj -> _flags !=0U){ - dbModBTerm* busport = block -> modbterm_tbl -> getPtr(obj -> _port); - dbModBTerm* cur = busport -> getPrev(); - // - //sequentially reallocate the elements - //to assure they are layed out for sequential access - //after being tampered with. - // - int size = obj -> getSize(); - for (int i =0; i < size; i++){ - dbModBTerm* new_cur = dbModBTerm::create(parentModule,cur -> getName()); - new_cur -> _modnet = cur -> _modnet; - new_cur -> _next_net_modbterm = cur -> _modbterm; - new_cur -> _prev_net_modbterm = cur -> _modbterm; - new_cur -> _busPort = cur -> _busPort; - new_cur -> _name = cur -> _name; - new_cur -> _parent = cur -> _parent; - } - } - */ -} - // User Code End dbBusPortPublicMethods } // namespace odb // Generator Code End Cpp diff --git a/src/odb/src/db/dbModule.cpp b/src/odb/src/db/dbModule.cpp index 3e107ea95f6..6f66968bc2d 100644 --- a/src/odb/src/db/dbModule.cpp +++ b/src/odb/src/db/dbModule.cpp @@ -40,6 +40,7 @@ #include "dbInst.h" #include "dbModBTerm.h" #include "dbModInst.h" +#include "dbModulePortItr.h" #include "dbTable.h" #include "dbTable.hpp" #include "odb/db.h" @@ -364,6 +365,26 @@ dbSet dbModule::getModInsts() return dbSet(module, block->_module_modinst_itr); } +// +// The ports include higher level views. These have a special +// iterator which knows about how to skip the contents +// of the hierarchical objects (busports) +// + +dbSet dbModule::getPorts() +{ + _dbModule* obj = (_dbModule*) this; + if (obj->_port_iter == nullptr) { + _dbBlock* block = (_dbBlock*) obj->getOwner(); + obj->_port_iter = new dbModulePortItr(block->_modbterm_tbl); + } + return dbSet(this, obj->_port_iter); +} + +// +// The modbterms are the leaf level connections +//"flat view" +// dbSet dbModule::getModBTerms() { _dbModule* module = (_dbModule*) this; @@ -508,18 +529,6 @@ std::string dbModule::getHierarchicalName() const return ""; } -void* dbModule::getStaCell() -{ - _dbModule* module = (_dbModule*) this; - return module->_sta_cell; -} - -void dbModule::staSetCell(void* cell) -{ - _dbModule* module = (_dbModule*) this; - module->_sta_cell = cell; -} - dbBlock* dbModule::getOwner() { _dbModule* obj = (_dbModule*) this; diff --git a/src/odb/src/db/dbModule.h b/src/odb/src/db/dbModule.h index fda8088e5c0..520818e0e6f 100644 --- a/src/odb/src/db/dbModule.h +++ b/src/odb/src/db/dbModule.h @@ -39,6 +39,7 @@ #include "odb/odb.h" // User Code Begin Includes #include "dbHashTable.h" +#include "dbModulePortItr.h" // User Code End Includes namespace odb { @@ -80,7 +81,8 @@ class _dbModule : public _dbObject dbId<_dbModBTerm> _modbterms; // User Code Begin Fields - void* _sta_cell = nullptr; + // custom iterator for traversing ports + dbModulePortItr* _port_iter = nullptr; // User Code End Fields }; dbIStream& operator>>(dbIStream& stream, _dbModule& obj); diff --git a/src/odb/src/db/dbModuleBusPortModBTermItr.cpp b/src/odb/src/db/dbModuleBusPortModBTermItr.cpp index 208f1dae070..89d0db7cc7a 100644 --- a/src/odb/src/db/dbModuleBusPortModBTermItr.cpp +++ b/src/odb/src/db/dbModuleBusPortModBTermItr.cpp @@ -92,6 +92,9 @@ uint dbModuleBusPortModBTermItr::begin(dbObject* parent) uint dbModuleBusPortModBTermItr::end(dbObject* /* unused: parent */) { + if (_ix == _size) { + return _iter->getId(); + } return 0; }