Skip to content

Commit 81706ae

Browse files
authored
Merge pull request #2737 from cdleary/small-rcx-cleanups
A few code cleanups in RCX as a first OpenROAD PR.
2 parents 0dc3945 + 7c9db2a commit 81706ae

File tree

9 files changed

+19
-109
lines changed

9 files changed

+19
-109
lines changed

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@
1010
*.rej
1111
*.orig
1212
*.vscode
13+
*.sw[opqr]
1314
TAGS
1415
*~
1516
\#*#

src/rcx/include/rcx/ext.h

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,8 @@
3434

3535
#include <tcl.h>
3636

37+
#include <memory>
38+
3739
#include "extRCap.h"
3840
#include "exttree.h"
3941

@@ -53,7 +55,7 @@ class Ext
5355
{
5456
public:
5557
Ext();
56-
~Ext();
58+
~Ext() = default;
5759

5860
void init(Tcl_Interp* tcl_interp, odb::dbDatabase* db, Logger* logger);
5961
void setLogger(Logger* logger);
@@ -307,10 +309,10 @@ class Ext
307309
const std::string& branch_len);
308310

309311
private:
310-
odb::dbDatabase* _db;
311-
extMain* _ext;
312-
extRcTree* _tree;
313-
Logger* logger_;
312+
odb::dbDatabase* _db = nullptr;
313+
std::unique_ptr<extMain> _ext;
314+
std::unique_ptr<extRcTree> _tree;
315+
Logger* logger_ = nullptr;
314316
}; // namespace rcx
315317

316318
} // namespace rcx

src/rcx/include/rcx/extRCap.h

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1601,7 +1601,6 @@ class extMain
16011601
Ath__array1D<int>* _btermTable;
16021602
Ath__array1D<int>* _itermTable;
16031603

1604-
uint _menuId;
16051604
uint _dbPowerId;
16061605
uint _dbSignalId;
16071606
uint _RsegId;
@@ -1805,7 +1804,7 @@ class extMain
18051804
ISPEF_ORIGINAL_PLUS_HALO,
18061805
ISPEF_NEW_PLUS_HALO,
18071806
};
1808-
extMain(uint menuId);
1807+
extMain();
18091808

