Skip to content

Commit d5dd734

Browse files
authored
Merge pull request #7824 from AcKoucher/odb-scan-inst-owner
odb: move ownership of _dbScanInst to _dbBlock
2 parents 54a3e7c + 59f780d commit d5dd734

15 files changed

Lines changed: 284 additions & 68 deletions

src/odb/include/odb/db.h

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8440,6 +8440,8 @@ class dbScanInst : public dbObject
84408440

84418441
dbInst* getInst() const;
84428442

8443+
void insertAtFront(dbScanList* scan_list);
8444+
84438445
static dbScanInst* create(dbScanList* scan_list, dbInst* inst);
84448446
// User Code End dbScanInst
84458447
};
@@ -8452,9 +8454,8 @@ class dbScanInst : public dbObject
84528454
class dbScanList : public dbObject
84538455
{
84548456
public:
8455-
dbSet<dbScanInst> getScanInsts() const;
8456-
84578457
// User Code Begin dbScanList
8458+
dbSet<dbScanInst> getScanInsts() const;
84588459
dbScanInst* add(dbInst* inst);
84598460
static dbScanList* create(dbScanPartition* scan_partition);
84608461
// User Code End dbScanList

src/odb/src/codeGenerator/schema.json

Lines changed: 9 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -153,6 +153,15 @@
153153
"reversible": "true",
154154
"orderReversed": "true",
155155
"sequential": 0
156+
},
157+
{
158+
"name": "dbScanListScanInstItr",
159+
"parentObject": "dbScanInst",
160+
"tableName": "scan_inst_tbl",
161+
"reversible": "true",
162+
"orderReversed": "true",
163+
"sequential": 0,
164+
"includes": ["dbScanList.h", "dbScanInst.h"]
156165
}
157166
],
158167
"relations":[
@@ -301,12 +310,6 @@
301310
"type": "1_n",
302311
"tbl_name": "scan_lists_"
303312
},
304-
{
305-
"parent": "dbScanList",
306-
"child": "dbScanInst",
307-
"type": "1_n",
308-
"tbl_name": "scan_insts_"
309-
},
310313
{
311314
"parent": "dbDft",
312315
"child": "dbScanChain",

src/odb/src/codeGenerator/schema/scan/dbScanInst.json

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -42,6 +42,18 @@
4242
"type": "uint",
4343
"default": "0",
4444
"flags": ["private"]
45+
},
46+
{
47+
"name": "_next_list_scan_inst",
48+
"type": "dbId<_dbScanInst>",
49+
"flags": ["private"],
50+
"schema":"db_schema_block_owns_scan_insts"
51+
},
52+
{
53+
"name": "_prev_list_scan_inst",
54+
"type": "dbId<_dbScanInst>",
55+
"flags": ["private"],
56+
"schema":"db_schema_block_owns_scan_insts"
4557
}
4658
],
4759
"enums": [

src/odb/src/codeGenerator/schema/scan/dbScanList.json

Lines changed: 22 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,27 @@
99
"optimizing the scan chain."],
1010
"cpp_includes": [
1111
"dbScanChain.h",
12-
"dbScanPartition.h"
12+
"dbScanPartition.h",
13+
"dbDft.h",
14+
"dbScanListScanInstItr.h"],
15+
"fields": [
16+
{
17+
"name": "_unused",
18+
"type": "uint",
19+
"flags": [
20+
"private"
21+
],
22+
"default": 0,
23+
"comment": "// As the elements of a free dbTable are 12 bytes long, we need this additional member in order to make _dbScanList big enough to allow safe casting between table members.",
24+
"schema": "db_schema_block_owns_scan_insts"
25+
},
26+
{
27+
"name": "_first_scan_inst",
28+
"type": "dbId<_dbScanInst>",
29+
"flags": [
30+
"private"
31+
],
32+
"schema": "db_schema_block_owns_scan_insts"
33+
}
1334
]
1435
}

src/odb/src/db/CMakeLists.txt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -161,6 +161,7 @@ add_library(db
161161
dbModulePortItr.cpp
162162
dbNetTrackItr.cpp
163163
dbRegionGroupItr.cpp
164+
dbScanListScanInstItr.cpp
164165
# Generator Code End cpp
165166
)
166167

src/odb/src/db/dbBlock.cpp

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -91,6 +91,8 @@
9191
#include "dbSBoxItr.h"
9292
#include "dbSWire.h"
9393
#include "dbSWireItr.h"
94+
#include "dbScanInst.h"
95+
#include "dbScanListScanInstItr.h"
9496
#include "dbTable.h"
9597
#include "dbTable.hpp"
9698
#include "dbTech.h"
@@ -180,6 +182,9 @@ _dbBlock::_dbBlock(_dbDatabase* db)
180182
_inst_tbl = new dbTable<_dbInst>(
181183
db, this, (GetObjTbl_t) &_dbBlock::getObjectTable, dbInstObj);
182184

