Skip to content

Commit e31f21d

Browse files
authored
Merge pull request #827 from os-fpga/checker_improved_clock_data_check
checker: improved clock-data check
2 parents 3027906 + a46d9e5 commit e31f21d

File tree

7 files changed

+104
-54
lines changed

7 files changed

+104
-54
lines changed

planning/src/RS/rsCheck.cpp

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -58,17 +58,18 @@ bool do_check_blif(CStr cfn) {
5858
bool chk_ok = bfile.checkBlif();
5959
assert(chk_ok == bfile.chk_ok_);
6060

61-
lprintf(">>>>> passed: %s\n", chk_ok ? "YES" : "NO");
61+
lprintf("===== passed: %s\n", chk_ok ? "YES" : "NO");
6262

63-
ls << ">>>>> topModel: " << bfile.topModel_ << endl;
64-
ls << ">>>>> file: " << bfile.fnm_ << endl;
65-
if (bfile.num_MOGs_) {
63+
ls << "----- topModel: " << bfile.topModel_ << endl;
64+
ls << "----- file: " << bfile.fnm_ << endl;
65+
ls << "----- PinGraph: " << bfile.pinGraphFile_ << endl;
66+
if (bfile.num_MOGs_ and tr >= 4) {
6667
ls << ">>>>> [NOTE] num_MOGs_ = " << bfile.num_MOGs_ << endl;
6768
}
6869

6970
flush_out(true);
7071
if (chk_ok) {
71-
ls << " === BLIF is OK." << endl;
72+
ls << "===== BLIF is OK." << endl;
7273
if (tr >= 4 or bfile.trace_ >= 4) {
7374
flush_out(true);
7475
lprintf(" ltrace()= %u pln_blif_trace= %u\n", tr, bfile.trace_);

planning/src/file_io/pln_blif_file.cpp

Lines changed: 48 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -183,6 +183,9 @@ bool BLIF_file::readBlif() noexcept {
183183
fabricNodes_.clear();
184184
latches_.clear();
185185
constantNodes_.clear();
186+
topModel_.clear();
187+
pinGraphFile_.clear();
188+
186189
rd_ok_ = chk_ok_ = false;
187190
err_msg_.clear();
188191
trace_ = 0;
@@ -459,7 +462,7 @@ bool BLIF_file::checkBlif() noexcept {
459462
}
460463

461464
// -- write yaml file to check prim-DB:
462-
if (trace_ >= 7) {
465+
if (trace_ >= 8) {
463466
//string written = pr_write_yaml( DFFRE );
464467
//string written = pr_write_yaml( DSP19X2 );
465468
//string written = pr_write_yaml( DSP38 );
@@ -924,7 +927,7 @@ bool BLIF_file::createNodes() noexcept {
924927
continue;
925928
}
926929

927-
if (trace_ >= 6) lprintf("\t ..... line-%u %s\n", L, cs);
930+
if (trace_ >= 7) lprintf("\t ..... line-%u %s\n", L, cs);
928931

929932
// -- parse .names
930933
if (starts_w_names(cs + 1, len - 1)) {
@@ -1571,8 +1574,9 @@ bool BLIF_file::checkClockSepar(vector<const BNode*>& clocked) noexcept {
15711574
lputs();
15721575
}
15731576

1574-
if (trace_ >= 4)
1575-
writePinGraph("pin_graph_2.dot");
1577+
if (trace_ >= 3) {
1578+
pinGraphFile_ = writePinGraph("_PinGraph.dot");
1579+
}
15761580

15771581
bool color_ok = true;
15781582
CStr viol_prefix = " ===>>> clock color violation";
@@ -1658,7 +1662,6 @@ bool BLIF_file::createPinGraph() noexcept {
16581662
assert(nid);
16591663
pg_.nodeRef(nid).markInp(true);
16601664
assert(not pg_.nodeRef(nid).isNamed());
1661-
//pg_.setNodeName(nid, port.out_);
16621665
pg_.setNodeName3(nid, port.id_, port.lnum_, port.out_.c_str());
16631666
port.nw_id_ = nid;
16641667
pg2blif_.emplace(nid, port.id_);
@@ -1672,12 +1675,23 @@ bool BLIF_file::createPinGraph() noexcept {
16721675
assert(nid);
16731676
pg_.nodeRef(nid).markOut(true);
16741677
assert(not pg_.nodeRef(nid).isNamed());
1675-
//pg_.setNodeName(nid, port.out_);
16761678
pg_.setNodeName3(nid, port.id_, port.lnum_, port.out_.c_str());
16771679
port.nw_id_ = nid;
16781680
pg2blif_.emplace(nid, port.id_);
16791681
}
16801682

1683+
uint max_nid1 = pg_.getMaxNid();
1684+
uint64_t max_key1 = pg_.getMaxKey();
1685+
if (trace_ >= 4) {
1686+
if (trace_ >= 5) lputs();
1687+
lprintf(" (pg_ after inserting top-port nodes)");
1688+
lprintf(" max_nid= %u max_key= %zu\n", max_nid1, max_key1);
1689+
if (trace_ >= 5) {
1690+
pg_.printNodes(lout(), " pg_ after inserting top-port nodes ", false);
1691+
}
1692+
}
1693+
max_key1++; // max_key1 is used to offset hashCantor
1694+
16811695
vector<qTup> Q;
16821696
Q.reserve(topInputs_.size());
16831697

@@ -1720,7 +1734,7 @@ bool BLIF_file::createPinGraph() noexcept {
17201734
}
17211735

17221736
assert(par.cell_hc_);
1723-
key = hashCantor(par.id_, pinIndex+1);
1737+
key = hashCantor(par.id_, pinIndex+1) + max_key1;
17241738
assert(key);
17251739
assert(not pg_.hasKey(key));
17261740
kid = pg_.insK(key);
@@ -1735,7 +1749,7 @@ bool BLIF_file::createPinGraph() noexcept {
17351749
par.lnum_, par.id_, pinIndex);
17361750

17371751
assert(not pg_.nodeRef(kid).inp_flag_);
1738-
pg_.setNodeName3(kid, par.id_, par.lnum_);
1752+
pg_.setNodeName4(kid, par.id_, par.lnum_, pinIndex+1, par.cPrimType());
17391753
pg_.nodeRef(kid).markClk(is_clock);
17401754

17411755
if (trace_ >= 6)
@@ -1772,7 +1786,7 @@ bool BLIF_file::createPinGraph() noexcept {
17721786
kid, bnode.lnum_, q.cellId_);
17731787

17741788
assert(not pg_.nodeRef(kid).inp_flag_);
1775-
pg_.setNodeName3(kid, bnode.id_, bnode.lnum_);
1789+
pg_.setNodeName3(kid, bnode.id_, bnode.lnum_, bnode.out_.c_str());
17761790
bnode.nw_id_ = kid;
17771791
pg2blif_.emplace(kid, bnode.id_);
17781792

@@ -1800,7 +1814,7 @@ bool BLIF_file::createPinGraph() noexcept {
18001814
if (not pr_pin_is_clock(cn.ptype_, inp))
18011815
continue;
18021816
assert(cn.cell_hc_);
1803-
key = hashCantor(cn.id_, i + 1);
1817+
key = hashCantor(cn.id_, i + 1) + max_key1;
18041818
assert(key);
18051819
// assert(not pg_.hasKey(key));
18061820
kid = pg_.insK(key);
@@ -1888,7 +1902,7 @@ bool BLIF_file::createPinGraph() noexcept {
18881902
return false;
18891903
}
18901904

1891-
uint64_t ipin_key = hashCantor(dn.id_, 1);
1905+
uint64_t ipin_key = hashCantor(dn.id_, 1) + max_key1;
18921906
assert(ipin_key);
18931907
uint ipin_nid = pg_.findNode(ipin_key);
18941908
if (ipin_nid) {
@@ -2029,32 +2043,39 @@ bool BLIF_file::createPinGraph() noexcept {
20292043
return true;
20302044
}
20312045

2032-
bool BLIF_file::writePinGraph(CStr fn) const noexcept {
2046+
string BLIF_file::writePinGraph(CStr fn0) const noexcept {
20332047
auto& ls = lout();
2034-
flush_out(true);
2035-
pg_.print(ls, "\t *** pin_graph for clock-data separation ***");
2036-
lprintf("\t pg_. numN()= %u numE()= %u\n", pg_.numN(), pg_.numE());
2037-
lputs();
2038-
pg_.printSum(ls, 0);
2039-
lputs();
2040-
pg_.printEdges(ls, "|edges|");
2041-
flush_out(true);
2048+
if (trace_ >= 5) {
2049+
flush_out(true);
2050+
pg_.print(ls, "\t *** pin_graph for clock-data separation ***");
2051+
lprintf("\t pg_. numN()= %u numE()= %u\n", pg_.numN(), pg_.numE());
2052+
lputs();
2053+
pg_.printSum(ls, 0);
2054+
lputs();
2055+
pg_.printEdges(ls, "|edges|");
2056+
flush_out(true);
2057+
}
20422058

2043-
if (!fn or !fn[0])
2044-
fn = "pinGraph.dot";
2059+
if (!fn0 or !fn0[0])
2060+
fn0 = "pinGraph.dot";
20452061

2046-
bool wrDot_ok = pg_.writeDot(fn, nullptr, true, true);
2062+
string fn = str::concat(topModel_.c_str(), "_", fn0);
2063+
2064+
bool wrDot_ok = pg_.writeDot(fn.c_str(), nullptr, true, true);
20472065
if (!wrDot_ok) {
20482066
flush_out(true); err_puts();
2049-
lprintf2("[Error] could not write pin_graph to file '%s'\n", fn);
2067+
lprintf2("[Error] could not write pin_graph to file '%s'\n", fn.c_str());
20502068
err_puts(); flush_out(true);
20512069
}
20522070

2053-
lprintf("(writePinGraph) status:%i file: %s\n",
2054-
wrDot_ok, fn);
2071+
lprintf("(writePinGraph) status:%s file: %s\n",
2072+
wrDot_ok ? "OK" : "FAIL",
2073+
fn.c_str());
20552074

20562075
flush_out(true);
2057-
return wrDot_ok;
2076+
if (wrDot_ok)
2077+
return fn;
2078+
return {};
20582079
}
20592080

20602081
}

planning/src/file_io/pln_blif_file.h

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -213,6 +213,7 @@ struct BLIF_file : public fio::MMapReader
213213
}
214214

215215
string topModel_;
216+
string pinGraphFile_;
216217

217218
vector<string> inputs_;
218219
vector<string> outputs_;
@@ -261,7 +262,8 @@ struct BLIF_file : public fio::MMapReader
261262

262263
bool createPinGraph() noexcept;
263264
bool linkPinGraph() noexcept;
264-
bool writePinGraph(CStr fn) const noexcept;
265+
266+
string writePinGraph(CStr fn0) const noexcept;
265267

266268
bool checkClockSepar(vector<const BNode*>& clocked) noexcept;
267269

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

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

planning/src/util/nw/Nw.h

Lines changed: 2 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -282,7 +282,8 @@ struct NW {
282282
bool empty() const noexcept { return nids_.empty(); }
283283

284284
inline uint getMaxLabel() const noexcept;
285-
inline uint getMaxNid() const noexcept;
285+
uint getMaxNid() const noexcept;
286+
uint64_t getMaxKey() const noexcept;
286287

287288
upair getMinMaxDeg() const noexcept;
288289
upair getMinMaxLbl() const noexcept;
@@ -812,16 +813,6 @@ inline uint NW::getMaxLabel() const noexcept {
812813
return maxLabel;
813814
}
814815

815-
inline uint NW::getMaxNid() const noexcept {
816-
if (empty()) return 0;
817-
uint maxId = 0;
818-
for (cNI I(*this); I.valid(); ++I) {
819-
const Node& nd = *I;
820-
if (nd.id_ > maxId) maxId = nd.id_;
821-
}
822-
return maxId;
823-
}
824-
825816
inline void NW::sort_xy() noexcept {
826817
std::sort(nids_.begin(), nids_.end(), Cmpi_xy(*this));
827818
}

planning/src/util/nw/Nw_io.cpp

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -346,8 +346,8 @@ void NW::Node::nprint_dot(ostream& os) const noexcept {
346346
::sprintf(attrib, "[ shape=box, color=%s, style=filled ];", cs);
347347
}
348348
else if (clk_flag_) {
349-
CStr cs = isRed() ? "red" : "orange";
350-
::sprintf(attrib, "[ shape=record, color=%s, style=filled ];", cs);
349+
CStr cs = isRed() ? "violet" : "orange";
350+
::sprintf(attrib, "[ shape=ellipse, color=%s, style=filled ];", cs);
351351
}
352352
}
353353

@@ -592,6 +592,8 @@ static const char* _colorNames[] = {
592592
};
593593

594594
CStr NW::i2color(uint i) noexcept {
595+
if (i == c_Red)
596+
return "darkviolet";
595597
return _colorNames[ i % (c_MAX_COLOR + 1) ];
596598
}
597599

planning/src/util/nw/Nw_node.cpp

Lines changed: 40 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -84,16 +84,17 @@ void NW::getOutgE(const Node& nd, vecu& E) const noexcept {
8484
}
8585
}
8686

87+
static constexpr uint STOP_ON_NAMING_NODE = 29;
88+
8789
void NW::setNodeName(uint id, CStr nm) noexcept {
8890
assert(hasNode(id));
91+
// assert(nm);
8992

90-
assert(nm);
91-
92-
//if (nodeRef(id).isNamed())
93-
// lputs1();
94-
// ---
95-
//if (id == 17)
96-
// lputs1();
93+
if (STOP_ON_NAMING_NODE) {
94+
if (id == STOP_ON_NAMING_NODE) {
95+
lputs1();
96+
}
97+
}
9798

9899
if (nm) {
99100
if (trace_ >= 6)
@@ -118,6 +119,12 @@ void NW::setNodeName3(uint id, uint B, uint L, CStr a) noexcept {
118119

119120
if (trace_ >= 6)
120121
lprintf(" (setNodeName3) %u --> %s\n", id, nd.name_.c_str());
122+
123+
if (STOP_ON_NAMING_NODE) {
124+
if (id == STOP_ON_NAMING_NODE) {
125+
lputs1();
126+
}
127+
}
121128
}
122129

123130
void NW::setNodeName4(uint id, uint B, uint L, uint ipin, CStr a) noexcept {
@@ -134,6 +141,12 @@ void NW::setNodeName4(uint id, uint B, uint L, uint ipin, CStr a) noexcept {
134141

135142
if (trace_ >= 6)
136143
lprintf(" (setNodeName4) %u --> %s\n", id, nd.name_.c_str());
144+
145+
if (STOP_ON_NAMING_NODE) {
146+
if (id == STOP_ON_NAMING_NODE) {
147+
lputs1();
148+
}
149+
}
137150
}
138151

139152
uint NW::countRedEdges() const noexcept {
@@ -154,5 +167,25 @@ void NW::clearEdges() noexcept {
154167
}
155168
}
156169

170+
uint NW::getMaxNid() const noexcept {
171+
if (empty()) return 0;
172+
uint maxId = 0;
173+
for (cNI I(*this); I.valid(); ++I) {
174+
const Node& nd = *I;
175+
if (nd.id_ > maxId) maxId = nd.id_;
176+
}
177+
return maxId;
178+
}
179+
180+
uint64_t NW::getMaxKey() const noexcept {
181+
if (empty()) return 0;
182+
uint64_t maxK = 0;
183+
for (cNI I(*this); I.valid(); ++I) {
184+
const Node& nd = *I;
185+
if (nd.key_ > maxK) maxK = nd.key_;
186+
}
187+
return maxK;
188+
}
189+
157190
}
158191

0 commit comments

Comments
 (0)