Skip to content

Commit 6ecdcc4

Browse files
committed
checker: handle pins of SERDES and RAM
1 parent e3f7876 commit 6ecdcc4

File tree

5 files changed

+207
-11
lines changed

5 files changed

+207
-11
lines changed

stars/src/RS/rsOpts.cpp

Lines changed: 18 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -149,8 +149,24 @@ void rsOpts::print(CStr label) const noexcept {
149149
void rsOpts::printHelp() const noexcept {
150150
cout << "Usage:" << endl;
151151

152-
#ifdef RSBE_UNIT_TEST_ON
153-
#endif // RSBE_UNIT_TEST_ON
152+
static CStr tab1[] = {
153+
"--help,-H", "Help",
154+
"--version,-V", "Version",
155+
"--check <blif_file_name>", "BLIF or EBLIF file to check",
156+
"--csv <csv_file_name>", "CSV file (pin table) to check",
157+
nullptr, nullptr, nullptr };
158+
159+
for (uint i = 0; ; i += 2) {
160+
CStr opt = tab1[i];
161+
if (!opt)
162+
break;
163+
CStr hlp = tab1[i+1];
164+
if (!hlp)
165+
break;
166+
printf("%30s : %s\n", opt, hlp);
167+
}
168+
169+
flush_out(true);
154170
}
155171

156172
static char* make_file_name(CStr arg) noexcept {

stars/src/file_readers/pln_blif_file.cpp

Lines changed: 83 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -159,6 +159,12 @@ void BLIF_file::Node::place_output_at_back(vector<string>& dat) noexcept {
159159
size_t dsz = dat.size();
160160
if (dsz < 3) return;
161161
CStr cs = dat.back().c_str();
162+
//if (1) {
163+
// lprintf("\t ||||| place_output_at_back() dat.size()= %zu\n", dsz);
164+
// lprintf("\t ||||| kw_= %s prim:%s\n", kw_.c_str(), primt_name(ptype_));
165+
// if (lnum_ == 76)
166+
// lputs9();
167+
//}
162168
if (starts_w_R_eq(cs)) {
163169
std::swap(dat[dsz - 2], dat[dsz - 1]);
164170
}
@@ -531,14 +537,44 @@ uint BLIF_file::printCarryNodes(std::ostream& os) const noexcept {
531537
return cnt;
532538
}
533539

534-
static bool s_is_MOG(const vector<string>& data,
540+
static bool s_is_MOG(const BLIF_file::Node& nd,
535541
vector<string>& terms) noexcept {
536542
terms.clear();
543+
const vector<string>& data = nd.data_;
537544
uint dsz = data.size();
538545
assert(dsz < 1000000);
539546
if (dsz < 4)
540547
return false;
541548

549+
if (nd.ptype_ == I_SERDES) {
550+
for (const string& t : data) {
551+
if (is_I_SERDES_output_term(t))
552+
terms.push_back(t);
553+
}
554+
return true;
555+
}
556+
if (nd.ptype_ == O_SERDES) {
557+
for (const string& t : data) {
558+
if (is_O_SERDES_output_term(t))
559+
terms.push_back(t);
560+
}
561+
return true;
562+
}
563+
if (nd.ptype_ == TDP_RAM36K) {
564+
for (const string& t : data) {
565+
if (is_TDP_RAM36K_output_term(t))
566+
terms.push_back(t);
567+
}
568+
return true;
569+
}
570+
if (nd.ptype_ == TDP_RAM18KX2) {
571+
for (const string& t : data) {
572+
if (is_TDP_RAM18KX_output_term(t))
573+
terms.push_back(t);
574+
}
575+
return true;
576+
}
577+
542578
bool has_O = false, has_Y = false, has_Q = false,
543579
has_COUT = false;
544580
uint sum = 0;
@@ -565,7 +601,6 @@ static bool s_is_MOG(const vector<string>& data,
565601
if (has_COUT)
566602
terms.emplace_back(cs);
567603
}
568-
// sum = uint(has_O) + uint(has_Y) + uint(has_Q) + uint(has_COUT);
569604
}
570605

571606
sum = uint(has_O) + uint(has_Y) + uint(has_Q) + uint(has_COUT);
@@ -576,11 +611,54 @@ static bool s_is_MOG(const vector<string>& data,
576611
return true;
577612
}
578613

579-
static void s_remove_MOG_terms(vector<string>& data) noexcept {
614+
static void s_remove_MOG_terms(BLIF_file::Node& nd) noexcept {
615+
vector<string>& data = nd.data_;
580616
uint dsz = data.size();
581617
assert(dsz < 1000000);
582618
if (dsz < 4)
583619
return;
620+
621+
if (nd.ptype_ == I_SERDES) {
622+
for (uint i = dsz - 1; i > 1; i--) {
623+
const string& t = data[i];
624+
if (is_I_SERDES_output_term(t)) {
625+
data.erase(data.begin() + i);
626+
continue;
627+
}
628+
}
629+
return;
630+
}
631+
if (nd.ptype_ == O_SERDES) {
632+
for (uint i = dsz - 1; i > 1; i--) {
633+
const string& t = data[i];
634+
if (is_O_SERDES_output_term(t)) {
635+
data.erase(data.begin() + i);
636+
continue;
637+
}
638+
}
639+
return;
640+
}
641+
if (nd.ptype_ == TDP_RAM36K) {
642+
for (uint i = dsz - 1; i > 1; i--) {
643+
const string& t = data[i];
644+
if (is_TDP_RAM36K_output_term(t)) {
645+
data.erase(data.begin() + i);
646+
continue;
647+
}
648+
}
649+
return;
650+
}
651+
if (nd.ptype_ == TDP_RAM18KX2) {
652+
for (uint i = dsz - 1; i > 1; i--) {
653+
const string& t = data[i];
654+
if (is_TDP_RAM18KX_output_term(t)) {
655+
data.erase(data.begin() + i);
656+
continue;
657+
}
658+
}
659+
return;
660+
}
661+
584662
for (uint i = dsz - 1; i > 1; i--) {
585663
CStr cs = data[i].c_str();
586664
if (starts_w_O_eq(cs)) {
@@ -716,10 +794,7 @@ bool BLIF_file::createNodes() noexcept {
716794
continue;
717795
assert(!nd.is_mog_);
718796

719-
// if (topModel_ == "MOG_01" and i == 10)
720-
// lputs9();
721-
722-
s_is_MOG(nd.data_, V);
797+
s_is_MOG(nd, V);
723798
bool is_mog = V.size() > 1;
724799
if (is_mog) {
725800
if (trace_ >= 5) {
@@ -729,7 +804,7 @@ bool BLIF_file::createNodes() noexcept {
729804
lputs();
730805
}
731806

732-
s_remove_MOG_terms(nd.data_);
807+
s_remove_MOG_terms(nd);
733808
uint startVirtual = nodePool_.size();
734809
for (uint j = 1; j < V.size(); j++) {
735810
nodePool_.emplace_back(nd);

stars/src/file_readers/pln_primitives.cpp

Lines changed: 101 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
#include "file_readers/pln_primitives.h"
2+
#include <regex>
23

34
namespace pln {
45

@@ -180,6 +181,106 @@ static inline bool starts_w_CAR(CStr z) noexcept {
180181
return z[0] == 'C' and z[1] == 'A' and z[2] == 'R';
181182
}
182183

184+
bool is_I_SERDES_output_term(const std::string& term) noexcept {
185+
assert(!term.empty());
186+
if (term.empty()) return false;
187+
188+
static std::regex re_iserdes_out{
189+
R"(DLY_TAP_VALUE=|CLK_OUT=|CDR_CORE_CLK=|Q=|DATA_VALID=|DPA_LOCK=|DPA_ERROR=|Q\[\d+\]=)" };
190+
191+
std::cmatch m;
192+
bool b = false;
193+
194+
try {
195+
b = std::regex_search(term.c_str(), m, re_iserdes_out);
196+
} catch (...) {
197+
assert(0);
198+
b = false;
199+
}
200+
201+
//if (b)
202+
// lprintf("__I_SERDES_output REGEX matched: %s\n", term.c_str());
203+
204+
return b;
205+
}
206+
207+
bool is_O_SERDES_output_term(const std::string& term) noexcept {
208+
assert(!term.empty());
209+
if (term.empty()) return false;
210+
211+
static std::regex re_oserdes_out{
212+
R"(CLK_OUT=|Q=|CHANNEL_BOND_SYNC_OUT=|DLY_TAP_VALUE=|Q\[\d+\]=)" };
213+
214+
std::cmatch m;
215+
bool b = false;
216+
217+
try {
218+
b = std::regex_search(term.c_str(), m, re_oserdes_out);
219+
} catch (...) {
220+
assert(0);
221+
b = false;
222+
}
223+
224+
//if (b)
225+
// lprintf("__O_SERDES_output REGEX matched: %s\n", term.c_str());
226+
227+
return b;
228+
}
229+
230+
bool is_TDP_RAM36K_output_term(const std::string& term) noexcept {
231+
assert(!term.empty());
232+
if (term.empty()) return false;
233+
234+
// // TDP_RAM36K = 32,
235+
// { "RDATA_A", "RPARITY_A", "RDATA_B", "RPARITY_B" },
236+
237+
static std::regex re_RAM36K_out{
238+
R"(RDATA_A=|RPARITY_A=|RDATA_B=|RPARITY_B=|RDATA_A\[\d+\]=|RPARITY_A\[\d+\]=|RDATA_B\[\d+\]=|RPARITY_B\[\d+\]=)"
239+
};
240+
241+
std::cmatch m;
242+
bool b = false;
243+
244+
try {
245+
b = std::regex_search(term.c_str(), m, re_RAM36K_out);
246+
} catch (...) {
247+
assert(0);
248+
b = false;
249+
}
250+
251+
//if (b)
252+
// lprintf("__RAM36K_output REGEX matched: %s\n", term.c_str());
253+
254+
return b;
255+
}
256+
257+
bool is_TDP_RAM18KX_output_term(const std::string& term) noexcept {
258+
assert(!term.empty());
259+
if (term.empty()) return false;
260+
261+
// // TDP_RAM18KX2 = 31,
262+
// { "RDATA_A1", "RDATA_B1", "RDATA_A2", "RDATA_B2" },
263+
264+
static std::regex re_RAM18KX_out{
265+
R"(RDATA_A1=|RDATA_A1\[\d+\]=|RDATA_A2=|RDATA_A2\[\d+\]=|RDATA_B1=|RDATA_B1\[\d+\]=|RDATA_B2=|RDATA_B2\[\d+\]=)"
266+
};
267+
268+
std::cmatch m;
269+
bool b = false;
270+
271+
try {
272+
b = std::regex_search(term.c_str(), m, re_RAM18KX_out);
273+
} catch (...) {
274+
assert(0);
275+
b = false;
276+
}
277+
278+
//if (b)
279+
// lprintf("__RAM18KX_output REGEX matched: %s\n", term.c_str());
280+
281+
return b;
282+
}
283+
183284
// string -> enum, returns A_ZERO on error
184285
Prim_t primt_id(CStr name) noexcept {
185286
if (!name or !name[0])

stars/src/file_readers/pln_primitives.h

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -67,6 +67,10 @@ inline bool prim_pin_is_output(Prim_t primId, const std::string& pinName) noexce
6767
return prim_cpin_is_output(primId, pinName.c_str());
6868
}
6969

70+
bool is_I_SERDES_output_term(const std::string& term) noexcept;
71+
bool is_O_SERDES_output_term(const std::string& term) noexcept;
72+
bool is_TDP_RAM36K_output_term(const std::string& term) noexcept;
73+
bool is_TDP_RAM18KX_output_term(const std::string& term) noexcept;
7074

7175
}
7276

stars/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 = "pln0227";
1+
static const char* _pln_VERSION_STR = "pln0231";
22

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

0 commit comments

Comments
 (0)