Skip to content

Commit 4709179

Browse files
authored
Merge pull request #864 from os-fpga/checker_improve_runtime_2
checker: improve runtime, skip unused DSP output bits
2 parents c2f66ae + ba0a213 commit 4709179

File tree

4 files changed

+79
-36
lines changed

4 files changed

+79
-36
lines changed

planning/src/RS/rsCheck.cpp

Lines changed: 23 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -67,25 +67,38 @@ bool do_check_blif(CStr cfn) {
6767
ls << "----- file: " << bfile.fnm_ << endl;
6868
ls << "----- #inputs= " << numInp << endl;
6969
ls << "----- #outputs= " << numOut << endl;
70-
ls << "----- #LUTs= " << bfile.countLUTs() << endl;
70+
ls << "-----\n";
71+
ls << "----- #ALL_LUTs= " << bfile.countLUTs() << endl;
7172
ls << "----- #LUT1= " << bfile.typeHist(prim::LUT1) << endl;
73+
ls << "----- #LUT2= " << bfile.typeHist(prim::LUT2) << endl;
74+
ls << "----- #LUT3= " << bfile.typeHist(prim::LUT3) << endl;
75+
ls << "----- #LUT4= " << bfile.typeHist(prim::LUT4) << endl;
7276
ls << "----- #LUT5= " << bfile.typeHist(prim::LUT5) << endl;
7377
ls << "----- #LUT6= " << bfile.typeHist(prim::LUT6) << endl;
74-
ls << "----- #FFs= " << bfile.countFFs() << endl;
78+
ls << "----- #FFs= " << bfile.countFFs() << endl;
79+
80+
ls << "-----\n";
7581
{
7682
uint nIBUF = 0, nOBUF = 0, nCBUF = 0;
7783
bfile.countBUFs(nIBUF, nOBUF, nCBUF);
78-
ls << "----- #I_BUFs= " << nIBUF << endl;
79-
ls << "----- #O_BUFs= " << nOBUF << endl;
84+
ls << "----- #I_BUFs= " << nIBUF
85+
<< " #I_FABs= " << bfile.typeHist(prim::I_FAB) << endl;
86+
87+
ls << "----- #O_BUFs= " << nOBUF
88+
<< " #O_FABs= " << bfile.typeHist(prim::O_FAB) << endl;
89+
8090
ls << "----- #CLK_BUFs= " << nCBUF << endl;
8191
}
92+
93+
ls << "-----\n";
8294
{
83-
uint nISERD = 0, nDSP38 = 0, nDSP19X = 0, nTDP_RAM36K = 0;
84-
bfile.countMOGs(nISERD, nDSP38, nDSP19X, nTDP_RAM36K);
85-
ls << "----- #I_SERDES= " << nISERD << endl;
86-
ls << "----- #DSP19X= " << nDSP19X << endl;
87-
ls << "----- #DSP38= " << nDSP38 << endl;
88-
ls << "----- #TDP_RAM36K= " << nTDP_RAM36K << endl;
95+
uint nISERD = 0, nDSP38 = 0, nDSP19X = 0, nTDP_RAM36K = 0, nTDP_RAM18K = 0;
96+
bfile.countMOGs(nISERD, nDSP38, nDSP19X, nTDP_RAM36K, nTDP_RAM18K);
97+
ls << "----- #I_SERDES= " << nISERD << endl;
98+
ls << "----- #DSP19X= " << nDSP19X << endl;
99+
ls << "----- #DSP38= " << nDSP38 << endl;
100+
ls << "----- #TDP_RAM36K= " << nTDP_RAM36K << endl;
101+
ls << "----- #TDP_RAM18KX2= " << nTDP_RAM18K << endl;
89102
}
90103
ls << "-----\n";
91104
ls << "----- PinGraph: " << bfile.pinGraphFile_ << endl;

planning/src/file_io/pln_blif_file.cpp

Lines changed: 50 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@ void BLIF_file::reset(CStr nm, uint16_t tr) noexcept {
1717
topInputs_.clear();
1818
topOutputs_.clear();
1919
fabricNodes_.clear();
20+
fabricRealNodes_.clear();
2021
latches_.clear();
2122
constantNodes_.clear();
2223
rd_ok_ = chk_ok_ = false;
@@ -184,6 +185,7 @@ bool BLIF_file::readBlif() noexcept {
184185
topInputs_.clear();
185186
topOutputs_.clear();
186187
fabricNodes_.clear();
188+
fabricRealNodes_.clear();
187189
latches_.clear();
188190
constantNodes_.clear();
189191
topModel_.clear();
@@ -417,11 +419,12 @@ bool BLIF_file::checkBlif() noexcept {
417419
lprintf("==== node summary after linking ====\n");
418420
uint nn = numNodes();
419421
ls << "==== nodes (" << nn << ") :" << endl;
420-
ls << "==== #topInputs_= " << topInputs_.size() << '\n';
421-
ls << " #topOutputs_= " << topOutputs_.size() << '\n';
422-
ls << " #fabricNodes_= " << fabricNodes_.size() << '\n';
423-
ls << " #latches_= " << latches_.size() << '\n';
424-
ls << " #constantNodes_= " << constantNodes_.size() << '\n';
422+
ls << "==== #topInputs_= " << topInputs_.size() << '\n';
423+
ls << " #topOutputs_= " << topOutputs_.size() << '\n';
424+
ls << " #fabricNodes_= " << fabricNodes_.size() << '\n';
425+
ls << " #fabricRealNodes_= " << fabricRealNodes_.size() << '\n';
426+
ls << " #latches_= " << latches_.size() << '\n';
427+
ls << " #constantNodes_= " << constantNodes_.size() << '\n';
425428
flush_out(true);
426429
}
427430
printPrimitives(ls, true);
@@ -541,11 +544,12 @@ uint BLIF_file::printNodes(std::ostream& os) const noexcept {
541544
return 0;
542545
}
543546
os << "--- nodes (" << n << ") :" << endl;
544-
os << "--- #topInputs_= " << topInputs_.size() << '\n';
545-
os << " #topOutputs_= " << topOutputs_.size() << '\n';
546-
os << " #fabricNodes_= " << fabricNodes_.size() << '\n';
547-
os << " #latches_= " << latches_.size() << '\n';
548-
os << " #constantNodes_= " << constantNodes_.size() << '\n';
547+
os << "--- #topInputs_= " << topInputs_.size() << '\n';
548+
os << " #topOutputs_= " << topOutputs_.size() << '\n';
549+
os << " #fabricNodes_= " << fabricNodes_.size() << '\n';
550+
os << " #fabricRealNodes_= " << fabricRealNodes_.size() << '\n';
551+
os << " #latches_= " << latches_.size() << '\n';
552+
os << " #constantNodes_= " << constantNodes_.size() << '\n';
549553
os << endl;
550554

551555
if (trace_ < 4) {
@@ -749,17 +753,21 @@ void BLIF_file::countBUFs(uint& nIBUF, uint& nOBUF, uint& nCBUF) const noexcept
749753
}
750754
}
751755

752-
void BLIF_file::countMOGs(uint& nISERD, uint& nDSP38, uint& nDSP19X,
753-
uint& nTDP_RAM36K) const noexcept {
754-
nISERD = nDSP38 = nDSP19X = nTDP_RAM36K = 0;
756+
void BLIF_file::countMOGs(uint& nISERD,
757+
uint& nDSP38, uint& nDSP19,
758+
uint& nRAM36, uint& nRAM18
759+
) const noexcept {
760+
nISERD = nDSP38 = nDSP19 = nRAM36 = nRAM18 = 0;
755761
uint nn = numNodes();
756762
if (nn == 0)
757763
return;
758764

759-
for (uint i = 1; i <= nn; i++) {
760-
const BNode& nd = nodePool_[i];
761-
if (nd.isTopPort() or nd.isVirtualMog())
762-
continue;
765+
assert(not fabricRealNodes_.empty());
766+
767+
for (const BNode* x : fabricRealNodes_) {
768+
const BNode& nd = *x;
769+
assert(not nd.isTopPort());
770+
assert(not nd.isVirtualMog());
763771
Prim_t pt = nd.ptype_;
764772
if (pt == I_SERDES) {
765773
nISERD++;
@@ -770,11 +778,15 @@ void BLIF_file::countMOGs(uint& nISERD, uint& nDSP38, uint& nDSP19X,
770778
continue;
771779
}
772780
if (pt == DSP19X2) {
773-
nDSP19X++;
781+
nDSP19++;
774782
continue;
775783
}
776784
if (pt == TDP_RAM36K) {
777-
nTDP_RAM36K++;
785+
nRAM36++;
786+
continue;
787+
}
788+
if (pt == TDP_RAM18KX2) {
789+
nRAM18++;
778790
}
779791
}
780792
}
@@ -1021,6 +1033,7 @@ bool BLIF_file::createNodes() noexcept {
10211033
topInputs_.clear();
10221034
topOutputs_.clear();
10231035
fabricNodes_.clear();
1036+
fabricRealNodes_.clear();
10241037
latches_.clear();
10251038
constantNodes_.clear();
10261039
if (!rd_ok_) return false;
@@ -1281,6 +1294,14 @@ bool BLIF_file::createNodes() noexcept {
12811294

12821295
std::sort(fabricNodes_.begin(), fabricNodes_.end(), BNode::CmpOut{});
12831296

1297+
fabricRealNodes_.clear();
1298+
fabricRealNodes_.reserve(fabricNodes_.size());
1299+
for (BNode* x : fabricNodes_) {
1300+
if (not x->isVirtualMog()) {
1301+
fabricRealNodes_.push_back(x);
1302+
}
1303+
}
1304+
12841305
V.clear();
12851306
topInputs_.clear();
12861307
topOutputs_.clear();
@@ -1417,8 +1438,10 @@ BLIF_file::BNode* BLIF_file::findFabricParent(uint of, const string& contact, in
14171438
assert(not contact.empty());
14181439
if (fabricNodes_.empty()) return nullptr;
14191440

1441+
assert(not fabricRealNodes_.empty());
1442+
14201443
// TMP linear
1421-
for (BNode* x : fabricNodes_) {
1444+
for (BNode* x : fabricRealNodes_) {
14221445
if (x->id_ == of) continue;
14231446
int pinIdx = x->in_contact(contact);
14241447
if (pinIdx >= 0) {
@@ -1433,8 +1456,10 @@ void BLIF_file::getFabricParents(uint of, const string& contact, vector<upair>&
14331456
assert(not contact.empty());
14341457
if (fabricNodes_.empty()) return;
14351458

1459+
assert(not fabricRealNodes_.empty());
1460+
14361461
// TMP linear
1437-
for (const BNode* x : fabricNodes_) {
1462+
for (const BNode* x : fabricRealNodes_) {
14381463
if (x->id_ == of) continue;
14391464
const BNode& nx = *x;
14401465
if (nx.inSigs_.empty())
@@ -1577,10 +1602,11 @@ bool BLIF_file::linkNodes() noexcept {
15771602
int pinIndex = -1;
15781603
BNode* par = findFabricParent(nd.id_, nd.out_, pinIndex);
15791604
if (!par) {
1580-
if (nd.is_RAM()) {
1581-
// RAM output bits may be unused
1582-
if (trace_ >= 6)
1605+
if (nd.is_RAM() or nd.is_DSP()) {
1606+
// RAM or DSP output bits may be unused
1607+
if (trace_ >= 6) {
15831608
lprintf("skipping dangling cell output issue for RAM");
1609+
}
15841610
continue;
15851611
}
15861612
err_msg_ = "dangling cell output: ";

planning/src/file_io/pln_blif_file.h

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -168,6 +168,9 @@ struct BLIF_file : public fio::MMapReader
168168
bool is_RAM() const noexcept {
169169
return prim::pr_is_RAM(ptype_);
170170
}
171+
bool is_DSP() const noexcept {
172+
return prim::pr_is_DSP(ptype_);
173+
}
171174

172175
bool canDriveClockNode() const noexcept {
173176
return isTopInput() or is_CLK_BUF() or ptype_ == prim::I_SERDES;
@@ -270,7 +273,7 @@ struct BLIF_file : public fio::MMapReader
270273
void countBUFs(uint& nIBUF, uint& nOBUF, uint& nCBUF) const noexcept;
271274

272275
void countMOGs(uint& nISERD, uint& nDSP38, uint& nDSP19X,
273-
uint& nTDP_RAM36K) const noexcept;
276+
uint& nRAM36, uint& nRAM18) const noexcept;
274277

275278
uint typeHist(prim::Prim_t t) const noexcept { return typeHistogram_[t]; }
276279

@@ -324,6 +327,7 @@ struct BLIF_file : public fio::MMapReader
324327

325328
std::vector<BNode*> topInputs_, topOutputs_;
326329
std::vector<BNode*> fabricNodes_, constantNodes_;
330+
std::vector<BNode*> fabricRealNodes_; // skip virtual SOGs
327331

328332
std::vector<BNode*> latches_; // latches are not checked for now
329333

planning/src/main.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
static const char* _pln_VERSION_STR = "pln0342";
1+
static const char* _pln_VERSION_STR = "pln0343";
22

33
#include "RS/rsEnv.h"
44
#include "util/pln_log.h"

0 commit comments

Comments
 (0)