Skip to content

Commit 9fddffa

Browse files
committed
checker: fix pinGraph bug EDA-3235
1 parent a94fb94 commit 9fddffa

File tree

7 files changed

+72
-24
lines changed

7 files changed

+72
-24
lines changed

planning/src/file_io/pln_blif_file.cpp

Lines changed: 41 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -196,6 +196,12 @@ CStr BLIF_file::BNode::cPrimType() const noexcept {
196196
return ptype_ == prim::A_ZERO ? "{e}" : pr_enum2str(ptype_);
197197
}
198198

199+
CStr BLIF_file::BNode::cPortName() const noexcept {
200+
if (isTopPort() and not data_.empty())
201+
return data_.front().c_str();
202+
return "{np}";
203+
}
204+
199205
bool BLIF_file::BNode::isDanglingTerm(uint term) const noexcept {
200206
if (dangTerms_.empty())
201207
return false;
@@ -1336,13 +1342,6 @@ bool BLIF_file::createNodes() noexcept {
13361342
continue;
13371343
assert(!nd.is_mog_);
13381344

1339-
//if (nd.lnum_ == 48) {
1340-
// string delWire1151 = "$delete_wire$1151";
1341-
// lputs8();
1342-
// int dTerm = findTermByNet(nd.data_, delWire1151);
1343-
// lprintf(" dTerm= %i\n", dTerm);
1344-
//}
1345-
13461345
s_is_MOG(nd, V);
13471346
bool is_mog = V.size() > 1;
13481347
if (is_mog) {
@@ -2152,10 +2151,15 @@ bool BLIF_file::createPinGraph() noexcept {
21522151

21532152
if (trace_ >= 5) {
21542153
lputs();
2155-
lprintf(" TopInput: lnum_= %u %s PAR.size()= %zu\n",
2156-
port.lnum_, port.out_.c_str(), PAR.size());
2154+
lprintf(" TopInput: id_= %u lnum_= %u %s PAR.size()= %zu\n",
2155+
port.id_, port.lnum_, port.out_.c_str(), PAR.size());
2156+
if (trace_ >= 6)
2157+
lprintf(" %s\n", port.cPortName());
21572158
}
21582159

2160+
// if (port.id_ == 24)
2161+
// lputs1();
2162+
21592163
for (const upair& pa : PAR) {
21602164
if (pa.first == port.id_)
21612165
continue;
@@ -2213,10 +2217,17 @@ bool BLIF_file::createPinGraph() noexcept {
22132217
eid = pg_.linK(port.id_, key);
22142218
assert(eid);
22152219

2220+
if (trace_ >= 8)
2221+
pg_.printEdge(eid);
2222+
22162223
Q.emplace_back(kid, par_realId, pinIndex, par.out_.c_str());
22172224
}
22182225
}
22192226

2227+
// if (0) {
2228+
// writePinGraph("111_G_afterLinkTopInp.dot", true, false);
2229+
// }
2230+
22202231
// -- link cell-edges and next level
22212232
if (trace_ >= 5) {
22222233
lprintf("|Q| .sz= %zu\n", Q.size());
@@ -2278,8 +2289,19 @@ bool BLIF_file::createPinGraph() noexcept {
22782289
uint cn_realId = cn.realId(*this);
22792290
key = hashCantor(cn_realId, i + 1) + max_key1;
22802291
assert(key);
2281-
kid = pg_.insK(key);
2282-
assert(kid);
2292+
// if (key == 110)
2293+
// lputs3();
2294+
kid = pg_.findNode(key);
2295+
if (kid) {
2296+
if (trace_ >= 8) {
2297+
lprintf("\t\t ___ found nid %u '%s' for key %zu",
2298+
kid, pg_.cnodeName(kid), key);
2299+
}
2300+
}
2301+
else {
2302+
kid = pg_.insK(key);
2303+
assert(kid);
2304+
}
22832305
pg_.nodeRef(kid).markClk(true);
22842306

22852307
::snprintf(nm_buf, 510, "nd%u_L%u_cn",
@@ -2522,16 +2544,20 @@ bool BLIF_file::createPinGraph() noexcept {
25222544
return true;
25232545
}
25242546

2525-
string BLIF_file::writePinGraph(CStr fn0) const noexcept {
2547+
string BLIF_file::writePinGraph(CStr fn0, bool nodeTable, bool noDeg0) const noexcept {
25262548
auto& ls = lout();
25272549
if (trace_ >= 5) {
25282550
flush_out(true);
2529-
pg_.print(ls, "\t *** pin_graph for clock-data separation ***");
2551+
if (trace_ >= 6)
2552+
pg_.print(ls, "\t *** pin_graph for clock-data separation ***");
2553+
else
2554+
lputs("\t --- pin_graph for clock-data separation ---");
25302555
lprintf("\t pg_. numN()= %u numE()= %u\n", pg_.numN(), pg_.numE());
25312556
lputs();
25322557
pg_.printSum(ls, 0);
25332558
lputs();
2534-
pg_.printEdges(ls, "|edges|");
2559+
if (trace_ >= 6)
2560+
pg_.printEdges(ls, "|edges|");
25352561
flush_out(true);
25362562
}
25372563

@@ -2540,7 +2566,7 @@ string BLIF_file::writePinGraph(CStr fn0) const noexcept {
25402566

25412567
string fn = str::concat(topModel_.c_str(), "_", fn0);
25422568

2543-
bool wrDot_ok = pg_.writeDot(fn.c_str(), nullptr, true, true);
2569+
bool wrDot_ok = pg_.writeDot(fn.c_str(), nullptr, nodeTable, noDeg0);
25442570
if (!wrDot_ok) {
25452571
flush_out(true); err_puts();
25462572
lprintf2("[Error] could not write pin_graph to file '%s'\n", fn.c_str());

planning/src/file_io/pln_blif_file.h

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -215,6 +215,7 @@ struct BLIF_file : public fio::MMapReader
215215
CStr cOut() const noexcept { return out_.empty() ? "{e}" : out_.c_str(); }
216216

217217
CStr cPrimType() const noexcept;
218+
CStr cPortName() const noexcept;
218219

219220
bool isDanglingTerm(uint term) const noexcept;
220221

@@ -350,7 +351,7 @@ struct BLIF_file : public fio::MMapReader
350351
bool createPinGraph() noexcept;
351352
bool linkPinGraph() noexcept;
352353

353-
string writePinGraph(CStr fn0) const noexcept;
354+
string writePinGraph(CStr fn0, bool nodeTable=true, bool noDeg0=true) const noexcept;
354355

355356
bool checkClockSepar(vector<BNode*>& clocked) noexcept;
356357

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

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

planning/src/util/geo/iv.h

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -44,10 +44,6 @@ inline uint64_t hashComb(uint64_t a, const std::string& s) noexcept {
4444
return hashComb(a, str::hashf(s));
4545
}
4646

47-
inline constexpr uint64_t hashCantor(uint64_t a, uint64_t b) noexcept {
48-
return ((a + b) >> 1) * (a + b + 1) + b;
49-
}
50-
5147
inline constexpr int protAdd(int a, int b) noexcept {
5248
int64_t c = int64_t(a) + int64_t(b);
5349
if (c > INT_MAX) return INT_MAX;
@@ -96,6 +92,11 @@ inline constexpr int64_t protRound64(double x) noexcept {
9692
return int64_t(x - 0.5);
9793
}
9894

95+
inline constexpr uint64_t hashCantor(uint64_t a, uint64_t b) noexcept {
96+
double apb = double(a + b);
97+
return protRound64(0.5 * apb * (apb + 1) + b);
98+
}
99+
99100
struct Iv {
100101
int a_ = INT_MIN, b_ = INT_MIN;
101102

@@ -119,7 +120,7 @@ struct Iv {
119120
bool valid() const noexcept { return b_ != INT_MIN; }
120121
bool normal() const noexcept { return a_ <= b_; }
121122
static bool normal(int a, int b) noexcept { return a <= b; }
122-
void invalidate() noexcept { b_ = INT_MIN; }
123+
void inval() noexcept { b_ = INT_MIN; }
123124
void normalize() noexcept {
124125
if (a_ > b_) std::swap(a_, b_);
125126
}

planning/src/util/nw/Nw.cpp

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -51,6 +51,8 @@ uint NW::insK(uint64_t k) noexcept {
5151
newNid = nid_at(I - nids_.begin());
5252
ndStor_.pop_back();
5353
nids_.pop_back();
54+
// if (newNid == 36)
55+
// lputs4();
5456
} else {
5557
newNid = p->id_;
5658
nids_.pop_back();
@@ -60,8 +62,8 @@ uint NW::insK(uint64_t k) noexcept {
6062
}
6163

6264
assert(nodeRef(newNid).key_ == k);
63-
//if (newNid == 27)
64-
// lputs1();
65+
//if (newNid == 36)
66+
// lputs4();
6567
return newNid;
6668
}
6769

planning/src/util/nw/Nw.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -483,6 +483,8 @@ struct NW {
483483
uint printEdges(ostream& os, CStr msg = nullptr) const noexcept;
484484
uint dumpEdges(CStr msg = nullptr) const noexcept;
485485

486+
bool printEdge(uint eid) const noexcept;
487+
486488
uint printSum(ostream& os, uint16_t forDot) const noexcept;
487489

488490
uint printMetis(ostream& os, bool nodeTable) const noexcept;

planning/src/util/nw/Nw_io.cpp

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -477,6 +477,22 @@ uint NW::printEdges(ostream& os, CStr msg) const noexcept {
477477
}
478478
uint NW::dumpEdges(CStr msg) const noexcept { return printEdges(lout(), msg); }
479479

480+
bool NW::printEdge(uint eid) const noexcept {
481+
lprintf(" (graph edge) eid= %u", eid);
482+
if (not hasEdge(eid)) {
483+
lputs(" <not_present>");
484+
return false;
485+
}
486+
const Edge& e = edgeRef(eid);
487+
uint n1 = e.n1_;
488+
uint n2 = e.n2_;
489+
490+
lprintf(" fr %u '%s' to %u '%s'\n",
491+
n1, cnodeName(n1), n2, cnodeName(n2));
492+
493+
return true;
494+
}
495+
480496
uint NW::printSum(ostream& os, uint16_t forDot) const noexcept {
481497
dot_comment(os, forDot);
482498
if (empty()) {

0 commit comments

Comments
 (0)