Skip to content

Commit

Permalink
Customized generated iterator for ports on a module. Signed-off-by: A…
Browse files Browse the repository at this point in the history
…ndy Fox <[email protected]>

Signed-off-by: andyfox-rushc <[email protected]>
  • Loading branch information
andyfox-rushc committed Aug 4, 2024
1 parent 41b4c39 commit 15a1870
Show file tree
Hide file tree
Showing 9 changed files with 48 additions and 69 deletions.
20 changes: 5 additions & 15 deletions src/dbSta/src/dbNetwork.cc
Original file line number Diff line number Diff line change
Expand Up @@ -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
{
Expand All @@ -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;
}

Expand All @@ -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<Port*>(ret));
}
Expand Down
10 changes: 3 additions & 7 deletions src/odb/include/odb/db.h
Original file line number Diff line number Diff line change
Expand Up @@ -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
};

Expand Down Expand Up @@ -7710,6 +7705,9 @@ class dbModule : public dbObject
dbSet<dbModInst> getChildren();
dbSet<dbModInst> getModInsts();
dbSet<dbModNet> getModNets();
// Get the ports of a module (STA world uses ports, which contain members).
dbSet<dbModBTerm> getPorts();
// Get the leaf level connections on a module (flat connected view).
dbSet<dbModBTerm> getModBTerms();
dbModBTerm* getModBTerm(uint id);
dbSet<dbInst> getInsts();
Expand All @@ -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);
Expand Down
10 changes: 10 additions & 0 deletions src/odb/src/codeGenerator/schema.json
Original file line number Diff line number Diff line change
@@ -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",
Expand Down
3 changes: 2 additions & 1 deletion src/odb/src/codeGenerator/schema/chip/dbModule.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
{
"name":"dbModule",
"type":"dbObject",
"needs_non_default_destructor" : "true",
"fields":[
{
"name":"_name",
Expand Down Expand Up @@ -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"
Expand Down
1 change: 1 addition & 0 deletions src/odb/src/db/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -142,6 +142,7 @@ add_library(db
dbModuleModNetItr.cpp
dbModuleModNetModBTermItr.cpp
dbModuleModNetModITermItr.cpp
dbModulePortItr.cpp
dbNetTrackItr.cpp
dbRegionGroupItr.cpp
# Generator Code End cpp
Expand Down
33 changes: 0 additions & 33 deletions src/odb/src/db/dbBusPort.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -299,7 +299,6 @@ dbModBTerm* dbBusPort::getBusIndexedElement(int index) const
return cur;
}
}

return nullptr;
}

Expand Down Expand Up @@ -369,38 +368,6 @@ dbSet<dbModBTerm> dbBusPort::getBusPortMembers()
return dbSet<dbModBTerm>(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
33 changes: 21 additions & 12 deletions src/odb/src/db/dbModule.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down Expand Up @@ -364,6 +365,26 @@ dbSet<dbModInst> dbModule::getModInsts()
return dbSet<dbModInst>(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<dbModBTerm> 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<dbModBTerm>(this, obj->_port_iter);
}

//
// The modbterms are the leaf level connections
//"flat view"
//
dbSet<dbModBTerm> dbModule::getModBTerms()
{
_dbModule* module = (_dbModule*) this;
Expand Down Expand Up @@ -508,18 +529,6 @@ std::string dbModule::getHierarchicalName() const
return "<top>";
}

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;
Expand Down
4 changes: 3 additions & 1 deletion src/odb/src/db/dbModule.h
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,7 @@
#include "odb/odb.h"
// User Code Begin Includes
#include "dbHashTable.h"
#include "dbModulePortItr.h"
// User Code End Includes

namespace odb {
Expand Down Expand Up @@ -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);
Expand Down
3 changes: 3 additions & 0 deletions src/odb/src/db/dbModuleBusPortModBTermItr.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -92,6 +92,9 @@ uint dbModuleBusPortModBTermItr::begin(dbObject* parent)

uint dbModuleBusPortModBTermItr::end(dbObject* /* unused: parent */)
{
if (_ix == _size) {
return _iter->getId();
}
return 0;
}

Expand Down

0 comments on commit 15a1870

Please sign in to comment.