Skip to content

Commit 4b98962

Browse files
authored
Merge pull request #8016 from osamahammad21/odb-chipinst
ODB: add dbChipInst
2 parents 107ebee + 8ba57be commit 4b98962

File tree

20 files changed

+737
-7
lines changed

20 files changed

+737
-7
lines changed

src/odb/include/odb/db.h

Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -106,6 +106,7 @@ class dbAccessPoint;
106106
class dbBusPort;
107107
class dbCellEdgeSpacing;
108108
class dbChip;
109+
class dbChipInst;
109110
class dbDatabase;
110111
class dbDft;
111112
class dbGCellGrid;
@@ -7002,6 +7003,8 @@ class dbChip : public dbObject
70027003
///
70037004
dbBlock* getBlock();
70047005

7006+
dbSet<dbChipInst> getChipInsts() const;
7007+
70057008
///
70067009
/// Create a new chip.
70077010
/// Returns nullptr if there is no database technology.
@@ -7022,6 +7025,34 @@ class dbChip : public dbObject
70227025
// User Code End dbChip
70237026
};
70247027

7028+
class dbChipInst : public dbObject
7029+
{
7030+
public:
7031+
std::string getName() const;
7032+
7033+
void setLoc(const Point3D& loc);
7034+
7035+
Point3D getLoc() const;
7036+
7037+
dbChip* getMasterChip() const;
7038+
7039+
dbChip* getParentChip() const;
7040+
7041+
// User Code Begin dbChipInst
7042+
void setOrient(const dbOrientType& orient);
7043+
7044+
dbOrientType getOrient() const;
7045+
7046+
dbTransform getTransform() const;
7047+
7048+
static odb::dbChipInst* create(dbChip* parent_chip,
7049+
dbChip* master_chip,
7050+
const std::string& name);
7051+
7052+
static void destroy(dbChipInst* chipInst);
7053+
// User Code End dbChipInst
7054+
};
7055+
70257056
class dbDatabase : public dbObject
70267057
{
70277058
public:
@@ -7031,6 +7062,8 @@ class dbDatabase : public dbObject
70317062

70327063
dbSet<dbProperty> getProperties() const;
70337064

7065+
dbSet<dbChipInst> getChipInsts() const;
7066+
70347067
// User Code Begin dbDatabase
70357068

70367069
void setTopChip(dbChip* chip);

src/odb/include/odb/dbCompare.h

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -479,6 +479,15 @@ struct less<odb::dbChip*>
479479
}
480480
};
481481

482+
template <>
483+
struct less<odb::dbChipInst*>
484+
{
485+
bool operator()(const odb::dbChipInst* lhs, const odb::dbChipInst* rhs) const
486+
{
487+
return odb::compare_by_id(lhs, rhs);
488+
}
489+
};
490+
482491
template <>
483492
struct less<odb::dbDatabase*>
484493
{

src/odb/include/odb/dbObject.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -61,6 +61,7 @@ enum dbObjectType
6161
dbBusPortObj,
6262
dbCellEdgeSpacingObj,
6363
dbChipObj,
64+
dbChipInstObj,
6465
dbDatabaseObj,
6566
dbDftObj,
6667
dbGCellGridObj,

src/odb/include/odb/geom.h

Lines changed: 49 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -57,13 +57,51 @@ class Point
5757
friend dbIStream& operator>>(dbIStream& stream, Point& p);
5858
friend dbOStream& operator<<(dbOStream& stream, const Point& p);
5959

60-
private:
60+
protected:
6161
int x_ = 0;
6262
int y_ = 0;
6363
};
6464

6565
std::ostream& operator<<(std::ostream& os, const Point& pIn);
6666

