Skip to content

Fix ODB: DEF_file in 3dbx (Issue #10077)#10096

Open
openroad-ci wants to merge 4 commits intoThe-OpenROAD-Project:masterfrom
The-OpenROAD-Project-staging:fix-3DBlox-DEF-file
Open

Fix ODB: DEF_file in 3dbx (Issue #10077)#10096
openroad-ci wants to merge 4 commits intoThe-OpenROAD-Project:masterfrom
The-OpenROAD-Project-staging:fix-3DBlox-DEF-file

Conversation

@openroad-ci
Copy link
Copy Markdown
Collaborator

fix issue #10077

Signed-off-by: Jorge Ferreira <jorge.ferreira@precisioninno.com>
@github-actions
Copy link
Copy Markdown
Contributor

github-actions bot commented Apr 9, 2026

clang-tidy review says "All clean, LGTM! 👍"

Copy link
Copy Markdown
Contributor

@gemini-code-assist gemini-code-assist bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Code Review

This pull request introduces logic to read DEF files for chiplets and chip instances, using a boolean property to track whether the file has already been processed. The review highlights a potential for redundant DEF reads in createChiplet due to a missing check, suggests refactoring the duplicated DEF reading logic into a shared helper function, and recommends using std::vector::assign for more efficient population of the search_libs vector.

chiplet.external.def_file.c_str(),
chip,
/*issue_callback*/ false);
odb::dbBoolProperty::create(chip, "def_file_read", true);
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

medium

While setting the def_file_read property here is correct, the corresponding check to see if it's already set (similar to the one added in createChipInst at line 683) is missing at the beginning of the DEF reading block in this function (around line 456). This could lead to redundant DEF reads if createChiplet is called multiple times for the same master chip.

Comment on lines +682 to +696
if (!chip_inst.external.def_file.empty()) {
if (odb::dbProperty::find(chip, "def_file_read") == nullptr) {
if (chip->getBlock() != nullptr) {
odb::dbBlock::destroy(chip->getBlock());
}
odb::defin def_reader(db_, logger_, odb::defin::DEFAULT);
std::vector<odb::dbLib*> search_libs;
for (odb::dbLib* lib : db_->getLibs()) {
search_libs.push_back(lib);
}
def_reader.readChip(
search_libs, chip_inst.external.def_file.c_str(), chip, false);
odb::dbBoolProperty::create(chip, "def_file_read", true);
}
}
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

medium

The logic for reading a DEF file for a chiplet is duplicated between createChiplet and createChipInst. This logic (checking for the property, destroying the existing block, populating search libraries, and reading the chip) should be refactored into a shared free function within a namespace to improve maintainability and ensure consistency.

References
  1. Helper logic should be defined as a free function in a namespace rather than as a local lambda within a function.

Comment on lines +688 to +691
std::vector<odb::dbLib*> search_libs;
for (odb::dbLib* lib : db_->getLibs()) {
search_libs.push_back(lib);
}
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

medium

The population of the search_libs vector can be simplified using std::vector::assign. This is more efficient and follows the general rule for copying elements from a dbSet to a std::vector.

      std::vector<odb::dbLib*> search_libs;
      search_libs.assign(db_->getLibs().begin(), db_->getLibs().end());
References
  1. To copy elements from a dbSet to a std::vector, use the vector::assign() method with iterators from the dbSet, as direct assignment is not supported.

…ard (Issue The-OpenROAD-Project#10077)

Signed-off-by: Jorge Ferreira <jorge.ferreira@precisioninno.com>
@github-actions
Copy link
Copy Markdown
Contributor

clang-tidy review says "All clean, LGTM! 👍"

Copy link
Copy Markdown
Member

@osamahammad21 osamahammad21 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Remove writing a def file in the 3dbv for each chiplet and add a test case.


if (!chip_inst.external.def_file.empty()) {
if (chip->getBlock() != nullptr) {
odb::dbBlock::destroy(chip->getBlock());
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

you probably should log an error here. There can't be 2 instances of the same chiplet with a def file each.

Comment on lines +692 to +698
odb::defin def_reader(db_, logger_, odb::defin::DEFAULT);
std::vector<odb::dbLib*> search_libs;
for (odb::dbLib* lib : db_->getLibs()) {
search_libs.push_back(lib);
}
def_reader.readChip(
search_libs, chip_inst.external.def_file.c_str(), chip, false);
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is the same code written in createChiplet, wrap in an inline function to reduce code duplication.

Comment on lines +467 to +473
odb::dbBoolProperty::create(chip, "def_file_read", true);
if (auto* prop = odb::dbStringProperty::find(chip, "def_file_path")) {
prop->setValue(chiplet.external.def_file.c_str());
} else {
odb::dbStringProperty::create(
chip, "def_file_path", chiplet.external.def_file.c_str());
}
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

why? I don't think these properties are needed.

Comment on lines +699 to +705
odb::dbBoolProperty::create(chip, "def_file_read", true);
if (auto* prop = odb::dbStringProperty::find(chip, "def_file_path")) {
prop->setValue(chip_inst.external.def_file.c_str());
} else {
odb::dbStringProperty::create(
chip, "def_file_path", chip_inst.external.def_file.c_str());
}
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

not needed.

Comment on lines +70 to +74
auto* chip = inst->getMasterChip();
if (odb::dbProperty::find(chip, "def_file_read") != nullptr) {
YAML::Node external_node = instance_node["external"];
external_node["def_file"] = std::string(chip->getName()) + ".def";
}
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is going to end up in all instances of that chiplet having a def file defined. This is incorrect. There should only be one chipInst with a defined def_file. It doesn't matter which one, but it should be only one.

Signed-off-by: Jorge Ferreira <jorge.ferreira@precisioninno.com>
Signed-off-by: Jorge Ferreira <jorge.ferreira@precisioninno.com>
@github-actions
Copy link
Copy Markdown
Contributor

clang-tidy review says "All clean, LGTM! 👍"

@jferreiraOpenRoad
Copy link
Copy Markdown
Contributor

All requested changes have been made.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants