Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
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
7 changes: 4 additions & 3 deletions src/odb/include/odb/db.h
Original file line number Diff line number Diff line change
Expand Up @@ -7120,14 +7120,15 @@ class dbChipInst : public dbObject

Point3D getLoc() const;

void setOrient(dbOrientType3D orient);

dbOrientType3D getOrient() const;

dbChip* getMasterChip() const;

dbChip* getParentChip() const;

// User Code Begin dbChipInst
void setOrient(const dbOrientType& orient);

dbOrientType getOrient() const;

dbTransform getTransform() const;

Expand Down
38 changes: 38 additions & 0 deletions src/odb/include/odb/dbTypes.h
Original file line number Diff line number Diff line change
Expand Up @@ -99,6 +99,44 @@ class dbOrientType
Value _value;
};

class dbOrientType3D
{
public:
static std::optional<dbOrientType3D> fromString(const std::string orient);

dbOrientType3D(const std::string orient);

dbOrientType3D(const char* orient);

///
/// Create a dbOrientType3D instance with an explicit orientation.
///
dbOrientType3D(const dbOrientType& orient, bool mirror_z);

dbOrientType3D() = default;

///
/// Copy constructor.
///
dbOrientType3D(const dbOrientType3D& orient) = default;

///
/// Returns the orientation as a string
///
std::string getString() const;

dbOrientType getOrientType2D() const;

bool isMirrorZ() const;

friend dbIStream& operator>>(dbIStream& stream, dbOrientType3D& t);
friend dbOStream& operator<<(dbOStream& stream, dbOrientType3D t);

private:
dbOrientType::Value value_{dbOrientType::R0};
bool mirror_z_{false};
};

