Skip to content

Commit 793b9ff

Browse files
authored
Merge pull request #840 from os-fpga/checker_recogn_DSP_output_EDA3235
checker: recognize DSP MOGs EDA-3235
2 parents 31ee24d + 66e3386 commit 793b9ff

File tree

6 files changed

+103
-4
lines changed

6 files changed

+103
-4
lines changed

planning/src/RS/rsCheck.cpp

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -69,14 +69,22 @@ bool do_check_blif(CStr cfn) {
6969
ls << "----- #outputs= " << numOut << endl;
7070
ls << "----- #LUTs= " << bfile.countLUTs() << endl;
7171
ls << "----- #FFs= " << bfile.countFFs() << endl;
72+
{
7273
uint nIBUF = 0, nOBUF = 0, nCBUF = 0;
7374
bfile.countBUFs(nIBUF, nOBUF, nCBUF);
7475
ls << "----- #I_BUFs= " << nIBUF << endl;
7576
ls << "----- #O_BUFs= " << nOBUF << endl;
7677
ls << "----- #CLK_BUFs= " << nCBUF << endl;
77-
ls << "----- #I_SERDES= " << bfile.typeHist(prim::I_SERDES) << endl;
78+
}
79+
{
80+
uint nISERD = 0, nDSP38 = 0, nDSP19X = 0;
81+
bfile.countMOGs(nISERD, nDSP38, nDSP19X);
82+
ls << "----- #I_SERDES= " << nISERD << endl;
83+
ls << "----- #DSP19X= " << nDSP19X << endl;
84+
ls << "----- #DSP38= " << nDSP38 << endl;
85+
}
7886
ls << "----- PinGraph: " << bfile.pinGraphFile_ << endl;
79-
if (bfile.num_MOGs_ and tr >= 5) {
87+
if (bfile.num_MOGs_ and tr >= 6) {
8088
ls << ">>>>> [NOTE] num_MOGs_ = " << bfile.num_MOGs_ << endl;
8189
}
8290
lprintf("===== passed: %s\n", chk_ok ? "YES" : "NO");

planning/src/file_io/pln_blif_file.cpp

Lines changed: 41 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -725,6 +725,8 @@ void BLIF_file::countBUFs(uint& nIBUF, uint& nOBUF, uint& nCBUF) const noexcept
725725

726726
for (uint i = 1; i <= nn; i++) {
727727
const BNode& nd = nodePool_[i];
728+
if (nd.isTopPort())
729+
continue;
728730
if (nd.is_IBUF()) {
729731
nIBUF++;
730732
continue;
@@ -739,6 +741,31 @@ void BLIF_file::countBUFs(uint& nIBUF, uint& nOBUF, uint& nCBUF) const noexcept
739741
}
740742
}
741743

744+
void BLIF_file::countMOGs(uint& nISERD, uint& nDSP38, uint& nDSP19X) const noexcept {
745+
nISERD = nDSP38 = nDSP19X = 0;
746+
uint nn = numNodes();
747+
if (nn == 0)
748+
return;
749+
750+
for (uint i = 1; i <= nn; i++) {
751+
const BNode& nd = nodePool_[i];
752+
if (nd.isTopPort() or nd.isVirtualMog())
753+
continue;
754+
Prim_t pt = nd.ptype_;
755+
if (pt == I_SERDES) {
756+
nISERD++;
757+
continue;
758+
}
759+
if (pt == DSP38) {
760+
nDSP38++;
761+
continue;
762+
}
763+
if (pt == DSP19X2) {
764+
nDSP19X++;
765+
}
766+
}
767+
}
768+
742769
uint BLIF_file::countCarryNodes() const noexcept {
743770
uint nn = numNodes();
744771
if (nn == 0)
@@ -846,6 +873,20 @@ static bool s_is_MOG(const BLIF_file::BNode& nd,
846873
}
847874
return true;
848875
}
876+
if (nd.ptype_ == DSP38) {
877+
for (const string& t : data) {
878+
if (is_DSP38_output_term(t))
879+
terms.push_back(t);
880+
}
881+
return true;
882+
}
883+
if (nd.ptype_ == DSP19X2) {
884+
for (const string& t : data) {
885+
if (is_DSP19X2_output_term(t))
886+
terms.push_back(t);
887+
}
888+
return true;
889+
}
849890

850891
bool has_O = false, has_Y = false, has_Q = false,
851892
has_COUT = false;

planning/src/file_io/pln_blif_file.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -265,6 +265,7 @@ 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;
268269

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

planning/src/file_io/pln_primitives.cpp

Lines changed: 47 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -593,7 +593,7 @@ bool is_I_SERDES_output_term(const string& term) noexcept {
593593

594594
static std::regex re_iserdes_out{
595595
R"(CLK_OUT=|Q=|DATA_VALID=|DPA_LOCK=|DPA_ERROR=|Q\[\d+\]=)" };
596-
596+
597597
std::cmatch m;
598598
bool b = false;
599599

@@ -711,6 +711,52 @@ R"(CLK_OUT=|CLK_OUT_DIV2=|CLK_OUT_DIV3=|CLK_OUT_DIV4=|SERDES_FAST_CLK=|LOCK=)";
711711
return b;
712712
}
713713

714+
bool is_DSP38_output_term(const string& term) noexcept {
715+
assert(!term.empty());
716+
if (term.empty()) return false;
717+
718+
static std::regex re_dsp38_out{
719+
R"(Z\[\d+\]=|DLY_B\[\d+\]=)" };
720+
721+
std::cmatch m;
722+
bool b = false;
723+
724+
try {
725+
b = std::regex_search(term.c_str(), m, re_dsp38_out);
726+
} catch (...) {
727+
assert(0);
728+
b = false;
729+
}
730+
731+
//if (b)
732+
// lprintf("__DSP38_output REGEX matched: %s\n", term.c_str());
733+
734+
return b;
735+
}
736+
737+
bool is_DSP19X2_output_term(const string& term) noexcept {
738+
assert(!term.empty());
739+
if (term.empty()) return false;
740+
741+
static std::regex re_dsp19_out{
742+
R"(Z1\[\d+\]=|DLY_B1\[\d+\]=|Z2\[\d+\]=|DLY_B2\[\d+\]=)" };
743+
744+
std::cmatch m;
745+
bool b = false;
746+
747+
try {
748+
b = std::regex_search(term.c_str(), m, re_dsp19_out);
749+
} catch (...) {
750+
assert(0);
751+
b = false;
752+
}
753+
754+
//if (b)
755+
// lprintf("__DSP19X2_output REGEX matched: %s\n", term.c_str());
756+
757+
return b;
758+
}
759+
714760
// string -> enum, returns A_ZERO on error
715761
Prim_t pr_str2enum(CStr name) noexcept {
716762
if (!name or !name[0])

planning/src/file_io/pln_primitives.h

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -108,6 +108,9 @@ bool is_TDP_RAM18KX_output_term(const std::string& term) noexcept;
108108

109109
bool is_PLL_output_term(const std::string& term) noexcept;
110110

111+
bool is_DSP38_output_term(const std::string& term) noexcept;
112+
bool is_DSP19X2_output_term(const std::string& term) noexcept;
113+
111114
// DEBUG:
112115
std::string pr_write_yaml(Prim_t pt) noexcept;
113116

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

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

0 commit comments

Comments
 (0)