Skip to content
Open
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
38 changes: 38 additions & 0 deletions src/odb/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -78,6 +78,44 @@ database to have exactly the same layout across save/restores.

The database distance units are **nanometers** and use the type `uint32_t`.

### Add Corner

Specifies a process corner for the current block. Corner names must be unique
within a block, so the command fails if a corner with the same name already
exists.

```tcl
add_corner corner_name
```

#### Options

| Switch Name | Description |
| ----- | ----- |
| `corner_name` | Name of the process corner to add. |

### Remove Corner

Removes a process corner from the current block.

```tcl
remove_corner corner_name
```

#### Options

| Switch Name | Description |
| ----- | ----- |
| `corner_name` | Name of the process corner to remove. |

### Remove Corners

Removes all process corners from the current block.

```tcl
remove_corners
```

### Create Physical Cluster

Description TBC.
Expand Down
21 changes: 21 additions & 0 deletions src/odb/include/odb/db.h
Original file line number Diff line number Diff line change
Expand Up @@ -121,6 +121,7 @@ class dbChipNet;
class dbChipPath;
class dbChipRegion;
class dbChipRegionInst;
class dbCorner;
class dbDatabase;
class dbDft;
class dbGCellGrid;
Expand Down Expand Up @@ -1026,6 +1027,14 @@ class dbBlock : public dbObject
///
int getCornerCount();

void addCorner(const std::string& corner_name);

dbCorner* findCorner(const std::string& corner_name) const;

void removeCorner(const std::string& corner_name);

void removeCorners();

///
/// Get the number of corners kept n this block
///
Expand Down Expand Up @@ -7575,6 +7584,18 @@ class dbChipRegionInst : public dbObject
// User Code End dbChipRegionInst
};

class dbCorner : public dbObject
{
public:
const std::string& getName() const;

// User Code Begin dbCorner
static dbCorner* create(dbBlock* block_, const std::string& corner_name);

static void destroy(dbCorner* corner_);
// User Code End dbCorner
};

class dbDatabase : public dbObject
{
public:
Expand Down
7 changes: 7 additions & 0 deletions src/odb/include/odb/dbCompare.inc
Original file line number Diff line number Diff line change
Expand Up @@ -392,6 +392,13 @@ struct less<odb::dbChipRegionInst*>
= delete;
};

template <>
struct less<odb::dbCorner*>
{
bool operator()(const odb::dbCorner* lhs, const odb::dbCorner* rhs) const
= delete;
};