class dbGDSSTrans
{
public:
Expand Down
5 changes: 2 additions & 3 deletions src/odb/src/codeGenerator/schema/chip/dbChipInst.json
Original file line number Diff line number Diff line change
Expand Up @@ -14,9 +14,8 @@
},
{
"name": "orient_",
"type": "dbOrientType::Value",
"flags": ["private" ,"cmpgt", "no-serial"],
"default": "dbOrientType::R0"
"type": "dbOrientType3D",
"flags": []
},
{
"name": "master_chip_",
Expand Down
32 changes: 17 additions & 15 deletions src/odb/src/db/dbChipInst.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -58,13 +58,13 @@ bool _dbChipInst::operator<(const _dbChipInst& rhs) const

_dbChipInst::_dbChipInst(_dbDatabase* db)
{
orient_ = dbOrientType::R0;
}

dbIStream& operator>>(dbIStream& stream, _dbChipInst& obj)
{
stream >> obj.name_;
stream >> obj.loc_;
stream >> obj.orient_;
stream >> obj.master_chip_;
stream >> obj.parent_chip_;
stream >> obj.chipinst_next_;
Expand All @@ -78,6 +78,7 @@ dbOStream& operator<<(dbOStream& stream, const _dbChipInst& obj)
{
stream << obj.name_;
stream << obj.loc_;
stream << obj.orient_;
stream << obj.master_chip_;
stream << obj.parent_chip_;
stream << obj.chipinst_next_;
Expand Down Expand Up @@ -116,6 +117,19 @@ Point3D dbChipInst::getLoc() const
return obj->loc_;
}

void dbChipInst::setOrient(dbOrientType3D orient)
{
_dbChipInst* obj = (_dbChipInst*) this;

obj->orient_ = orient;
}

dbOrientType3D dbChipInst::getOrient() const
{
_dbChipInst* obj = (_dbChipInst*) this;
return obj->orient_;
}

dbChip* dbChipInst::getMasterChip() const
{
_dbChipInst* obj = (_dbChipInst*) this;
Expand All @@ -137,23 +151,13 @@ dbChip* dbChipInst::getParentChip() const
}

// User Code Begin dbChipInstPublicMethods
void dbChipInst::setOrient(const dbOrientType& orient)
{
_dbChipInst* obj = (_dbChipInst*) this;
obj->orient_ = orient;
}

dbOrientType dbChipInst::getOrient() const
{
_dbChipInst* obj = (_dbChipInst*) this;
return obj->orient_;
}

dbTransform dbChipInst::getTransform() const
{
_dbChipInst* obj = (_dbChipInst*) this;
// TODO: Add 3d Point handling to the transform
return dbTransform(obj->orient_, Point(obj->loc_.x(), obj->loc_.y()));
return dbTransform(obj->orient_.getOrientType2D(),
Point(obj->loc_.x(), obj->loc_.y()));
}

dbSet<dbChipRegionInst> dbChipInst::getRegions() const
Expand Down Expand Up @@ -219,8 +223,6 @@ dbChipInst* dbChipInst::create(dbChip* parent_chip,
// Initialize the chip instance
chipinst->name_ = name;
chipinst->loc_ = Point3D(0, 0, 0); // Default location
chipinst->orient_
= dbOrientType::R0; // Default orientation (already set in constructor)
chipinst->master_chip_ = _master->getOID();
chipinst->parent_chip_ = _parent->getOID();

Expand Down
2 changes: 1 addition & 1 deletion src/odb/src/db/dbChipInst.h
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ class _dbChipInst : public _dbObject

std::string name_;
Point3D loc_;
dbOrientType::Value orient_;
dbOrientType3D orient_;
dbId<_dbChip> master_chip_;
dbId<_dbChip> parent_chip_;
dbId<_dbChipInst> chipinst_next_;
Expand Down
78 changes: 76 additions & 2 deletions src/odb/src/db/dbTypes.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -30,11 +30,13 @@ std::optional<dbOrientType::Value> dbOrientType::fromString(const char* orient)
ret = R270;
} else if (strcasecmp(orient, "MY") == 0) {
ret = MY;
} else if (strcasecmp(orient, "MYR90") == 0) {
} else if (strcasecmp(orient, "MYR90") == 0
|| strcasecmp(orient, "MY_R90") == 0) {
ret = MYR90;
} else if (strcasecmp(orient, "MX") == 0) {
ret = MX;
} else if (strcasecmp(orient, "MXR90") == 0) {
} else if (strcasecmp(orient, "MXR90") == 0
|| strcasecmp(orient, "MX_R90") == 0) {
ret = MXR90;
} else if (strcasecmp(orient, "N") == 0) { // LEF/DEF style names
ret = R0;
Expand Down Expand Up @@ -186,6 +188,62 @@ bool dbOrientType::isRightAngleRotation() const
return false;
}

std::optional<dbOrientType3D> dbOrientType3D::fromString(
const std::string orient)
{
std::string orient_str = orient;
bool flipZ = false;
// check if the orient string contains "MZ"
if (orient_str.find("MZ_") != std::string::npos) {
flipZ = true;
orient_str = orient_str.erase(orient_str.find("MZ_"), 3);
}
auto opt = dbOrientType::fromString(orient_str.c_str());
if (!opt.has_value()) {
return std::nullopt;
}
return dbOrientType3D(opt.value(), flipZ);
}

dbOrientType3D::dbOrientType3D(const char* orient)
{
auto opt = fromString(orient);
if (opt.has_value()) {
value_ = opt.value().value_;
mirror_z_ = opt.value().mirror_z_;
} else {
value_ = dbOrientType::DEFAULT;
mirror_z_ = false;
}
}

dbOrientType3D::dbOrientType3D(const dbOrientType& orient, bool mirror_z)
{
value_ = orient.getValue();
mirror_z_ = mirror_z;
}

std::string dbOrientType3D::getString() const
{
std::string orient_2d_str = getOrientType2D().getString();
if (orient_2d_str == "MXR90") {
orient_2d_str = "MX_R90";
} else if (orient_2d_str == "MYR90") {
orient_2d_str = "MY_R90";
}
return (mirror_z_ ? "MZ_" : "") + orient_2d_str;
}

dbOrientType dbOrientType3D::getOrientType2D() const
{
return value_;
}

bool dbOrientType3D::isMirrorZ() const
{
return mirror_z_;
}

dbGDSSTrans::dbGDSSTrans()
{
_flipX = false;
Expand Down Expand Up @@ -269,6 +327,22 @@ dbOStream& operator<<(dbOStream& stream, const dbGDSSTrans t)
return stream;
}

dbIStream& operator>>(dbIStream& stream, dbOrientType3D& t)
{
uint8_t value;
stream >> value;
t.value_ = static_cast<dbOrientType::Value>(value);
stream >> t.mirror_z_;
return stream;
}

dbOStream& operator<<(dbOStream& stream, const dbOrientType3D t)
{
stream << static_cast<uint8_t>(t.value_);
stream << t.mirror_z_;
return stream;
}

dbIStream& operator>>(dbIStream& stream, dbGDSTextPres& t)
{
uint8_t vPresTemp, hPresTemp;
Expand Down
7 changes: 7 additions & 0 deletions src/odb/test/cpp/TestChips.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -80,6 +80,7 @@ struct F_CHIP_HIERARCHY
// Position components
memory_inst->setLoc(Point3D(2500, 500, 0));
cache_inst->setLoc(Point3D(100, 100, 50));
cache_inst->setOrient(dbOrientType3D("MZ_MY_R90"));
}

~F_CHIP_HIERARCHY() { dbDatabase::destroy(db); }
Expand Down Expand Up @@ -191,11 +192,17 @@ BOOST_FIXTURE_TEST_CASE(test_chip_hierarchy, F_CHIP_HIERARCHY)
BOOST_TEST(memory_loc.x() == 2500);
BOOST_TEST(memory_loc.y() == 500);
BOOST_TEST(memory_loc.z() == 0);
BOOST_TEST(memory_inst->getOrient().getOrientType2D() == dbOrientType::R0);
BOOST_TEST(memory_inst->getOrient().isMirrorZ() == false);
BOOST_TEST(memory_inst->getOrient().getString() == "R0");

Point3D cache_loc = cache_inst->getLoc();
BOOST_TEST(cache_loc.x() == 100);
BOOST_TEST(cache_loc.y() == 100);
BOOST_TEST(cache_loc.z() == 50);
BOOST_TEST(cache_inst->getOrient().getOrientType2D() == dbOrientType::MYR90);
BOOST_TEST(cache_inst->getOrient().isMirrorZ() == true);
BOOST_TEST(cache_inst->getOrient().getString() == "MZ_MY_R90");
}

BOOST_FIXTURE_TEST_CASE(test_chip_complex_destroy, F_CHIP_HIERARCHY)
Expand Down
Loading