185+
_scan_inst_tbl = new dbTable<_dbScanInst>(
186+
db, this, (GetObjTbl_t) &_dbBlock::getObjectTable, dbScanInstObj);
187+
183188
_module_tbl = new dbTable<_dbModule>(
184189
db, this, (GetObjTbl_t) &_dbBlock::getObjectTable, dbModuleObj);
185190

@@ -338,6 +343,8 @@ _dbBlock::_dbBlock(_dbDatabase* db)
338343

339344
_inst_iterm_itr = new dbInstITermItr(_iterm_tbl);
340345

346+
_scan_list_scan_inst_itr = new dbScanListScanInstItr(_scan_inst_tbl);
347+
341348
_box_itr = new dbBoxItr<1024>(_box_tbl, nullptr, false);
342349

343350
_swire_itr = new dbSWireItr(_swire_tbl);
@@ -406,6 +413,7 @@ _dbBlock::~_dbBlock()
406413
delete _net_tbl;
407414
delete _inst_hdr_tbl;
408415
delete _inst_tbl;
416+
delete _scan_inst_tbl;
409417
delete _module_tbl;
410418
delete _modinst_tbl;
411419
delete _modbterm_tbl;
@@ -450,6 +458,7 @@ _dbBlock::~_dbBlock()
450458
delete _net_bterm_itr;
451459
delete _net_iterm_itr;
452460
delete _inst_iterm_itr;
461+
delete _scan_list_scan_inst_itr;
453462
delete _box_itr;
454463
delete _swire_itr;
455464
delete _sbox_itr;
@@ -785,6 +794,7 @@ dbOStream& operator<<(dbOStream& stream, const _dbBlock& block)
785794
stream << *block._inst_hdr_tbl;
786795
stream << *block._module_tbl;
787796
stream << *block._inst_tbl;
797+
stream << *block._scan_inst_tbl;
788798
stream << *block._modinst_tbl;
789799
stream << *block._modbterm_tbl;
790800
stream << *block._busport_tbl;
@@ -941,6 +951,9 @@ dbIStream& operator>>(dbIStream& stream, _dbBlock& block)
941951
stream >> *block._inst_tbl;
942952
stream >> *block._module_tbl;
943953
}
954+
if (db->isSchema(db_schema_block_owns_scan_insts)) {
955+
stream >> *block._scan_inst_tbl;
956+
}
944957
stream >> *block._modinst_tbl;
945958
if (db->isSchema(db_schema_update_hierarchy)) {
946959
stream >> *block._modbterm_tbl;

src/odb/src/db/dbBlock.h

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,8 @@ class _dbITerm;
3333
class _dbNet;
3434
class _dbInst;
3535
class _dbInstHdr;
36+
class _dbScanInst;
37+
class dbScanListScanInstItr;
3638
class _dbWire;
3739
class _dbVia;
3840
class _dbGCellGrid;
@@ -200,6 +202,7 @@ class _dbBlock : public _dbObject
200202
dbTable<_dbNet>* _net_tbl;
201203
dbTable<_dbInstHdr>* _inst_hdr_tbl;
202204
dbTable<_dbInst>* _inst_tbl;
205+
dbTable<_dbScanInst>* _scan_inst_tbl;
203206
dbTable<_dbBox, 1024>* _box_tbl;
204207
dbTable<_dbVia, 1024>* _via_tbl;
205208
dbTable<_dbGCellGrid>* _gcell_grid_tbl;
@@ -251,6 +254,7 @@ class _dbBlock : public _dbObject
251254
dbNetBTermItr* _net_bterm_itr;
252255
dbNetITermItr* _net_iterm_itr;
253256
dbInstITermItr* _inst_iterm_itr;
257+
dbScanListScanInstItr* _scan_list_scan_inst_itr;
254258
dbBoxItr<1024>* _box_itr;
255259
dbSWireItr* _swire_itr;
256260
dbSBoxItr* _sbox_itr;

src/odb/src/db/dbDatabase.h

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,9 @@ namespace odb {
4343
const uint db_schema_major = 0; // Not used...
4444
const uint db_schema_initial = 57;
4545

46-
const uint db_schema_minor = 109; // Current revision number
46+
const uint db_schema_minor = 110; // Current revision number
47+
48+
const uint db_schema_block_owns_scan_insts = 110;
4749

4850
// Revision where is_connect_to_term_ flag was added to dbGuide
4951
const uint db_schema_guide_connected_to_term = 109;

src/odb/src/db/dbScanInst.cpp

Lines changed: 47 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,12 @@ bool _dbScanInst::operator==(const _dbScanInst& rhs) const
3636
if (clock_edge_ != rhs.clock_edge_) {
3737
return false;
3838
}
39+
if (_next_list_scan_inst != rhs._next_list_scan_inst) {
40+
return false;
41+
}
42+
if (_prev_list_scan_inst != rhs._prev_list_scan_inst) {
43+
return false;
44+
}
3945

4046
return true;
4147
}
@@ -59,6 +65,12 @@ dbIStream& operator>>(dbIStream& stream, _dbScanInst& obj)
5965
stream >> obj.inst_;
6066
stream >> obj.scan_clock_;
6167
stream >> obj.clock_edge_;
68+
if (obj.getDatabase()->isSchema(db_schema_block_owns_scan_insts)) {
69+
stream >> obj._next_list_scan_inst;
70+
}
71+
if (obj.getDatabase()->isSchema(db_schema_block_owns_scan_insts)) {
72+
stream >> obj._prev_list_scan_inst;
73+
}
6274
return stream;
6375
}
6476