18101809
void set_debug_nets(const char* nets)
18111810
{

src/rcx/src/ext.cpp

Lines changed: 3 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -51,16 +51,8 @@ extern "C" {
5151
extern int Rcx_Init(Tcl_Interp* interp);
5252
}
5353

54-
Ext::Ext() : odb::ZInterface()
54+
Ext::Ext() : odb::ZInterface(), _ext(std::make_unique<extMain>())
5555
{
56-
_ext = new extMain(5);
57-
_tree = NULL;
58-
logger_ = nullptr;
59-
}
60-
61-
Ext::~Ext()
62-
{
63-
delete _ext;
6456
}
6557

6658
void Ext::init(Tcl_Interp* tcl_interp, odb::dbDatabase* db, Logger* logger)
@@ -687,8 +679,8 @@ bool Ext::rc_tree(float max_cap,
687679

688680
odb::dbBlock* block = _ext->getBlock();
689681

690-
if (_tree == NULL)
691-
_tree = new extRcTree(block, logger_);
682+
if (_tree == nullptr)
683+
_tree = std::make_unique<extRcTree>(block, logger_);
692684

693685
uint cnt;
694686
if (netId > 0)

src/rcx/src/extBenchDB.cpp

Lines changed: 0 additions & 45 deletions
Original file line numberDiff line numberDiff line change
@@ -431,22 +431,6 @@ uint extRCModel::benchDB_WS(extMainOptions* opt, extMeasure* measure)
431431
}
432432
} else if (opt->_nondefault_lef_rules) {
433433
return 0;
434-
wTable->resetCnt();
435-
sTable->resetCnt();
436-
dbSet<dbTechNonDefaultRule> nd_rules = opt->_tech->getNonDefaultRules();
437-
dbSet<dbTechNonDefaultRule>::iterator nditr;
438-
dbTechLayerRule* tst_rule;
439-
440-
for (nditr = nd_rules.begin(); nditr != nd_rules.end(); ++nditr) {
441-
tst_rule = (*nditr)->getLayerRule(layer);
442-
if (tst_rule == NULL)
443-
continue;
444-
445-
double w = tst_rule->getWidth();
446-
double s = tst_rule->getSpacing();
447-
wTable->add(w);
448-
sTable->add(s);
449-
}
450434
} else {
451435
if (measure->_diag)
452436
spaceTable->add(0.0);
@@ -646,7 +630,6 @@ int extRCModel::writeBenchWires_DB(extMeasure* measure)
646630
uint WW2 = measure->_w2_nm;
647631
uint SS2 = measure->_s2_nm;
648632

649-
uint base;
650633
if (n > 1) {
651634
cnt++;
652635
measure->createNetSingleWire(_wireDirName, idCnt, WW, s_layout);
@@ -655,7 +638,6 @@ int extRCModel::writeBenchWires_DB(extMeasure* measure)
655638
cnt++;
656639
if (!measure->_diag) {
657640
measure->createNetSingleWire(_wireDirName, idCnt, WW, SS1);
658-
base = measure->_ll[measure->_dir] + WW / 2;
659641
idCnt++;
660642
cnt++;
661643
measure->createNetSingleWire(_wireDirName, idCnt, WW2, SS2);
@@ -681,40 +663,13 @@ int extRCModel::writeBenchWires_DB(extMeasure* measure)
681663
idCnt++;
682664
}
683665
} else {
684-
base = measure->_ll[measure->_dir] + WW / 2;
685666
cnt++;
686667
measure->createNetSingleWire(_wireDirName, 3, w_layout, s_layout);
687668
idCnt++;
688669
}
689670

690671
if (measure->_diag) {
691672
return cnt;
692-
693-
int met;
694-
if (measure->_overMet > 0)
695-
met = measure->_overMet;
696-
else if (measure->_underMet > 0)
697-
met = measure->_underMet;
698-
699-
double minWidth = measure->_minWidth;
700-
double minSpace = measure->_minSpace;
701-
double min_pitch = minWidth + minSpace;
702-
measure->clean2dBoxTable(met, false);
703-
int i;
704-
uint begin = base - Ath__double2int(measure->_seff * 1000)
705-
+ Ath__double2int(minWidth * 1000) / 2;
706-
for (i = 0; i < n + 1; i++) {
707-
measure->createDiagNetSingleWire(_wireDirName,
708-
idCnt,
709-
begin,
710-
Ath__double2int(1000 * minWidth),
711-
Ath__double2int(1000 * minSpace),
712-
measure->_dir);
713-
begin -= Ath__double2int(min_pitch * 1000);
714-
idCnt++;
715-
}
716-
measure->_ur[measure->_dir] += grid_gap_cnt * (w_layout + s_layout);
717-
return cnt;
718673
}
719674
bool grid_context = true;
720675
bool grid_context_same_dir = false;

src/rcx/src/extSpef.cpp

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1259,12 +1259,6 @@ uint extSpef::writeRes(uint netId, odb::dbSet<odb::dbRSeg>& rSet)
12591259
}
12601260
return cnt;
12611261
}
1262-
void getjxy(odb::dbNet* net, uint jid, Logger* logger)
1263-
{
1264-
int jx, jy;
1265-
net->getWire()->getCoord((int) jid, jx, jy);
1266-
logger->info(RCX, 174, "{}:{} {} {}", net->getId(), jid, jx, jy);
1267-
}
12681262
uint extSpef::writeNet(odb::dbNet* net, double resBound, uint debug)
12691263
{
12701264
_d_net = net;

src/rcx/src/extmain.cpp

Lines changed: 4 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -63,7 +63,7 @@ void extMain::initExtractedCorners(dbBlock* block)
6363
{
6464
extMain* tmiExt = (extMain*) block->getExtmi();
6565
if (tmiExt == NULL) {
66-
tmiExt = new extMain(0);
66+
tmiExt = new extMain;
6767
tmiExt->init((dbDatabase*) block->getDataBase(), logger_);
6868
}
6969
if (tmiExt->_processCornerTable)
@@ -76,7 +76,7 @@ int extMain::getExtCornerIndex(dbBlock* block, const char* cornerName)
7676
{
7777
extMain* tmiExt = (extMain*) block->getExtmi();
7878
if (tmiExt == NULL) {
79-
tmiExt = new extMain(0);
79+
tmiExt = new extMain;
8080
tmiExt->init((dbDatabase*) block->getDataBase(), logger_);
8181
}
8282
int idx = tmiExt->getDbCornerIndex(cornerName);
@@ -165,7 +165,7 @@ void extMain::writeIncrementalSpef(std::vector<dbNet*>& buf_nets,
165165
{
166166
extMain* tmiExt = (extMain*) block->getExtmi();
167167
if (tmiExt == NULL) {
168-
tmiExt = new extMain(0);
168+
tmiExt = new extMain;
169169
tmiExt->init((dbDatabase*) block->getDataBase(), logger_);
170170
}
171171
tmiExt->writeIncrementalSpef(buf_nets,
@@ -395,7 +395,7 @@ void extMain::setupMapping(uint itermCnt)
395395
_itermTable = new Ath__array1D<int>(itermCnt);
396396
_nodeTable = new Ath__array1D<int>(16000);
397397
}
398-
extMain::extMain(uint menuId)
398+
extMain::extMain()
399399
: _db(nullptr),
400400
_tech(nullptr),
401401
_block(nullptr),
@@ -476,7 +476,6 @@ extMain::extMain(uint menuId)
476476
_gndcFactor = 1.0;
477477
_gndcModify = false;
478478

479-
_menuId = menuId;
480479
_dbPowerId = 1;
481480
_dbSignalId = 2;
482481
_CCsegId = 3;
@@ -1227,15 +1226,6 @@ void extMain::printNet(dbNet* net, uint netId)
12271226
if (netId == net->getId())
12281227
net->printNetName(stdout);
12291228
}
1230-
bool IsDebugNets(dbNet* srcNet, dbNet* tgtNet, uint debugNetId)
1231-
{
1232-
if (srcNet != NULL && srcNet->getId() == debugNetId)
1233-
return true;
1234-
if (tgtNet != NULL && tgtNet->getId() == debugNetId)
1235-
return true;
1236-
1237-
return false;
1238-
}
12391229
void extMain::measureRC(CoupleOptions& options)
12401230
{
12411231
_totSegCnt++;
@@ -1394,11 +1384,6 @@ void extMain::measureRC(CoupleOptions& options)
13941384
}
13951385
ccReportProgress();
13961386
}
1397-
void extCompute(CoupleOptions& options, void* computePtr)
1398-
{
1399-
extMain* mmm = (extMain*) computePtr;
1400-
mmm->measureRC(options);
1401-
}
14021387
extern CoupleOptions coupleOptionsNull;
14031388

14041389
void extCompute1(CoupleOptions& options, void* computePtr)

src/rcx/src/extprocess.cpp

Lines changed: 0 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -816,19 +816,6 @@ double extMasterConductor::writeRaphaelBox(FILE* fp,
816816
double volt)
817817
{
818818
return writeRaphaelPoly(fp, wireNum, width, X, volt);
819-
820-
fprintf(fp, "BOX NAME=");
821-
writeBoxName(fp, wireNum);
822-
823-
fprintf(fp,
824-
" CX=%g; CY=%g; W=%g; H=%g; VOLT=%g\n",
825-
X,
826-
_loLeft[2],
827-
width,
828-
_hiLeft[2] - _loLeft[2],
829-
volt);
830-
831-
return X + width;
832819
}
833820
void extMasterConductor::writeRaphaelPointXY(FILE* fp, double X, double Y)
834821
{

src/rcx/src/netRC.cpp

Lines changed: 3 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1116,13 +1116,6 @@ void extMain::removeExt()
11161116
}
11171117
removeExt(rnets);
11181118
}
1119-
void v_printWireNeighbor(void* ip,
1120-
uint met,
1121-
void* v_swire,
1122-
void* v_topNeighbor,
1123-
void* v_botNeighbor)
1124-
{
1125-
}
11261119
void extCompute(CoupleOptions& inputTable, void* extModel);
11271120
void extCompute1(CoupleOptions& inputTable, void* extModel);
11281121

@@ -1881,9 +1874,11 @@ bool extMain::setCorners(const char* rulesFileName, const char* cmp_file)
18811874
logger_->info(
18821875
RCX, 435, "Reading extraction model file {} ...", rulesFileName);
18831876

1884-
if (!fopen(rulesFileName, "r"))
1877+
FILE* rules_file = fopen(rulesFileName, "r");
1878+
if (rules_file == nullptr)
18851879
logger_->error(
18861880
RCX, 468, "Can't open extraction model file {}", rulesFileName);
1881+
fclose(rules_file);
18871882

18881883
if (!(m->readRules((char*) rulesFileName,
18891884
false,

0 commit comments

Comments
 (0)