|
2 | 2 | // Copyright (c) 2019-2025, The OpenROAD Authors |
3 | 3 |
|
4 | 4 | #include <cstring> |
| 5 | +#include <unordered_map> |
5 | 6 |
|
6 | 7 | #include "dbCore.h" |
7 | 8 | #include "dbDatabase.h" |
@@ -139,6 +140,236 @@ static const char* name_tbl[] = {"dbDatabase", |
139 | 140 | "dbProperty", |
140 | 141 | "dbName"}; |
141 | 142 |
|
| 143 | +static const std::unordered_map<uint32_t, dbObjectType> hash_to_object_type |
| 144 | + = {{0x0, dbDatabaseObj}, |
| 145 | + |
| 146 | + // Design Objects |
| 147 | + {0x1, dbChipObj}, |
| 148 | + {0x2, dbGdsLibObj}, |
| 149 | + {0x3, dbBlockObj}, |
| 150 | + {0x4, dbInstHdrObj}, |
| 151 | + {0x5, dbInstObj}, |
| 152 | + {0x6, dbNetObj}, |
| 153 | + {0x7, dbBTermObj}, |
| 154 | + {0x8, dbITermObj}, |
| 155 | + {0x9, dbBoxObj}, |
| 156 | + {0xA, dbViaObj}, |
| 157 | + {0xB, dbTrackGridObj}, |
| 158 | + {0xC, dbObstructionObj}, |
| 159 | + {0xD, dbBlockageObj}, |
| 160 | + {0xE, dbWireObj}, |
| 161 | + {0xF, dbSWireObj}, |
| 162 | + {0x10, dbSBoxObj}, |
| 163 | + {0x11, dbCapNodeObj}, |
| 164 | + {0x12, dbRSegObj}, |
| 165 | + {0x13, dbCCSegObj}, |
| 166 | + {0x14, dbRowObj}, |
| 167 | + {0x15, dbFillObj}, |
| 168 | + {0x16, dbRegionObj}, |
| 169 | + {0x17, dbHierObj}, |
| 170 | + {0x18, dbBPinObj}, |
| 171 | + // Generator Code Begin HashToObjectType |
| 172 | + {0x663302D5, dbAccessPointObj}, |
| 173 | + {0x12B22B2C, dbBusPortObj}, |
| 174 | + {0xEE4BAB67, dbCellEdgeSpacingObj}, |
| 175 | + {0x7C713BD7, dbDftObj}, |
| 176 | + {0x645E6090, dbGCellGridObj}, |
| 177 | + {0xCC5EB4AD, dbGDSARefObj}, |
| 178 | + {0xE4D136A3, dbGDSBoundaryObj}, |
| 179 | + {0x2A7E2FFE, dbGDSBoxObj}, |
| 180 | + {0xE38B6A0A, dbGDSPathObj}, |
| 181 | + {0x85F207E7, dbGDSSRefObj}, |
| 182 | + {0x99297302, dbGDSStructureObj}, |
| 183 | + {0x90DFB402, dbGDSTextObj}, |
| 184 | + {0xA0D52ACE, dbGlobalConnectObj}, |
| 185 | + {0x7A16F67A, dbGroupObj}, |
| 186 | + {0xE76AA1E9, dbGuideObj}, |
| 187 | + {0xB6738B19, dbIsolationObj}, |
| 188 | + {0x861F1D0A, dbLevelShifterObj}, |
| 189 | + {0x2B46CE60, dbLogicPortObj}, |
| 190 | + {0xEB83E7A1, dbMarkerObj}, |
| 191 | + {0x4D3FFF1D, dbMarkerCategoryObj}, |
| 192 | + {0x05DBC7F0, dbMasterEdgeTypeObj}, |
| 193 | + {0x0FD3C974, dbMetalWidthViaMapObj}, |
| 194 | + {0x7EBE8F33, dbModBTermObj}, |
| 195 | + {0xAFA31C35, dbModInstObj}, |
| 196 | + {0xFAC1E1FA, dbModITermObj}, |
| 197 | + {0xDFD34354, dbModNetObj}, |
| 198 | + {0x9F568C6F, dbModuleObj}, |
| 199 | + {0x6D3EE435, dbNetTrackObj}, |
| 200 | + {0x110F3173, dbPolygonObj}, |
| 201 | + {0x7352FE40, dbPowerDomainObj}, |
| 202 | + {0x7D280800, dbPowerSwitchObj}, |
| 203 | + {0xBF9698BF, dbScanChainObj}, |
| 204 | + {0x05CD9D4A, dbScanInstObj}, |
| 205 | + {0xD398101E, dbScanListObj}, |
| 206 | + {0x534639A0, dbScanPartitionObj}, |
| 207 | + {0x2BA03C39, dbScanPinObj}, |
| 208 | + {0x4ED3B51C, dbTechLayerObj}, |
| 209 | + {0x2C0432EB, dbTechLayerAreaRuleObj}, |
| 210 | + {0x1904C344, dbTechLayerArraySpacingRuleObj}, |
| 211 | + {0x598158F4, dbTechLayerCornerSpacingRuleObj}, |
| 212 | + {0xE1F72282, dbTechLayerCutClassRuleObj}, |
| 213 | + {0xFFC5F736, dbTechLayerCutEnclosureRuleObj}, |
| 214 | + {0xB78E788B, dbTechLayerCutSpacingRuleObj}, |
| 215 | + {0x79DFAE70, dbTechLayerCutSpacingTableDefRuleObj}, |
| 216 | + {0xA5373824, dbTechLayerCutSpacingTableOrthRuleObj}, |
| 217 | + {0x49B1981B, dbTechLayerEolExtensionRuleObj}, |
| 218 | + {0x88B0E445, dbTechLayerEolKeepOutRuleObj}, |
| 219 | + {0x139CF020, dbTechLayerForbiddenSpacingRuleObj}, |
| 220 | + {0x0AD77253, dbTechLayerKeepOutZoneRuleObj}, |
| 221 | + {0xA65D53B9, dbTechLayerMaxSpacingRuleObj}, |
| 222 | + {0x4BA55CDE, dbTechLayerMinCutRuleObj}, |
| 223 | + {0x6BE58714, dbTechLayerMinStepRuleObj}, |
| 224 | + {0x49E7A7BD, dbTechLayerSpacingEolRuleObj}, |
| 225 | + {0xA223F41D, dbTechLayerSpacingTablePrlRuleObj}, |
| 226 | + {0x7C5FB405, dbTechLayerTwoWiresForbiddenSpcRuleObj}, |
| 227 | + {0x7BF3D392, dbTechLayerWidthTableRuleObj}, |
| 228 | + {0xF73FA7DF, dbTechLayerWrongDirSpacingRuleObj}, |
| 229 | + // Generator Code End HashToObjectType |
| 230 | + |
| 231 | + // Lib Objects |
| 232 | + {0x52, dbLibObj}, |
| 233 | + {0x53, dbGDSLibObj}, |
| 234 | + {0x54, dbSiteObj}, |
| 235 | + {0x55, dbMasterObj}, |
| 236 | + {0x56, dbMPinObj}, |
| 237 | + {0x57, dbMTermObj}, |
| 238 | + {0x58, dbTechAntennaPinModelObj}, |
| 239 | + |
| 240 | + // Tech Objects |
| 241 | + {0x59, dbTechObj}, |
| 242 | + {0x5A, dbTechViaObj}, |
| 243 | + {0x5B, dbTechNonDefaultRuleObj}, |
| 244 | + {0x5C, dbTechLayerRuleObj}, |
| 245 | + {0x5D, dbTechSameNetRuleObj}, |
| 246 | + {0x5E, dbTechLayerSpacingRuleObj}, |
| 247 | + {0x5F, dbTechMinCutRuleObj}, |
| 248 | + {0x60, dbTechMinEncRuleObj}, |
| 249 | + {0x61, dbTechV55InfluenceEntryObj}, |
| 250 | + {0x62, dbTechLayerAntennaRuleObj}, |
| 251 | + {0x63, dbTechViaRuleObj}, |
| 252 | + {0x64, dbTechViaGenerateRuleObj}, |
| 253 | + {0x65, dbTechViaLayerRuleObj}, |
| 254 | + |
| 255 | + {0x66, dbPropertyObj}, |
| 256 | + {0x67, dbNameObj}}; |
| 257 | + |
| 258 | +static const std::unordered_map<dbObjectType, uint32_t> object_type_to_hash |
| 259 | + = {{dbDatabaseObj, 0x0}, |
| 260 | + |
| 261 | + // Design Objects |
| 262 | + {dbChipObj, 0x1}, |
| 263 | + {dbGdsLibObj, 0x2}, |
| 264 | + {dbBlockObj, 0x3}, |
| 265 | + {dbInstHdrObj, 0x4}, |
| 266 | + {dbInstObj, 0x5}, |
| 267 | + {dbNetObj, 0x6}, |
| 268 | + {dbBTermObj, 0x7}, |
| 269 | + {dbITermObj, 0x8}, |
| 270 | + {dbBoxObj, 0x9}, |
| 271 | + {dbViaObj, 0xA}, |
| 272 | + {dbTrackGridObj, 0xB}, |
| 273 | + {dbObstructionObj, 0xC}, |
| 274 | + {dbBlockageObj, 0xD}, |
| 275 | + {dbWireObj, 0xE}, |
| 276 | + {dbSWireObj, 0xF}, |
| 277 | + {dbSBoxObj, 0x10}, |
| 278 | + {dbCapNodeObj, 0x11}, |
| 279 | + {dbRSegObj, 0x12}, |
| 280 | + {dbCCSegObj, 0x13}, |
| 281 | + {dbRowObj, 0x14}, |
| 282 | + {dbFillObj, 0x15}, |
| 283 | + {dbRegionObj, 0x16}, |
| 284 | + {dbHierObj, 0x17}, |
| 285 | + {dbBPinObj, 0x18}, |
| 286 | + // Generator Code Begin ObjectTypeToHash |
| 287 | + {dbAccessPointObj, 0x663302D5}, |
| 288 | + {dbBusPortObj, 0x12B22B2C}, |
| 289 | + {dbCellEdgeSpacingObj, 0xEE4BAB67}, |
| 290 | + {dbDftObj, 0x7C713BD7}, |
| 291 | + {dbGCellGridObj, 0x645E6090}, |
| 292 | + {dbGDSARefObj, 0xCC5EB4AD}, |
| 293 | + {dbGDSBoundaryObj, 0xE4D136A3}, |
| 294 | + {dbGDSBoxObj, 0x2A7E2FFE}, |
| 295 | + {dbGDSPathObj, 0xE38B6A0A}, |
| 296 | + {dbGDSSRefObj, 0x85F207E7}, |
| 297 | + {dbGDSStructureObj, 0x99297302}, |
| 298 | + {dbGDSTextObj, 0x90DFB402}, |
| 299 | + {dbGlobalConnectObj, 0xA0D52ACE}, |
| 300 | + {dbGroupObj, 0x7A16F67A}, |
| 301 | + {dbGuideObj, 0xE76AA1E9}, |
| 302 | + {dbIsolationObj, 0xB6738B19}, |
| 303 | + {dbLevelShifterObj, 0x861F1D0A}, |
| 304 | + {dbLogicPortObj, 0x2B46CE60}, |
| 305 | + {dbMarkerObj, 0xEB83E7A1}, |
| 306 | + {dbMarkerCategoryObj, 0x4D3FFF1D}, |
| 307 | + {dbMasterEdgeTypeObj, 0x05DBC7F0}, |
| 308 | + {dbMetalWidthViaMapObj, 0x0FD3C974}, |
| 309 | + {dbModBTermObj, 0x7EBE8F33}, |
| 310 | + {dbModInstObj, 0xAFA31C35}, |
| 311 | + {dbModITermObj, 0xFAC1E1FA}, |
| 312 | + {dbModNetObj, 0xDFD34354}, |
| 313 | + {dbModuleObj, 0x9F568C6F}, |
| 314 | + {dbNetTrackObj, 0x6D3EE435}, |
| 315 | + {dbPolygonObj, 0x110F3173}, |
| 316 | + {dbPowerDomainObj, 0x7352FE40}, |
| 317 | + {dbPowerSwitchObj, 0x7D280800}, |
| 318 | + {dbScanChainObj, 0xBF9698BF}, |
| 319 | + {dbScanInstObj, 0x05CD9D4A}, |
| 320 | + {dbScanListObj, 0xD398101E}, |
| 321 | + {dbScanPartitionObj, 0x534639A0}, |
| 322 | + {dbScanPinObj, 0x2BA03C39}, |
| 323 | + {dbTechLayerObj, 0x4ED3B51C}, |
| 324 | + {dbTechLayerAreaRuleObj, 0x2C0432EB}, |
| 325 | + {dbTechLayerArraySpacingRuleObj, 0x1904C344}, |
| 326 | + {dbTechLayerCornerSpacingRuleObj, 0x598158F4}, |
| 327 | + {dbTechLayerCutClassRuleObj, 0xE1F72282}, |
| 328 | + {dbTechLayerCutEnclosureRuleObj, 0xFFC5F736}, |
| 329 | + {dbTechLayerCutSpacingRuleObj, 0xB78E788B}, |
| 330 | + {dbTechLayerCutSpacingTableDefRuleObj, 0x79DFAE70}, |
| 331 | + {dbTechLayerCutSpacingTableOrthRuleObj, 0xA5373824}, |
| 332 | + {dbTechLayerEolExtensionRuleObj, 0x49B1981B}, |
| 333 | + {dbTechLayerEolKeepOutRuleObj, 0x88B0E445}, |
| 334 | + {dbTechLayerForbiddenSpacingRuleObj, 0x139CF020}, |
| 335 | + {dbTechLayerKeepOutZoneRuleObj, 0x0AD77253}, |
| 336 | + {dbTechLayerMaxSpacingRuleObj, 0xA65D53B9}, |
| 337 | + {dbTechLayerMinCutRuleObj, 0x4BA55CDE}, |
| 338 | + {dbTechLayerMinStepRuleObj, 0x6BE58714}, |
| 339 | + {dbTechLayerSpacingEolRuleObj, 0x49E7A7BD}, |
| 340 | + {dbTechLayerSpacingTablePrlRuleObj, 0xA223F41D}, |
| 341 | + {dbTechLayerTwoWiresForbiddenSpcRuleObj, 0x7C5FB405}, |
| 342 | + {dbTechLayerWidthTableRuleObj, 0x7BF3D392}, |
| 343 | + {dbTechLayerWrongDirSpacingRuleObj, 0xF73FA7DF}, |
| 344 | + // Generator Code End ObjectTypeToHash |
| 345 | + |
| 346 | + // Lib Objects |
| 347 | + {dbLibObj, 0x52}, |
| 348 | + {dbGDSLibObj, 0x53}, |
| 349 | + {dbSiteObj, 0x54}, |
| 350 | + {dbMasterObj, 0x55}, |
| 351 | + {dbMPinObj, 0x56}, |
| 352 | + {dbMTermObj, 0x57}, |
| 353 | + {dbTechAntennaPinModelObj, 0x58}, |
| 354 | + |
| 355 | + // Tech Objects |
| 356 | + {dbTechObj, 0x59}, |
| 357 | + {dbTechViaObj, 0x5A}, |
| 358 | + {dbTechNonDefaultRuleObj, 0x5B}, |
| 359 | + {dbTechLayerRuleObj, 0x5C}, |
| 360 | + {dbTechSameNetRuleObj, 0x5D}, |
| 361 | + {dbTechLayerSpacingRuleObj, 0x5E}, |
| 362 | + {dbTechMinCutRuleObj, 0x5F}, |
| 363 | + {dbTechMinEncRuleObj, 0x60}, |
| 364 | + {dbTechV55InfluenceEntryObj, 0x61}, |
| 365 | + {dbTechLayerAntennaRuleObj, 0x62}, |
| 366 | + {dbTechViaRuleObj, 0x63}, |
| 367 | + {dbTechViaGenerateRuleObj, 0x64}, |
| 368 | + {dbTechViaLayerRuleObj, 0x65}, |
| 369 | + |
| 370 | + {dbPropertyObj, 0x66}, |
| 371 | + {dbNameObj, 0x67}}; |
| 372 | + |
142 | 373 | const char* dbObject::getTypeName() const |
143 | 374 | { |
144 | 375 | return name_tbl[getImpl()->getType()]; |
@@ -182,4 +413,18 @@ bool compare_by_id(const dbObject* lhs, const dbObject* rhs) |
182 | 413 | return compare_by_id(lhs_owner, rhs_owner); |
183 | 414 | } |
184 | 415 |
|
| 416 | +dbIStream& operator>>(dbIStream& stream, dbObjectType& type) |
| 417 | +{ |
| 418 | + uint32_t hash; |
| 419 | + stream >> hash; |
| 420 | + type = hash_to_object_type.at(hash); |
| 421 | + return stream; |
| 422 | +} |
| 423 | + |
| 424 | +dbOStream& operator<<(dbOStream& stream, dbObjectType type) |
| 425 | +{ |
| 426 | + stream << object_type_to_hash.at(type); |
| 427 | + return stream; |
| 428 | +} |
| 429 | + |
185 | 430 | } // namespace odb |
0 commit comments