Skip to content

Commit 521d62e

Browse files
committed
checker: added outputs for RAM36K in PrimDB
1 parent bcbbc0d commit 521d62e

File tree

6 files changed

+113
-38
lines changed

6 files changed

+113
-38
lines changed

planning/src/RS/rsCheck.cpp

Lines changed: 21 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -63,34 +63,36 @@ bool do_check_blif(CStr cfn) {
6363

6464
lprintf("===== passed: %s\n", chk_ok ? "YES" : "NO");
6565

66-
ls << "----- topModel: " << bfile.topModel_ << endl;
67-
ls << "----- file: " << bfile.fnm_ << endl;
68-
ls << "----- #inputs= " << numInp << endl;
69-
ls << "----- #outputs= " << numOut << endl;
70-
ls << "----- #LUTs= " << bfile.countLUTs() << endl;
71-
ls << "----- #LUT1= " << bfile.typeHist(prim::LUT1) << endl;
72-
ls << "----- #LUT5= " << bfile.typeHist(prim::LUT5) << endl;
73-
ls << "----- #LUT6= " << bfile.typeHist(prim::LUT6) << endl;
74-
ls << "----- #FFs= " << bfile.countFFs() << endl;
66+
ls << "----- topModel: " << bfile.topModel_ << endl;
67+
ls << "----- file: " << bfile.fnm_ << endl;
68+
ls << "----- #inputs= " << numInp << endl;
69+
ls << "----- #outputs= " << numOut << endl;
70+
ls << "----- #LUTs= " << bfile.countLUTs() << endl;
71+
ls << "----- #LUT1= " << bfile.typeHist(prim::LUT1) << endl;
72+
ls << "----- #LUT5= " << bfile.typeHist(prim::LUT5) << endl;
73+
ls << "----- #LUT6= " << bfile.typeHist(prim::LUT6) << endl;
74+
ls << "----- #FFs= " << bfile.countFFs() << endl;
7575
{
7676
uint nIBUF = 0, nOBUF = 0, nCBUF = 0;
7777
bfile.countBUFs(nIBUF, nOBUF, nCBUF);
78-
ls << "----- #I_BUFs= " << nIBUF << endl;
79-
ls << "----- #O_BUFs= " << nOBUF << endl;
80-
ls << "----- #CLK_BUFs= " << nCBUF << endl;
78+
ls << "----- #I_BUFs= " << nIBUF << endl;
79+
ls << "----- #O_BUFs= " << nOBUF << endl;
80+
ls << "----- #CLK_BUFs= " << nCBUF << endl;
8181
}
8282
{
83-
uint nISERD = 0, nDSP38 = 0, nDSP19X = 0;
84-
bfile.countMOGs(nISERD, nDSP38, nDSP19X);
85-
ls << "----- #I_SERDES= " << nISERD << endl;
86-
ls << "----- #DSP19X= " << nDSP19X << endl;
87-
ls << "----- #DSP38= " << nDSP38 << endl;
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;
8889
}
89-
ls << "----- PinGraph: " << bfile.pinGraphFile_ << endl;
90+
ls << "-----\n";
91+
ls << "----- PinGraph: " << bfile.pinGraphFile_ << endl;
9092
if (bfile.num_MOGs_ and tr >= 6) {
9193
ls << ">>>>> [NOTE] num_MOGs_ = " << bfile.num_MOGs_ << endl;
9294
}
93-
lprintf("===== passed: %s\n", chk_ok ? "YES" : "NO");
95+
lprintf("===== passed: %s\n", chk_ok ? "YES" : "NO");
9496

9597
flush_out(true);
9698
if (chk_ok) {

planning/src/file_io/pln_blif_file.cpp

Lines changed: 57 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -390,11 +390,13 @@ bool BLIF_file::checkBlif() noexcept {
390390
flush_out(true);
391391
}
392392

393+
#ifndef NDEBUG
393394
// confirm that all fab node have output:
394-
// for (const BNode* fab_nd : fabricNodes_) {
395-
// assert(fab_nd);
396-
// assert(not fab_nd->out_.empty());
397-
// }
395+
for (const BNode* fab_nd : fabricNodes_) {
396+
assert(fab_nd);
397+
assert(not fab_nd->out_.empty());
398+
}
399+
#endif
398400

399401
bool link_ok = linkNodes();
400402
if (not link_ok) {
@@ -477,20 +479,20 @@ bool BLIF_file::checkBlif() noexcept {
477479

478480
// -- write yaml file to check prim-DB:
479481
if (trace_ >= 8) {
480-
//string written = pr_write_yaml( DFFRE );
481482
//string written = pr_write_yaml( DSP19X2 );
482483
//string written = pr_write_yaml( DSP38 );
483484
//string written = pr_write_yaml( FIFO36K );
484-
string written = pr_write_yaml( FIFO18KX2 );
485+
//string written = pr_write_yaml( FIFO18KX2 );
486+
string written = pr_write_yaml( TDP_RAM36K );
485487
flush_out(true);
486488
if (written.empty()) {
487489
lprintf("\t\t FAIL: pr_write_yaml() FAILED\n\n");
488490
} else {
489491
lprintf("\t written: %s\n\n", written.c_str());
490492
if (0) {
491493
lprintf("\n ");
492-
for (int bb = 18; bb >= 0; bb--) {
493-
lprintf(" \"RD_DATA2[%i]\",", bb);
494+
for (int bb = 30; bb >= 0; bb--) {
495+
lprintf(" \"RDATA_A[%i]\",", bb);
494496
}
495497
lputs();
496498
lputs();
@@ -747,8 +749,9 @@ void BLIF_file::countBUFs(uint& nIBUF, uint& nOBUF, uint& nCBUF) const noexcept
747749
}
748750
}
749751

750-
void BLIF_file::countMOGs(uint& nISERD, uint& nDSP38, uint& nDSP19X) const noexcept {
751-
nISERD = nDSP38 = nDSP19X = 0;
752+
void BLIF_file::countMOGs(uint& nISERD, uint& nDSP38, uint& nDSP19X,
753+
uint& nTDP_RAM36K) const noexcept {
754+
nISERD = nDSP38 = nDSP19X = nTDP_RAM36K = 0;
752755
uint nn = numNodes();
753756
if (nn == 0)
754757
return;
@@ -768,6 +771,10 @@ void BLIF_file::countMOGs(uint& nISERD, uint& nDSP38, uint& nDSP19X) const noexc
768771
}
769772
if (pt == DSP19X2) {
770773
nDSP19X++;
774+
continue;
775+
}
776+
if (pt == TDP_RAM36K) {
777+
nTDP_RAM36K++;
771778
}
772779
}
773780
}
@@ -1023,14 +1030,48 @@ bool BLIF_file::createNodes() noexcept {
10231030
if (not hasLines() or lsz < 3) return false;
10241031
if (lsz >= UINT_MAX) return false;
10251032

1026-
nodePool_.reserve(4 * lsz + 8);
1027-
nodePool_.emplace_back(); // put a fake node
1028-
1029-
char buf[4096] = {};
10301033
vector<string> V;
10311034
V.reserve(16);
10321035
inputs_lnum_ = outputs_lnum_ = 0;
10331036
err_lnum_ = 0;
1037+
1038+
// estimate #MOG-bnodes to reserve memory
1039+
{
1040+
size_t MOG_bnodes = 0;
1041+
1042+
for (uint L = 1; L < lsz; L++) {
1043+
V.clear();
1044+
CStr cs = lines_[L];
1045+
if (!cs || !cs[0]) continue;
1046+
cs = str::trimFront(cs);
1047+
assert(cs);
1048+
size_t len = ::strlen(cs);
1049+
if (len < 3) continue;
1050+
if (cs[0] != '.') continue;
1051+
if (not starts_w_subckt(cs + 1, len - 1))
1052+
continue;
1053+
Fio::split_spa(lines_[L], V);
1054+
if (V.size() > 1 and V.front() == ".subckt") {
1055+
Prim_t pt = pr_str2enum( V[1].c_str() );
1056+
if (pr_is_MOG(pt)) {
1057+
MOG_bnodes++;
1058+
MOG_bnodes += pr_num_outputs(pt);
1059+
}
1060+
}
1061+
}
1062+
1063+
if (trace_ >= 5)
1064+
lprintf(" estimated #MOG bnodes = %zu\n", MOG_bnodes);
1065+
1066+
MOG_bnodes++;
1067+
nodePool_.reserve(lsz * 4 + MOG_bnodes * 8);
1068+
nodePool_.emplace_back(); // put a fake node
1069+
}
1070+
1071+
char buf[4096] = {};
1072+
V.clear();
1073+
inputs_lnum_ = outputs_lnum_ = 0;
1074+
err_lnum_ = 0;
10341075
for (uint L = 1; L < lsz; L++) {
10351076
V.clear();
10361077
CStr cs = lines_[L];
@@ -1049,7 +1090,7 @@ bool BLIF_file::createNodes() noexcept {
10491090
continue;
10501091
}
10511092

1052-
if (trace_ >= 7) lprintf("\t ..... line-%u %s\n", L, cs);
1093+
if (trace_ >= 8) lprintf("\t ..... line-%u %s\n", L, cs);
10531094

10541095
// -- parse .names
10551096
if (starts_w_names(cs + 1, len - 1)) {
@@ -1127,7 +1168,7 @@ bool BLIF_file::createNodes() noexcept {
11271168
bool is_mog = V.size() > 1;
11281169
if (is_mog) {
11291170
if (trace_ >= 5) {
1130-
lprintf("\t\t .... MOG-type: %s\n", nd.cPrimType());
1171+
lprintf("\t\t ____ MOG-type: %s\n", nd.cPrimType());
11311172
lprintf("\t\t .... [terms] V.size()= %zu\n", V.size());
11321173
logVec(V, " [V-terms] ");
11331174
lputs();

planning/src/file_io/pln_blif_file.h

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -265,7 +265,9 @@ struct BLIF_file : public fio::MMapReader
265265
uint countFFs() const noexcept;
266266
uint countCBUFs() const noexcept;
267267
void countBUFs(uint& nIBUF, uint& nOBUF, uint& nCBUF) const noexcept;
268-
void countMOGs(uint& nISERD, uint& nDSP38, uint& nDSP19X) const noexcept;
268+
269+
void countMOGs(uint& nISERD, uint& nDSP38, uint& nDSP19X,
270+
uint& nTDP_RAM36K) const noexcept;
269271

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

planning/src/file_io/pln_primitives.cpp

Lines changed: 23 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -189,7 +189,29 @@ using std::string;
189189
"RPARITY_A1", "RPARITY_B1", "RPARITY_A2", "RPARITY_B2" },
190190

191191
// TDP_RAM36K
192-
{ "RDATA_A", "RPARITY_A", "RDATA_B", "RPARITY_B" },
192+
{
193+
// RDATA_A[31:0]
194+
"RDATA_A[30]", "RDATA_A[29]", "RDATA_A[28]", "RDATA_A[27]", "RDATA_A[26]", "RDATA_A[25]",
195+
"RDATA_A[24]", "RDATA_A[23]", "RDATA_A[22]", "RDATA_A[21]", "RDATA_A[20]", "RDATA_A[19]",
196+
"RDATA_A[18]", "RDATA_A[17]", "RDATA_A[16]", "RDATA_A[15]", "RDATA_A[14]", "RDATA_A[13]",
197+
"RDATA_A[12]", "RDATA_A[11]", "RDATA_A[10]", "RDATA_A[9]", "RDATA_A[8]", "RDATA_A[7]",
198+
"RDATA_A[6]", "RDATA_A[5]", "RDATA_A[4]", "RDATA_A[3]", "RDATA_A[2]",
199+
"RDATA_A[1]", "RDATA_A[0]",
200+
201+
// RDATA_B[31:0]
202+
"RDATA_B[30]", "RDATA_B[29]", "RDATA_B[28]", "RDATA_B[27]", "RDATA_B[26]", "RDATA_B[25]",
203+
"RDATA_B[24]", "RDATA_B[23]", "RDATA_B[22]", "RDATA_B[21]", "RDATA_B[20]", "RDATA_B[19]",
204+
"RDATA_B[18]", "RDATA_B[17]", "RDATA_B[16]", "RDATA_B[15]", "RDATA_B[14]", "RDATA_B[13]",
205+
"RDATA_B[12]", "RDATA_B[11]", "RDATA_B[10]", "RDATA_B[9]", "RDATA_B[8]", "RDATA_B[7]",
206+
"RDATA_B[6]", "RDATA_B[5]", "RDATA_B[4]", "RDATA_B[3]", "RDATA_B[2]",
207+
"RDATA_B[1]", "RDATA_B[0]",
208+
209+
// RPARITY_A[3:0]
210+
"RPARITY_A[2]", "RPARITY_A[1]", "RPARITY_A[0]",
211+
212+
// RPARITY_B[3:0]
213+
"RPARITY_B[2]", "RPARITY_B[1]", "RPARITY_B[0]"
214+
},
193215

194216
{}, // X_UNKNOWN
195217
{}, // Y_UPPER_GUARD

planning/src/file_io/pln_primitives.h

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -92,6 +92,14 @@ inline bool pr_is_RAM(Prim_t t) noexcept {
9292
return t == TDP_RAM18KX2 or t == TDP_RAM36K;
9393
}
9494

95+
inline bool pr_is_MOG(Prim_t t) noexcept {
96+
if (pr_is_LUT(t) or pr_is_DFF(t))
97+
return false;
98+
if (pr_is_DSP(t) or pr_is_RAM(t))
99+
return true;
100+
return pr_num_outputs(t) > 1;
101+
}
102+
95103
bool pr_is_core_fabric(Prim_t t) noexcept;
96104

97105
void pr_get_inputs(Prim_t pt, std::vector<std::string>& INP) noexcept;

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 = "pln0338";
1+
static const char* _pln_VERSION_STR = "pln0339";
22

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

0 commit comments

Comments
 (0)