@@ -70,6 +82,8 @@ dbOStream& operator<<(dbOStream& stream, const _dbScanInst& obj)
7082
stream << obj.inst_;
7183
stream << obj.scan_clock_;
7284
stream << obj.clock_edge_;
85+
stream << obj._next_list_scan_inst;
86+
stream << obj._prev_list_scan_inst;
7387
return stream;
7488
}
7589

@@ -137,28 +151,24 @@ uint dbScanInst::getBits() const
137151
void dbScanInst::setScanEnable(dbBTerm* scan_enable)
138152
{
139153
_dbScanInst* scan_inst = (_dbScanInst*) this;
140-
_dbScanChain* scan_chain = (_dbScanChain*) scan_inst->getOwner();
141-
dbDft* dft = (dbDft*) scan_chain->getOwner();
154+
_dbBlock* block = (_dbBlock*) scan_inst->getOwner();
155+
dbDft* dft = (dbDft*) block->_dft_tbl->getPtr(block->_dft);
142156
scan_inst->scan_enable_ = dbScanPin::create(dft, scan_enable);
143157
}
144158

145159
void dbScanInst::setScanEnable(dbITerm* scan_enable)
146160
{
147161
_dbScanInst* scan_inst = (_dbScanInst*) this;
148-
_dbScanList* scan_list = (_dbScanList*) scan_inst->getOwner();
149-
_dbScanPartition* scan_partition = (_dbScanPartition*) scan_list->getOwner();
150-
_dbScanChain* scan_chain = (_dbScanChain*) scan_partition->getOwner();
151-
dbDft* dft = (dbDft*) scan_chain->getOwner();
162+
_dbBlock* block = (_dbBlock*) scan_inst->getOwner();
163+
dbDft* dft = (dbDft*) block->_dft_tbl->getPtr(block->_dft);
152164
scan_inst->scan_enable_ = dbScanPin::create(dft, scan_enable);
153165
}
154166

