Skip to content

Commit 7647fff

Browse files
committed
Modified DbInstanceChildIterator to iterate through logical cells (exclude physical-only cells).
- This makes STA not traverse physical-only cells. - In the output .v, there will be no physical-only cells. Signed-off-by: Jaehyun Kim <[email protected]>
1 parent 666be19 commit 7647fff

File tree

7 files changed

+100
-4
lines changed

7 files changed

+100
-4
lines changed

src/dbSta/src/dbNetwork.cc

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -253,7 +253,7 @@ DbInstanceChildIterator::DbInstanceChildIterator(const Instance* instance,
253253
// original code for non hierarchy
254254
if (!network->hasHierarchy()) {
255255
if (instance == network->topInstance() && block) {
256-
dbSet<dbInst> insts = block->getInsts();
256+
dbSet<dbInst> insts = block->getLogicalInsts();
257257
top_ = true;
258258
dbinst_iter_ = insts.begin();
259259
dbinst_end_ = insts.end();

src/odb/include/odb/db.h

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -695,6 +695,11 @@ class dbBlock : public dbObject
695695
///
696696
dbSet<dbInst> getInsts();
697697

698+
///
699+
/// Get the logical (non-physical-only) instances of this block.
700+
///
701+
dbSet<dbInst> getLogicalInsts();
702+
698703
///
699704
/// Get the modules of this block.
700705
///

src/odb/src/db/dbBlock.cpp

Lines changed: 67 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -135,6 +135,63 @@
135135

136136
namespace odb {
137137

138+
class dbLogicalInstItr : public dbIterator
139+
{
140+
public:
141+
dbLogicalInstItr(dbTable<_dbInst>* inst_tbl) : _inst_tbl(inst_tbl) {}
142+
143+
bool reversible() override { return false; }
144+
bool orderReversed() override { return false; }
145+
void reverse(dbObject* /*parent*/) override {}
146+
uint sequential() override { return 0; }
147+
148+
uint size(dbObject* parent) override
149+
{
150+
uint count = 0;
151+
for (uint id = begin(parent); id != end(parent); id = next(id)) {
152+
count++;
153+
}
154+
return count;
155+
}
156+
157+
uint begin(dbObject* parent) override
158+
{
159+
return findNext(_inst_tbl->begin(parent));
160+
}
161+
162+
uint end(dbObject* parent) override { return _inst_tbl->end(parent); }
163+
164+
uint next(uint id, ...) override { return findNext(_inst_tbl->next(id)); }
165+
166+
dbObject* getObject(uint id, ...) override
167+
{
168+
return _inst_tbl->getObject(id);
169+
}
170+
171+
private:
172+
uint findNext(uint start_id)
173+
{
174+
uint cur_id = start_id;
175+
const uint end_id = _inst_tbl->end(nullptr);
176+
177+
while (cur_id != end_id) {
178+
if (_inst_tbl->validId(cur_id)) {
179+
_dbInst* inst_impl = (_dbInst*) _inst_tbl->getPtr(cur_id);
180+
dbInst* inst = reinterpret_cast<dbInst*>(inst_impl);
181+
if (inst->isPhysicalOnly() == false) {
182+
return cur_id;
183+
}
184+
}
185+
cur_id = _inst_tbl->next(cur_id);
186+
}
187+
188+
return end_id;
189+
}
190+
191+
private:
192+
dbTable<_dbInst>* _inst_tbl;
193+
};
194+
138195
struct OldTransform
139196
{
140197
int _orient;
@@ -415,6 +472,9 @@ _dbBlock::_dbBlock(_dbDatabase* db)
415472

416473
_prop_itr = new dbPropertyItr(_prop_tbl);
417474

475+
_logical_inst_itr
476+
= new dbLogicalInstItr((dbTable<_dbInst>*) getObjectTable(dbInstObj));
477+
418478
_num_ext_dbs = 1;
419479
_searchDb = nullptr;
420480
_extmi = nullptr;
@@ -506,6 +566,7 @@ _dbBlock::~_dbBlock()
506566
delete _group_ground_net_itr;
507567
delete _bpin_itr;
508568
delete _prop_itr;
569+
delete _logical_inst_itr;
509570
delete _dft_tbl;
510571
delete _marker_categories_tbl;
511572

@@ -1797,6 +1858,12 @@ dbSet<dbInst> dbBlock::getInsts()
17971858
return dbSet<dbInst>(block, block->_inst_tbl);
17981859
}
17991860

1861+
dbSet<dbInst> dbBlock::getLogicalInsts()
1862+
{
1863+
_dbBlock* block = (_dbBlock*) this;
1864+
return dbSet<dbInst>(block, block->_logical_inst_itr);
1865+
}
1866+
18001867
dbSet<dbModule> dbBlock::getModules()
18011868
{
18021869
_dbBlock* block = (_dbBlock*) this;

src/odb/src/db/dbBlock.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -116,6 +116,7 @@ class dbBlockCallBackObj;
116116
class dbGuideItr;
117117
class dbNetTrackItr;
118118
class _dbDft;
119+
class dbLogicalInstItr;
119120

120121
struct _dbBlockFlags
121122
{
@@ -289,6 +290,7 @@ class _dbBlock : public _dbObject
289290
dbBPinItr* _bpin_itr;
290291
dbPropertyItr* _prop_itr;
291292
dbBlockSearch* _searchDb;
293+
dbLogicalInstItr* _logical_inst_itr;
292294

293295
std::unordered_map<std::string, int> _module_name_id_map;
294296
std::unordered_map<std::string, int> _inst_name_id_map;

src/tap/test/gcd_asap7.ok

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,3 +5,4 @@
55
[INFO TAP-0004] Inserted 104 endcaps.
66
[INFO TAP-0005] Inserted 0 tapcells.
77
No differences found.
8+
No differences found.

src/tap/test/gcd_asap7.tcl

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3,13 +3,15 @@ read_lef asap7/asap7_tech_1x_201209.lef
33
read_lef asap7/asap7sc7p5t_28_R_1x_220121a.lef
44
read_def asap7_data/gcd.def
55

6-
set def_file [make_result_file gcd_asap7.def]
7-
86
tapcell \
97
-distance 25 \
108
-tapcell_master TAPCELL_ASAP7_75t_R \
119
-endcap_master TAPCELL_ASAP7_75t_R
1210

11+
set def_file [make_result_file gcd_asap7.def]
1312
write_def $def_file
14-
1513
diff_file gcd_asap7.defok $def_file
14+
15+
set verilog_file [make_result_file gcd_asap7.v]
16+
write_verilog $verilog_file
17+
diff_file gcd_asap7.vok $verilog_file

src/tap/test/gcd_asap7.vok

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
module gcd (clk,
2+
req_rdy,
3+
req_val,
4+
reset,
5+
resp_rdy,
6+
resp_val,
7+
req_msg,
8+
resp_msg);
9+
input clk;
10+
output req_rdy;
11+
input req_val;
12+
input reset;
13+
input resp_rdy;
14+
output resp_val;
15+
input [31:0] req_msg;
16+
output [15:0] resp_msg;
17+
18+
19+
endmodule

0 commit comments

Comments
 (0)