67+
class Point3D
68+
{
69+
public:
70+
Point3D() = default;
71+
Point3D(int x, int y, int z) : x_(x), y_(y), z_(z) {}
72+
Point3D& operator=(const Point3D&) = default;
73+
Point3D(const Point3D& p) : x_(p.x()), y_(p.y()), z_(p.z()) {}
74+
Point3D(const Point& p, int z) : x_(p.x()), y_(p.y()), z_(z) {}
75+
76+
bool operator==(const Point3D& rhs) const;
77+
bool operator!=(const Point3D& rhs) const { return !(*this == rhs); }
78+
bool operator<(const Point3D& rhs) const;
79+
bool operator>=(const Point3D& rhs) const { return !(*this < rhs); }
80+
81+
int z() const { return z_; }
82+
void setZ(int z) { z_ = z; }
83+
int x() const { return x_; }
84+
void setX(int x) { x_ = x; }
85+
int y() const { return y_; }
86+
void setY(int y) { y_ = y; }
87+
void set(const int x, const int y, const int z)
88+
{
89+
setX(x);
90+
setY(y);
91+
setZ(z);
92+
}
93+
94+
friend dbIStream& operator>>(dbIStream& stream, Point3D& p);
95+
friend dbOStream& operator<<(dbOStream& stream, const Point3D& p);
96+
97+
private:
98+
int x_ = 0;
99+
int y_ = 0;
100+
int z_ = 0;
101+
};
102+
103+
std::ostream& operator<<(std::ostream& os, const Point3D& pIn);
104+
67105
/*
68106
an Oct represents a 45-degree routing segment as 2 connected octagons
69107
@@ -443,6 +481,16 @@ inline bool Point::operator<(const Point& rhs) const
443481
return std::tie(x_, y_) < std::tie(rhs.x_, rhs.y_);
444482
}
445483

484+
inline bool Point3D::operator==(const Point3D& rhs) const
485+
{
486+
return std::tie(x_, y_, z_) == std::tie(rhs.x_, rhs.y_, rhs.z_);
487+
}
488+
489+
inline bool Point3D::operator<(const Point3D& rhs) const
490+
{
491+
return std::tie(x_, y_, z_) < std::tie(rhs.x_, rhs.y_, rhs.z_);
492+
}
493+
446494
inline bool Rect::operator<(const Rect& rhs) const
447495
{
448496
return std::tie(xlo_, ylo_, xhi_, yhi_)

src/odb/src/codeGenerator/gen.py

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -128,10 +128,12 @@ def add_field_attributes(field, klass, flags_struct, schema):
128128
field["isHashTable"] = is_hash_table(field["type"])
129129
field["hashTableType"] = get_hash_table_type(field["type"])
130130
field["isPassByRef"] = is_pass_by_ref(field["type"])
131-
field["isSetByRef"] = is_set_by_ref(field["type"])
131+
field.setdefault("flags", [])
132+
field["isSetByRef"] = "set-const-ref" in field["flags"] or is_set_by_ref(
133+
field["type"]
134+
)
132135
if "argument" not in field:
133136
field["argument"] = field["name"].strip("_")
134-
field.setdefault("flags", [])
135137
if "private" in field["flags"]:
136138
field["flags"].append("no-set")
137139
field["flags"].append("no-get")

src/odb/src/codeGenerator/schema.json

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -162,6 +162,15 @@
162162
"orderReversed": "true",
163163
"sequential": 0,
164164
"includes": ["dbScanList.h", "dbScanInst.h"]
165+
},
166+
{
167+
"name": "dbChipInstItr",
168+
"parentObject": "dbChipInst",
169+
"tableName": "chip_inst_tbl",
170+
"reversible": "true",
171+
"orderReversed": "true",
172+
"sequential": 0,
173+
"includes": ["dbChipInst.h", "dbChip.h"]
165174
}
166175
],
167176
"relations":[
@@ -387,6 +396,14 @@
387396
"type":"1_n",
388397
"tbl_name":"_prop_tbl",
389398
"flags": ["no-serial"]
399+
},
400+
{
401+
"parent":"dbDatabase",
402+
"child":"dbChipInst",
403+
"type":"1_n",
404+
"tbl_name":"chip_inst_tbl_",
405+
"schema":"db_schema_chip_inst",
406+
"flags": ["no-serial"]
390407
}
391408
]
392409
}

src/odb/src/codeGenerator/schema/chip/dbChip.json

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -142,6 +142,12 @@
142142
"name": "_prop_itr",
143143
"type": "dbPropertyItr*",
144144
"flags": ["private", "no-cmp", "no-serial"]
145+
},
146+
{
147+
"name": "chipinsts_",
148+
"type": "dbId<_dbChipInst>",
149+
"flags": ["private"],
150+
"schema":"db_schema_chip_inst"
145151
}
146152
],
147153
"declared_classes": ["dbPropertyItr", "_dbNameCache","dbBlockItr"],
Lines changed: 43 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,43 @@
1+
{
2+
"name": "dbChipInst",
3+
"type": "dbObject",
4+
"fields": [
5+
{
6+
"name": "name_",
7+
"type": "std::string",
8+
"flags":["cmpgt", "no-set"]
9+
},
10+
{
11+
"name": "loc_",
12+
"type": "Point3D",
13+
"flags":["cmpgt", "set-const-ref"]
14+
},
15+
{
16+
"name": "orient_",
17+
"type": "dbOrientType::Value",
18+
"flags": ["private" ,"cmpgt", "no-serial"]
19+
},
20+
{
21+
"name": "master_chip_",
22+
"type": "dbId<_dbChip>",
23+
"flags": ["no-set"],
24+
"parent" : "dbDatabase"
25+
},
26+
{
27+
"name": "parent_chip_",
28+
"type": "dbId<_dbChip>",
29+
"flags": ["no-set"],
30+
"parent":"dbDatabase"
31+
},
32+
{
33+
"name":"chipinst_next_",
34+
"type":"dbId<_dbChipInst>",
35+
"flags":["private"]
36+
}
37+
],
38+
"h_includes": [
39+
"odb/geom.h",
40+
"odb/dbTypes.h"
41+
],
42+
"cpp_includes": []
43+
}

src/odb/src/db/CMakeLists.txt

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -88,6 +88,7 @@ add_library(db
8888
dbBusPort.cpp
8989
dbCellEdgeSpacing.cpp
9090
dbChip.cpp
91+
dbChipInst.cpp
9192
dbDatabase.cpp
9293
dbDft.cpp
9394
dbGCellGrid.cpp
@@ -144,6 +145,7 @@ add_library(db
144145
dbTechLayerTwoWiresForbiddenSpcRule.cpp
145146
dbTechLayerWidthTableRule.cpp
146147
dbTechLayerWrongDirSpacingRule.cpp
148+
dbChipInstItr.cpp
147149
dbGroupInstItr.cpp
148150
dbGroupItr.cpp
149151
dbGroupModInstItr.cpp

src/odb/src/db/dbChip.cpp

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,10 @@
1515
#include "dbTech.h"
1616
#include "odb/db.h"
1717
#include "odb/dbSet.h"
18+
// User Code Begin Includes
19+
#include "dbChipInst.h"
20+
#include "dbChipInstItr.h"
21+
// User Code End Includes
1822
namespace odb {
1923
template class dbTable<_dbChip>;
2024

@@ -71,6 +75,9 @@ bool _dbChip::operator==(const _dbChip& rhs) const
7175
if (_top != rhs._top) {
7276
return false;
7377
}
78+
if (chipinsts_ != rhs.chipinsts_) {
79+
return false;
80+
}
7481
if (*_prop_tbl != *rhs._prop_tbl) {
7582
return false;
7683
}
@@ -181,6 +188,9 @@ dbIStream& operator>>(dbIStream& stream, _dbChip& obj)
181188
stream >> obj.tsv_;
182189
}
183190
stream >> obj._top;
191+
if (obj.getDatabase()->isSchema(db_schema_chip_inst)) {
192+
stream >> obj.chipinsts_;
193+
}
184194
// User Code Begin >>
185195
stream >> *obj._block_tbl;
186196
stream >> *obj._prop_tbl;
@@ -212,6 +222,7 @@ dbOStream& operator<<(dbOStream& stream, const _dbChip& obj)
212222
stream << obj.scribe_line_south_;
213223
stream << obj.tsv_;
214224
stream << obj._top;
225+
stream << obj.chipinsts_;
215226
// User Code Begin <<
216227
stream << *obj._block_tbl;
217228
stream << NamedTable("prop_tbl", obj._prop_tbl);
@@ -475,6 +486,13 @@ dbBlock* dbChip::getBlock()
475486
return (dbBlock*) chip->_block_tbl->getPtr(chip->_top);
476487
}
477488

489+
dbSet<dbChipInst> dbChip::getChipInsts() const
490+
{
491+
_dbChip* chip = (_dbChip*) this;
492+
_dbDatabase* db = (_dbDatabase*) chip->getOwner();
493+
return dbSet<dbChipInst>(chip, db->chip_inst_itr_);
494+
}
495+
478496
dbChip* dbChip::create(dbDatabase* db_, const std::string& name, ChipType type)
479497
{
480498
_dbDatabase* db = (_dbDatabase*) db_;

0 commit comments

Comments
 (0)