template <>
struct less<odb::dbDatabase*>
{
Expand Down
1 change: 1 addition & 0 deletions src/odb/include/odb/dbObject.h
Original file line number Diff line number Diff line change
Expand Up @@ -70,6 +70,7 @@ enum dbObjectType
dbChipPathObj,
dbChipRegionObj,
dbChipRegionInstObj,
dbCornerObj,
dbDatabaseObj,
dbDftObj,
dbGCellGridObj,
Expand Down
11 changes: 11 additions & 0 deletions src/odb/src/codeGenerator/schema/chip/dbCorner.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
{
"name": "dbCorner",
"type": "dbObject",
"fields": [
{
"name": "name_",
"type": "std::string",
"flags":["cmpgt", "no-set"]
}
]
}
1 change: 1 addition & 0 deletions src/odb/src/db/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -103,6 +103,7 @@ add_library(db
dbChipPath.cpp
dbChipRegion.cpp
dbChipRegionInst.cpp
dbCorner.cpp
dbDatabase.cpp
dbDft.cpp
dbGCellGrid.cpp
Expand Down
95 changes: 95 additions & 0 deletions src/odb/src/db/dbBlock.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,7 @@
#include "dbChip.h"
#include "dbCommon.h"
#include "dbCore.h"
#include "dbCorner.h"
#include "dbDatabase.h"
#include "dbDft.h"
#include "dbFill.h"
Expand Down Expand Up @@ -116,6 +117,7 @@
#include "dbTechLayerRule.h"
#include "dbTechNonDefaultRule.h"
#include "dbTrackGrid.h"
#include "dbVector.h"
#include "dbVia.h"
#include "dbWire.h"
#include "odb/PtrSetMap.h"
Expand Down Expand Up @@ -245,6 +247,9 @@ _dbBlock::_dbBlock(_dbDatabase* db)
net_tracks_tbl_ = new dbTable<_dbNetTrack>(
db, this, (GetObjTbl_t) &_dbBlock::getObjectTable, dbNetTrackObj);

corner_tbl_ = new dbTable<_dbCorner>(
db, this, (GetObjTbl_t) &_dbBlock::getObjectTable, dbCornerObj);

box_tbl_ = new dbTable<_dbBox, 1024>(
db, this, (GetObjTbl_t) &_dbBlock::getObjectTable, dbBoxObj);

Expand Down Expand Up @@ -437,6 +442,7 @@ _dbBlock::~_dbBlock()
delete global_connect_tbl_;
delete guide_tbl_;
delete net_tracks_tbl_;
delete corner_tbl_;
delete box_tbl_;
delete via_tbl_;
delete gcell_grid_tbl_;
Expand Down Expand Up @@ -616,6 +622,9 @@ dbObjectTable* _dbBlock::getObjectTable(dbObjectType type)
case dbNetTrackObj:
return net_tracks_tbl_;

case dbCornerObj:
return corner_tbl_;

case dbNetObj:
return net_tbl_;

Expand Down Expand Up @@ -780,6 +789,7 @@ dbOStream& operator<<(dbOStream& stream, const _dbBlock& block)
stream << block.max_cc_seg_id_;
stream << block.children_;
stream << block.component_mask_shift_;
stream << block.corners_;
stream << block.currentCcAdjOrder_;

stream << *block.bterm_tbl_;
Expand All @@ -804,6 +814,7 @@ dbOStream& operator<<(dbOStream& stream, const _dbBlock& block)
stream << *block.global_connect_tbl_;
stream << *block.guide_tbl_;
stream << *block.net_tracks_tbl_;
stream << *block.corner_tbl_;
stream << *block.box_tbl_;
stream << *block.via_tbl_;
stream << *block.gcell_grid_tbl_;
Expand Down Expand Up @@ -975,6 +986,9 @@ dbIStream& operator>>(dbIStream& stream, _dbBlock& block)
if (db->isSchema(kSchemaBlockComponentMaskShift)) {
stream >> block.component_mask_shift_;
}
if (db->isSchema(kSchemaCorner)) {
stream >> block.corners_;
}
stream >> block.currentCcAdjOrder_;
stream >> *block.bterm_tbl_;
stream >> *block.iterm_tbl_;
Expand Down Expand Up @@ -1041,6 +1055,9 @@ dbIStream& operator>>(dbIStream& stream, _dbBlock& block)
if (db->isSchema(kSchemaNetTracks)) {
stream >> *block.net_tracks_tbl_;
}
if (db->isSchema(kSchemaCorner)) {
stream >> *block.corner_tbl_;
}
stream >> *block.box_tbl_;
stream >> *block.via_tbl_;
stream >> *block.gcell_grid_tbl_;
Expand Down Expand Up @@ -1336,6 +1353,9 @@ bool _dbBlock::operator==(const _dbBlock& rhs) const
if (children_ != rhs.children_) {
return false;
}
if (corners_ != rhs.corners_) {
return false;
}

if (component_mask_shift_ != rhs.component_mask_shift_) {
return false;
Expand Down Expand Up @@ -1411,6 +1431,10 @@ bool _dbBlock::operator==(const _dbBlock& rhs) const
return false;
}

if (*corner_tbl_ != *rhs.corner_tbl_) {
return false;
}

if (*box_tbl_ != *rhs.box_tbl_) {
return false;
}
Expand Down Expand Up @@ -2871,6 +2895,75 @@ void dbBlock::setCornerCount(int cornersStoredCnt,
}
}

dbCorner* dbBlock::findCorner(const std::string& corner_name) const
{
_dbBlock* block = (_dbBlock*) this;

for (const dbId<_dbCorner> corner_id : block->corners_) {
_dbCorner* corner = block->corner_tbl_->getPtr(corner_id);

if (corner->name_ == corner_name) {
return (dbCorner*) corner;
}
}

return nullptr;
}

void dbBlock::addCorner(const std::string& corner_name)
{
utl::Logger* logger = getImpl()->getLogger();

if (corner_name.empty()) {
logger->error(
utl::ODB, 9, "Could not add corner. Empty name is not allowed.");
}

if (findCorner(corner_name)) {
logger->error(
utl::ODB,
5,
"Could not add corner {}. A corner with that name already exists.",
corner_name);
}

dbCorner* corner_ = dbCorner::create(this, corner_name);

_dbBlock* block = (_dbBlock*) this;
block->corners_.push_back(corner_->getId());
}

void dbBlock::removeCorner(const std::string& corner_name)
{
dbCorner* corner_ = findCorner(corner_name);

if (!corner_) {
utl::Logger* logger = getImpl()->getLogger();
logger->error(utl::ODB,
6,
"Could not remove corner {}. No corner with that name "
"exists.",
corner_name);
}

_dbBlock* block = (_dbBlock*) this;

// Note that std::ranges::find requires the search value
// to be the same type as the range's elements.
const auto corner_id = (dbId<_dbCorner>) corner_->getId();
auto corner_position = std::ranges::find(block->corners_, corner_id);
block->corners_.erase(corner_position);
Comment thread
AcKoucher marked this conversation as resolved.
Outdated

dbCorner::destroy(corner_);
}

void dbBlock::removeCorners()
{
_dbBlock* block = (_dbBlock*) this;
block->corners_.clear();
block->corner_tbl_->clear();
}

char* dbBlock::getCornerNameList()
{
_dbBlock* block = (_dbBlock*) this;
Expand Down Expand Up @@ -3722,6 +3815,7 @@ void _dbBlock::collectMemInfo(MemInfo& info)
info.children["bterm_hash"].add(bterm_hash_);

info.children["children"].add(children_);
info.children["corners"].add(corners_);
info.children["component_mask_shift"].add(component_mask_shift_);

bterm_tbl_->collectMemInfo(info.children["bterm"]);
Expand Down Expand Up @@ -3758,6 +3852,7 @@ void _dbBlock::collectMemInfo(MemInfo& info)
global_connect_tbl_->collectMemInfo(info.children["global_connect"]);
guide_tbl_->collectMemInfo(info.children["guide"]);
net_tracks_tbl_->collectMemInfo(info.children["net_tracks"]);
corner_tbl_->collectMemInfo(info.children["corner"]);
dft_tbl_->collectMemInfo(info.children["dft"]);
modbterm_tbl_->collectMemInfo(info.children["modbterm"]);
moditerm_tbl_->collectMemInfo(info.children["moditerm"]);
Expand Down
3 changes: 3 additions & 0 deletions src/odb/src/db/dbBlock.h
Original file line number Diff line number Diff line change
Expand Up @@ -76,6 +76,7 @@ class _dbAccessPoint;
class _dbGlobalConnect;
class _dbGuide;
class _dbNetTrack;
class _dbCorner;
class _dbMarkerCategory;
class dbJournal;

Expand Down Expand Up @@ -219,6 +220,7 @@ class _dbBlock : public _dbObject
uint32_t max_cc_seg_id_;
dbVector<dbId<_dbBlock>> children_;
dbVector<dbId<_dbTechLayer>> component_mask_shift_;
dbVector<dbId<_dbCorner>> corners_;
uint32_t currentCcAdjOrder_;
dbId<_dbDft> dft_;
int min_routing_layer_;
Expand Down Expand Up @@ -267,6 +269,7 @@ class _dbBlock : public _dbObject
dbTable<_dbGlobalConnect>* global_connect_tbl_;
dbTable<_dbGuide>* guide_tbl_;
dbTable<_dbNetTrack>* net_tracks_tbl_;
dbTable<_dbCorner>* corner_tbl_;
_dbNameCache* name_cache_;
dbTable<_dbDft, 4096>* dft_tbl_;

Expand Down
Loading
Loading