Skip to content

Commit bb8cb57

Browse files
committed
odb: use code generator for new iterator and add
add reverse logic to it Signed-off-by: Arthur Koucher <arthurkoucher@precisioninno.com>
1 parent f7d7cb9 commit bb8cb57

7 files changed

Lines changed: 116 additions & 71 deletions

File tree

src/odb/src/codeGenerator/schema.json

Lines changed: 9 additions & 0 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":[

src/odb/src/db/CMakeLists.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,6 @@ add_library(db
1616
dbITermItr.cpp
1717
dbInst.cpp
1818
dbInstHdr.cpp
19-
dbScanInstItr.cpp
2019
dbLib.cpp
2120
dbMPin.cpp
2221
dbMPinItr.cpp
@@ -162,6 +161,7 @@ add_library(db
162161
dbModulePortItr.cpp
163162
dbNetTrackItr.cpp
164163
dbRegionGroupItr.cpp
164+
dbScanListScanInstItr.cpp
165165
# Generator Code End cpp
166166
)
167167

src/odb/src/db/dbBlock.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -92,7 +92,7 @@
9292
#include "dbSWire.h"
9393
#include "dbSWireItr.h"
9494
#include "dbScanInst.h"
95-
#include "dbScanInstItr.h"
95+
#include "dbScanListScanInstItr.h"
9696
#include "dbTable.h"
9797
#include "dbTable.hpp"
9898
#include "dbTech.h"

src/odb/src/db/dbScanInstItr.cpp

Lines changed: 0 additions & 62 deletions
This file was deleted.

src/odb/src/db/dbScanList.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
#include "dbDatabase.h"
88
#include "dbDft.h"
99
#include "dbScanChain.h"
10-
#include "dbScanInstItr.h"
10+
#include "dbScanListScanInstItr.h"
1111
#include "dbScanPartition.h"
1212
#include "dbTable.h"
1313
#include "dbTable.hpp"
Lines changed: 95 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,95 @@
1+
// SPDX-License-Identifier: BSD-3-Clause
2+
// Copyright (c) 2019-2025, The OpenROAD Authors
3+
4+
// Generator Code Begin Cpp
5+
#include "dbScanListScanInstItr.h"
6+
7+
#include "dbScanInst.h"
8+
#include "dbScanList.h"
9+
#include "dbTable.h"
10+
#include "dbTable.hpp"
11+
12+
namespace odb {
13+
14+
////////////////////////////////////////////////////////////////////
15+
//
16+
// dbScanListScanInstItr - Methods
17+
//
18+
////////////////////////////////////////////////////////////////////
19+
20+
bool dbScanListScanInstItr::reversible()
21+
{
22+
return true;
23+
}
24+
25+
bool dbScanListScanInstItr::orderReversed()
26+
{
27+
return true;
28+
}
29+
30+
void dbScanListScanInstItr::reverse(dbObject* parent)
31+
{
32+
// User Code Begin reverse
33+
_dbScanList* scan_list = (_dbScanList*) parent;
34+
uint current_id = scan_list->_first_scan_inst;
35+
uint new_head = 0;
36+
37+
while (current_id != 0) {
38+
_dbScanInst* scan_inst = _scan_inst_tbl->getPtr(current_id);
39+
uint new_next = scan_inst->_prev_list_scan_inst;
40+
scan_inst->_prev_list_scan_inst = scan_inst->_next_list_scan_inst;
41+
scan_inst->_next_list_scan_inst = new_next;
42+
new_head = current_id;
43+
current_id = scan_inst->_prev_list_scan_inst;
44+
}
45+
46+
scan_list->_first_scan_inst = new_head;
47+
// User Code End reverse
48+
}
49+
50+
uint dbScanListScanInstItr::sequential()
51+
{
52+
return 0;
53+
}
54+
55+
uint dbScanListScanInstItr::size(dbObject* parent)
56+
{
57+
uint id;
58+
uint cnt = 0;
59+
60+
for (id = dbScanListScanInstItr::begin(parent);
61+
id != dbScanListScanInstItr::end(parent);
62+
id = dbScanListScanInstItr::next(id)) {
63+
++cnt;
64+
}
65+
66+
return cnt;
67+
}
68+
69+
uint dbScanListScanInstItr::begin(dbObject* parent)
70+
{
71+
// User Code Begin begin
72+
_dbScanList* scan_list = (_dbScanList*) parent;
73+
return (uint) scan_list->_first_scan_inst;
74+
// User Code End begin
75+
}
76+
77+
uint dbScanListScanInstItr::end(dbObject* /* unused: parent */)
78+
{
79+
return 0;
80+
}
81+
82+
uint dbScanListScanInstItr::next(uint id, ...)
83+
{
84+
// User Code Begin next
85+
_dbScanInst* scan_inst = _scan_inst_tbl->getPtr(id);
86+
return (uint) scan_inst->_next_list_scan_inst;
87+
// User Code End next
88+
}
89+
90+
dbObject* dbScanListScanInstItr::getObject(uint id, ...)
91+
{
92+
return _scan_inst_tbl->getPtr(id);
93+
}
94+
} // namespace odb
95+
// Generator Code End Cpp
Original file line numberDiff line numberDiff line change
@@ -1,23 +1,22 @@
11
// SPDX-License-Identifier: BSD-3-Clause
2-
// Copyright (c) 2025-2025, The OpenROAD Authors
2+
// Copyright (c) 2019-2025, The OpenROAD Authors
33

4+
// Generator Code Begin Header
45
#pragma once
56

67
#include "dbCore.h"
78
#include "odb/dbIterator.h"
9+
#include "odb/odb.h"
810

911
namespace odb {
10-
1112
class _dbScanInst;
1213

1314
class dbScanListScanInstItr : public dbIterator
1415
{
15-
dbTable<_dbScanInst>* _scan_inst_tbl;
16-
1716
public:
1817
dbScanListScanInstItr(dbTable<_dbScanInst>* scan_inst_tbl)
19-
: _scan_inst_tbl(scan_inst_tbl)
2018
{
19+
_scan_inst_tbl = scan_inst_tbl;
2120
}
2221

2322
bool reversible() override;
@@ -29,6 +28,10 @@ class dbScanListScanInstItr : public dbIterator
2928
uint end(dbObject* parent) override;
3029
uint next(uint id, ...) override;
3130
dbObject* getObject(uint id, ...) override;
31+
32+
private:
33+
dbTable<_dbScanInst>* _scan_inst_tbl;
3234
};
3335

34-
} // namespace odb
36+
} // namespace odb
37+
// Generator Code End Header

0 commit comments

Comments
 (0)