From 917f192bb2168d1b509745dec7fecf140f794243 Mon Sep 17 00:00:00 2001 From: andyfox-rushc Date: Wed, 5 Jun 2024 15:45:27 -0700 Subject: [PATCH] const expr, add error message for undefined modtype. Signed-off-by: Andy Fox Signed-off-by: andyfox-rushc --- src/dbSta/include/db_sta/dbNetwork.hh | 2 ++ src/dbSta/src/dbNetwork.cc | 28 ++++++++++++++++----------- 2 files changed, 19 insertions(+), 11 deletions(-) diff --git a/src/dbSta/include/db_sta/dbNetwork.hh b/src/dbSta/include/db_sta/dbNetwork.hh index 0b6fb213347..0b685f3049a 100644 --- a/src/dbSta/include/db_sta/dbNetwork.hh +++ b/src/dbSta/include/db_sta/dbNetwork.hh @@ -65,6 +65,7 @@ using odb::dbModule; using odb::dbMTerm; using odb::dbNet; using odb::dbObject; +using odb::dbObjectType; using odb::dbSet; using odb::dbSigType; using odb::Point; @@ -103,6 +104,7 @@ class dbNetwork : public ConcreteNetwork void addObserver(dbNetworkObserver* observer); void removeObserver(dbNetworkObserver* observer); + ObjectId getDbNwkObjectId(dbObjectType typ, ObjectId db_id) const; dbBlock* block() const { return block_; } void makeLibrary(dbLib* lib); void makeCell(Library* library, dbMaster* master); diff --git a/src/dbSta/src/dbNetwork.cc b/src/dbSta/src/dbNetwork.cc index 0e1bd01540a..ad102659603 100644 --- a/src/dbSta/src/dbNetwork.cc +++ b/src/dbSta/src/dbNetwork.cc @@ -101,19 +101,19 @@ char* tmpStringCopy(const char* str) // lower 4 bits used to encode type // -#define DBITERM_ID 0x0 -#define DBBTERM_ID 0x1 -#define DBINST_ID 0x2 -#define DBNET_ID 0x3 -#define DBMODITERM_ID 0x4 -#define DBMODBTERM_ID 0x5 -#define DBMODINST_ID 0x6 -#define DBMODNET_ID 0x7 -#define DBMODULE_ID 0x8 +static constexpr unsigned DBITERM_ID = 0x0; +static constexpr unsigned DBBTERM_ID = 0x1; +static constexpr unsigned DBINST_ID = 0x2; +static constexpr unsigned DBNET_ID = 0x3; +static constexpr unsigned DBMODITERM_ID = 0x4; +static constexpr unsigned DBMODBTERM_ID = 0x5; +static constexpr unsigned DBMODINST_ID = 0x6; +static constexpr unsigned DBMODNET_ID = 0x7; +static constexpr unsigned DBMODULE_ID = 0x8; // Number of lower bits used -#define DBIDTAG_WIDTH 0x4 +static constexpr unsigned DBIDTAG_WIDTH = 0x4; -ObjectId getDbNwkObjectId(dbObjectType typ, ObjectId db_id) +ObjectId dbNetwork::getDbNwkObjectId(dbObjectType typ, ObjectId db_id) const { switch (typ) { case dbITermObj: { @@ -144,6 +144,12 @@ ObjectId getDbNwkObjectId(dbObjectType typ, ObjectId db_id) return ((db_id << DBIDTAG_WIDTH) | DBMODULE_ID); } break; default: + logger_->error( + ORD, + 2017, + "Error: unknown database type passed into unique id generation"); + // note the default "exception undefined case" in database is 0. + // so we reasonably expect upstream tools to handle this. return 0; break; }