155167
std::variant<dbBTerm*, dbITerm*> dbScanInst::getScanEnable() const
156168
{
157169
_dbScanInst* scan_inst = (_dbScanInst*) this;
158-
_dbScanList* scan_list = (_dbScanList*) scan_inst->getOwner();
159-
_dbScanPartition* scan_partition = (_dbScanPartition*) scan_list->getOwner();
160-
_dbScanChain* scan_chain = (_dbScanChain*) scan_partition->getOwner();
161-
_dbDft* dft = (_dbDft*) scan_chain->getOwner();
170+
_dbBlock* block = (_dbBlock*) scan_inst->getOwner();
171+
_dbDft* dft = (_dbDft*) block->_dft_tbl->getPtr(block->_dft);
162172
const dbScanPin* scan_enable = (dbScanPin*) dft->scan_pins_->getPtr(
163173
(dbId<_dbScanPin>) scan_inst->scan_enable_);
164174
return scan_enable->getPin();
@@ -177,10 +187,8 @@ std::string_view getName(odb::dbITerm* iterm)
177187
void dbScanInst::setAccessPins(const AccessPins& access_pins)
178188
{
179189
_dbScanInst* scan_inst = (_dbScanInst*) this;
180-
_dbScanList* scan_list = (_dbScanList*) scan_inst->getOwner();
181-
_dbScanPartition* scan_partition = (_dbScanPartition*) scan_list->getOwner();
182-
_dbScanChain* scan_chain = (_dbScanChain*) scan_partition->getOwner();
183-
dbDft* dft = (dbDft*) scan_chain->getOwner();
190+
_dbBlock* block = (_dbBlock*) scan_inst->getOwner();
191+
dbDft* dft = (dbDft*) block->_dft_tbl->getPtr(block->_dft);
184192

185193
std::visit(
186194
[&access_pins, scan_inst, dft](auto&& scan_in_pin) {
@@ -200,10 +208,8 @@ dbScanInst::AccessPins dbScanInst::getAccessPins() const
200208
{
201209
AccessPins access_pins;
202210
_dbScanInst* scan_inst = (_dbScanInst*) this;
203-
_dbScanList* scan_list = (_dbScanList*) scan_inst->getOwner();
204-
_dbScanPartition* scan_partition = (_dbScanPartition*) scan_list->getOwner();
205-
_dbScanChain* scan_chain = (_dbScanChain*) scan_partition->getOwner();
206-
_dbDft* dft = (_dbDft*) scan_chain->getOwner();
211+
_dbBlock* block = (_dbBlock*) scan_inst->getOwner();
212+
_dbDft* dft = (_dbDft*) block->_dft_tbl->getPtr(block->_dft);
207213

208214
const auto& [scan_in_id, scan_out_id] = scan_inst->access_pins_;
209215

@@ -221,19 +227,34 @@ dbScanInst::AccessPins dbScanInst::getAccessPins() const
221227
dbInst* dbScanInst::getInst() const
222228
{
223229
_dbScanInst* scan_inst = (_dbScanInst*) this;
224-
_dbScanList* scan_list = (_dbScanList*) scan_inst->getOwner();
225-
_dbScanPartition* scan_partition = (_dbScanPartition*) scan_list->getOwner();
226-
_dbScanChain* scan_chain = (_dbScanChain*) scan_partition->getOwner();
227-
_dbDft* dft = (_dbDft*) scan_chain->getOwner();
228-
_dbBlock* block = (_dbBlock*) dft->getOwner();
229-
230+
_dbBlock* block = (_dbBlock*) scan_inst->getOwner();
230231
return (dbInst*) block->_inst_tbl->getPtr((dbId<_dbInst>) scan_inst->inst_);
231232
}
232233

234+
void dbScanInst::insertAtFront(dbScanList* scan_list_)
235+
{
236+
_dbScanInst* scan_inst = (_dbScanInst*) this;
237+
_dbScanList* scan_list = (_dbScanList*) scan_list_;
238+
_dbBlock* block = (_dbBlock*) scan_inst->getOwner();
239+
240+
if (scan_list->_first_scan_inst != 0) {
241+
_dbScanInst* head
242+
= block->_scan_inst_tbl->getPtr(scan_list->_first_scan_inst);
243+
scan_inst->_next_list_scan_inst = scan_list->_first_scan_inst;
244+
head->_prev_list_scan_inst = scan_inst->getOID();
245+
} else {
246+
// Needed if an already listed scan inst is moved to an empty list.
247+
scan_inst->_next_list_scan_inst = 0;
248+
}
249+
250+
scan_inst->_prev_list_scan_inst = 0;
251+
scan_list->_first_scan_inst = scan_inst->getOID();
252+
}
253+
233254
dbScanInst* dbScanInst::create(dbScanList* scan_list, dbInst* inst)
234255
{
235-
_dbScanList* obj = (_dbScanList*) scan_list;
236-
_dbScanInst* scan_inst = (_dbScanInst*) obj->scan_insts_->create();
256+
_dbBlock* block = (_dbBlock*) ((_dbInst*) inst)->getOwner();
257+
_dbScanInst* scan_inst = (_dbScanInst*) block->_scan_inst_tbl->create();
237258
scan_inst->inst_ = ((_dbInst*) inst)->getId();
238259

239260
return (dbScanInst*) scan_inst;

src/odb/src/db/dbScanInst.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,8 @@ class _dbScanInst : public _dbObject
3737
dbId<dbInst> inst_;
3838
std::string scan_clock_;
3939
uint clock_edge_;
40+
dbId<_dbScanInst> _next_list_scan_inst;
41+
dbId<_dbScanInst> _prev_list_scan_inst;
4042
};
4143
dbIStream& operator>>(dbIStream& stream, _dbScanInst& obj);
4244
dbOStream& operator<<(dbOStream& stream, const _dbScanInst& obj);

0 commit comments

Comments
 (0)