From c43a25f3d050eca7f6d195068fb748e28863e867 Mon Sep 17 00:00:00 2001 From: Matt Liberty Date: Wed, 6 May 2020 09:24:45 -0700 Subject: [PATCH] Add isFixed, isPlaced, isBlock, isCore, isPad, isEndCap predicates --- include/opendb/db.h | 54 ++++++++++- include/opendb/dbTypes.h | 27 +++++- src/db/dbInst.cpp | 26 +++++- src/db/dbMaster.cpp | 2 +- src/db/dbTypes.cpp | 187 ++++++++++++++++++++++++++++++++++++++- 5 files changed, 285 insertions(+), 11 deletions(-) diff --git a/include/opendb/db.h b/include/opendb/db.h index 80f31b6..5739adf 100644 --- a/include/opendb/db.h +++ b/include/opendb/db.h @@ -2775,6 +2775,16 @@ class dbInst : public dbObject /// dbPlacementStatus getPlacementStatus(); + /// + /// Is the placement status of this instance fixed + /// + bool isFixed() { return getPlacementStatus().isFixed(); } + + /// + /// Is the placement status of this instance placed + /// + bool isPlaced() { return getPlacementStatus().isPlaced(); } + /// /// Set the placement status of this instance. /// @@ -2877,7 +2887,7 @@ class dbInst : public dbObject /// /// Get the Master of this instance. /// - dbMaster* getMaster(); + dbMaster* getMaster() const; /// /// Get the instance-terminals of this instance. @@ -3041,6 +3051,26 @@ class dbInst : public dbObject /// void setLevel(uint v, bool fromPI); + /// + /// Is the master's type BLOCK or any of its subtypes + /// + bool isBlock() const; + + /// + /// Is the master's type CORE or any of its subtypes + /// + bool isCore() const; + + /// + /// Is the master's type PAD or any of its subtypes + /// + bool isPad() const; + + /// + /// Is the master's type ENDCAP or any of its subtypes + /// + bool isEndCap() const; + /// /// Create a new instance. /// Returns NULL if an instance with this name already exists. @@ -5149,7 +5179,27 @@ class dbMaster : public dbObject /// /// Get the type of this master cell /// - dbMasterType getType(); + dbMasterType getType() const; + + /// + /// Is the type BLOCK or any of its subtypes + /// + bool isBlock() const { return getType().isBlock(); } + + /// + /// Is the type CORE or any of its subtypes + /// + bool isCore() const { return getType().isCore(); } + + /// + /// Is the type PAD or any of its subtypes + /// + bool isPad() const { return getType().isPad(); } + + /// + /// Is the type ENDCAP or any of its subtypes + /// + bool isEndCap() const { return getType().isEndCap(); } /// /// This master can be placed automatically in the core. diff --git a/include/opendb/dbTypes.h b/include/opendb/dbTypes.h index 4bc3df7..4a5b123 100755 --- a/include/opendb/dbTypes.h +++ b/include/opendb/dbTypes.h @@ -273,10 +273,15 @@ class dbPlacementStatus operator Value() const { return _value; } /// - /// True Iff value corresponds to a definite (not suggested) placement. + /// True Iff value corresponds to a PLACED, LOCKED, FIRM, or COVER /// bool isPlaced() const; + /// + /// True Iff value corresponds to LOCKED, FIRM, or COVER + /// + bool isFixed() const; + private: Value _value; }; @@ -364,6 +369,26 @@ class dbMasterType /// operator Value() const { return _value; } + /// + /// Is the type BLOCK or any of its subtypes + /// + bool isBlock() const; + + /// + /// Is the type CORE or any of its subtypes + /// + bool isCore() const; + + /// + /// Is the type PAD or any of its subtypes + /// + bool isPad() const; + + /// + /// Is the type ENDCAP or any of its subtypes + /// + bool isEndCap() const; + private: Value _value; }; diff --git a/src/db/dbInst.cpp b/src/db/dbInst.cpp index 6e9695a..308ec61 100644 --- a/src/db/dbInst.cpp +++ b/src/db/dbInst.cpp @@ -30,8 +30,6 @@ // ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE // POSSIBILITY OF SUCH DAMAGE. -#include "dbInst.h" - #include #include "db.h" @@ -47,6 +45,7 @@ #include "dbHier.h" #include "dbITerm.h" #include "dbITermItr.h" +#include "dbInst.h" #include "dbInstHdr.h" #include "dbJournal.h" #include "dbLib.h" @@ -786,7 +785,7 @@ dbBlock* dbInst::getBlock() return (dbBlock*) getImpl()->getOwner(); } -dbMaster* dbInst::getMaster() +dbMaster* dbInst::getMaster() const { _dbInst* inst = (_dbInst*) this; _dbBlock* block = (_dbBlock*) inst->getOwner(); @@ -795,6 +794,27 @@ dbMaster* dbInst::getMaster() _dbLib* lib = db->_lib_tbl->getPtr(inst_hdr->_lib); return (dbMaster*) lib->_master_tbl->getPtr(inst_hdr->_master); } + +bool dbInst::isBlock() const +{ + return getMaster()->isBlock(); +} + +bool dbInst::isCore() const +{ + return getMaster()->isCore(); +} + +bool dbInst::isPad() const +{ + return getMaster()->isPad(); +} + +bool dbInst::isEndCap() const +{ + return getMaster()->isEndCap(); +} + dbITerm* dbInst::getClockedTerm() { dbMaster* m = getMaster(); diff --git a/src/db/dbMaster.cpp b/src/db/dbMaster.cpp index a4669e6..bbf9045 100644 --- a/src/db/dbMaster.cpp +++ b/src/db/dbMaster.cpp @@ -462,7 +462,7 @@ void dbMaster::setHeight(uint h) master->_height = h; } -dbMasterType dbMaster::getType() +dbMasterType dbMaster::getType() const { _dbMaster* master = (_dbMaster*) this; return dbMasterType(master->_flags._type); diff --git a/src/db/dbTypes.cpp b/src/db/dbTypes.cpp index 3f848ea..9107698 100644 --- a/src/db/dbTypes.cpp +++ b/src/db/dbTypes.cpp @@ -30,12 +30,11 @@ // ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE // POSSIBILITY OF SUCH DAMAGE. -#include "dbTypes.h" - #include #include #include "dbId.h" +#include "dbTypes.h" namespace odb { @@ -369,8 +368,36 @@ const char* dbPlacementStatus::getString() const bool dbPlacementStatus::isPlaced() const { - return ((_value == PLACED) || (_value == LOCKED) || (_value == FIRM) - || (_value == COVER)); + switch (_value) { + case NONE: + case UNPLACED: + case SUGGESTED: + return false; + case PLACED: + case LOCKED: + case FIRM: + case COVER: + return true; + } + assert(false); + return false; +} + +bool dbPlacementStatus::isFixed() const +{ + switch (_value) { + case NONE: + case UNPLACED: + case SUGGESTED: + case PLACED: + return false; + case LOCKED: + case FIRM: + case COVER: + return true; + } + assert(false); + return false; } dbMasterType::dbMasterType(const char* value) @@ -598,6 +625,158 @@ const char* dbMasterType::getString() const return value; } +bool dbMasterType::isBlock() const +{ + switch (_value) { + case BLOCK: + case BLOCK_BLACKBOX: + case BLOCK_SOFT: + return true; + case NONE: + case COVER: + case COVER_BUMP: + case RING: + case PAD: + case PAD_INPUT: + case PAD_OUTPUT: + case PAD_INOUT: + case PAD_POWER: + case PAD_SPACER: + case PAD_AREAIO: + case CORE: + case CORE_FEEDTHRU: + case CORE_TIEHIGH: + case CORE_TIELOW: + case CORE_SPACER: + case CORE_ANTENNACELL: + case CORE_WELLTAP: + case ENDCAP: + case ENDCAP_PRE: + case ENDCAP_POST: + case ENDCAP_TOPLEFT: + case ENDCAP_TOPRIGHT: + case ENDCAP_BOTTOMLEFT: + case ENDCAP_BOTTOMRIGHT: + return false; + } + assert(false); + return false; +} + +bool dbMasterType::isCore() const +{ + switch (_value) { + case CORE: + case CORE_FEEDTHRU: + case CORE_TIEHIGH: + case CORE_TIELOW: + case CORE_SPACER: + case CORE_ANTENNACELL: + case CORE_WELLTAP: + return true; + case NONE: + case COVER: + case COVER_BUMP: + case RING: + case BLOCK: + case BLOCK_BLACKBOX: + case BLOCK_SOFT: + case PAD: + case PAD_INPUT: + case PAD_OUTPUT: + case PAD_INOUT: + case PAD_POWER: + case PAD_SPACER: + case PAD_AREAIO: + case ENDCAP: + case ENDCAP_PRE: + case ENDCAP_POST: + case ENDCAP_TOPLEFT: + case ENDCAP_TOPRIGHT: + case ENDCAP_BOTTOMLEFT: + case ENDCAP_BOTTOMRIGHT: + return false; + } + assert(false); + return false; +} + +bool dbMasterType::isPad() const +{ + switch (_value) { + case PAD: + case PAD_INPUT: + case PAD_OUTPUT: + case PAD_INOUT: + case PAD_POWER: + case PAD_SPACER: + case PAD_AREAIO: + return true; + case NONE: + case COVER: + case COVER_BUMP: + case RING: + case BLOCK: + case BLOCK_BLACKBOX: + case BLOCK_SOFT: + case CORE: + case CORE_FEEDTHRU: + case CORE_TIEHIGH: + case CORE_TIELOW: + case CORE_SPACER: + case CORE_ANTENNACELL: + case CORE_WELLTAP: + case ENDCAP: + case ENDCAP_PRE: + case ENDCAP_POST: + case ENDCAP_TOPLEFT: + case ENDCAP_TOPRIGHT: + case ENDCAP_BOTTOMLEFT: + case ENDCAP_BOTTOMRIGHT: + return false; + } + assert(false); + return false; +} + +bool dbMasterType::isEndCap() const +{ + switch (_value) { + case ENDCAP: + case ENDCAP_PRE: + case ENDCAP_POST: + case ENDCAP_TOPLEFT: + case ENDCAP_TOPRIGHT: + case ENDCAP_BOTTOMLEFT: + case ENDCAP_BOTTOMRIGHT: + return true; + case NONE: + case COVER: + case COVER_BUMP: + case RING: + case BLOCK: + case BLOCK_BLACKBOX: + case BLOCK_SOFT: + case PAD: + case PAD_INPUT: + case PAD_OUTPUT: + case PAD_INOUT: + case PAD_POWER: + case PAD_SPACER: + case PAD_AREAIO: + case CORE: + case CORE_FEEDTHRU: + case CORE_TIEHIGH: + case CORE_TIELOW: + case CORE_SPACER: + case CORE_ANTENNACELL: + case CORE_WELLTAP: + return false; + } + assert(false); + return false; +} + dbTechLayerType::dbTechLayerType(const char* value) { if (strcasecmp(value, "ROUTING") == 0)