Skip to content

Commit 070165c

Browse files
committed
odb: Added a new test in TestWriteReadDbHier.cpp
Signed-off-by: Jaehyun Kim <[email protected]>
1 parent 40f0809 commit 070165c

File tree

3 files changed

+56
-3
lines changed

3 files changed

+56
-3
lines changed

src/odb/src/db/dbBlock.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1000,7 +1000,7 @@ dbIStream& operator>>(dbIStream& stream, _dbBlock& block)
10001000
}
10011001
stream >> *block.moditerm_tbl_;
10021002
stream >> *block.modnet_tbl_;
1003-
if (db->isSchema(db_schema_db_remove_hash)) {
1003+
if (db->isSchema(kSchemaDbRemoveHash)) {
10041004
// Construct modnet_hash_
10051005
dbSet<dbModNet> modnets((dbBlock*) &block, block.modnet_tbl_);
10061006
for (dbModNet* obj : modnets) {

src/odb/test/cpp/TestWriteReadDbHier.cpp

Lines changed: 53 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -178,5 +178,58 @@ TEST_F(TestWriteReadDbHier, WriteReadOdb)
178178
ASSERT_NE(db2_mi1, nullptr);
179179
}
180180

181+
// Construct hierarchical netlist with multiple blocks and write/read it back.
182+
// The hierarchical netlist should be read back successfully.
183+
TEST_F(TestWriteReadDbHier, WriteReadOdbMultiBlocks)
184+
{
185+
SetUpTmpPath("WriteReadOdbMultiBlocks");
186+
db_->setHierarchy(true);
187+
188+
// Create masters
189+
dbMaster* buf_master = db_->findMaster("BUF_X1");
190+
ASSERT_TRUE(buf_master);
191+
192+
// Create child block
193+
dbBlock* child_block = dbBlock::create(block_, "CHILD_BLOCK");
194+
ASSERT_TRUE(child_block);
195+
196+
// Create module in child block
197+
dbModule* mod0 = dbModule::create(child_block, "MOD0");
198+
ASSERT_TRUE(mod0);
199+
200+
dbModBTerm* mod0_a = dbModBTerm::create(mod0, "A");
201+
ASSERT_TRUE(mod0_a);
202+
203+
// Create instance in child block
204+
dbInst* child_inst
205+
= dbInst::create(child_block, buf_master, "child_inst", false, mod0);
206+
ASSERT_TRUE(child_inst);
207+
208+
//--------------------------------------------------------------
209+
// Write ODB and read back
210+
//--------------------------------------------------------------
211+
dbDatabase* db2 = writeReadDb();
212+
ASSERT_TRUE(db2->hasHierarchy());
213+
dbBlock* top_block2 = db2->getChip()->getBlock();
214+
215+
// Find child block
216+
dbBlock* child_block2 = top_block2->findChild("CHILD_BLOCK");
217+
ASSERT_NE(child_block2, nullptr);
218+
219+
// Find module in child block
220+
dbModule* mod0_2 = child_block2->findModule("MOD0");
221+
ASSERT_NE(mod0_2, nullptr);
222+
223+
// Verify ModBTerm hash is populated
224+
dbModBTerm* mod0_a_2 = mod0_2->findModBTerm("A");
225+
ASSERT_NE(mod0_a_2, nullptr);
226+
EXPECT_STREQ(mod0_a_2->getName(), "A");
227+
228+
// Verify Inst hash is populated
229+
dbInst* child_inst_2 = child_block2->findInst("child_inst");
230+
ASSERT_NE(child_inst_2, nullptr);
231+
EXPECT_EQ(child_inst_2->getName(), "child_inst");
232+
}
233+
181234
} // namespace
182235
} // namespace odb

src/tst/include/tst/IntegratedFixture.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -35,9 +35,9 @@ class IntegratedFixture : public tst::Fixture
3535
void removeFile(const std::string& path);
3636

3737
protected:
38-
odb::dbLib* lib_;
38+
odb::dbLib* lib_{nullptr};
3939
odb::dbBlock* block_{nullptr};
40-
sta::dbNetwork* db_network_;
40+
sta::dbNetwork* db_network_{nullptr};
4141

4242
stt::SteinerTreeBuilder stt_;
4343
utl::CallBackHandler callback_handler_;

0 commit comments

Comments
 (0)