diff --git a/planning/src/file_io/pln_blif_file.cpp b/planning/src/file_io/pln_blif_file.cpp index fb1d45fd..7e129b2d 100644 --- a/planning/src/file_io/pln_blif_file.cpp +++ b/planning/src/file_io/pln_blif_file.cpp @@ -196,6 +196,12 @@ CStr BLIF_file::BNode::cPrimType() const noexcept { return ptype_ == prim::A_ZERO ? "{e}" : pr_enum2str(ptype_); } +CStr BLIF_file::BNode::cPortName() const noexcept { + if (isTopPort() and not data_.empty()) + return data_.front().c_str(); + return "{np}"; +} + bool BLIF_file::BNode::isDanglingTerm(uint term) const noexcept { if (dangTerms_.empty()) return false; @@ -1336,13 +1342,6 @@ bool BLIF_file::createNodes() noexcept { continue; assert(!nd.is_mog_); - //if (nd.lnum_ == 48) { - // string delWire1151 = "$delete_wire$1151"; - // lputs8(); - // int dTerm = findTermByNet(nd.data_, delWire1151); - // lprintf(" dTerm= %i\n", dTerm); - //} - s_is_MOG(nd, V); bool is_mog = V.size() > 1; if (is_mog) { @@ -2152,10 +2151,15 @@ bool BLIF_file::createPinGraph() noexcept { if (trace_ >= 5) { lputs(); - lprintf(" TopInput: lnum_= %u %s PAR.size()= %zu\n", - port.lnum_, port.out_.c_str(), PAR.size()); + lprintf(" TopInput: id_= %u lnum_= %u %s PAR.size()= %zu\n", + port.id_, port.lnum_, port.out_.c_str(), PAR.size()); + if (trace_ >= 6) + lprintf(" %s\n", port.cPortName()); } + // if (port.id_ == 24) + // lputs1(); + for (const upair& pa : PAR) { if (pa.first == port.id_) continue; @@ -2213,10 +2217,17 @@ bool BLIF_file::createPinGraph() noexcept { eid = pg_.linK(port.id_, key); assert(eid); + if (trace_ >= 8) + pg_.printEdge(eid); + Q.emplace_back(kid, par_realId, pinIndex, par.out_.c_str()); } } + // if (0) { + // writePinGraph("111_G_afterLinkTopInp.dot", true, false); + // } + // -- link cell-edges and next level if (trace_ >= 5) { lprintf("|Q| .sz= %zu\n", Q.size()); @@ -2278,8 +2289,19 @@ bool BLIF_file::createPinGraph() noexcept { uint cn_realId = cn.realId(*this); key = hashCantor(cn_realId, i + 1) + max_key1; assert(key); - kid = pg_.insK(key); - assert(kid); + // if (key == 110) + // lputs3(); + kid = pg_.findNode(key); + if (kid) { + if (trace_ >= 8) { + lprintf("\t\t ___ found nid %u '%s' for key %zu", + kid, pg_.cnodeName(kid), key); + } + } + else { + kid = pg_.insK(key); + assert(kid); + } pg_.nodeRef(kid).markClk(true); ::snprintf(nm_buf, 510, "nd%u_L%u_cn", @@ -2522,16 +2544,20 @@ bool BLIF_file::createPinGraph() noexcept { return true; } -string BLIF_file::writePinGraph(CStr fn0) const noexcept { +string BLIF_file::writePinGraph(CStr fn0, bool nodeTable, bool noDeg0) const noexcept { auto& ls = lout(); if (trace_ >= 5) { flush_out(true); - pg_.print(ls, "\t *** pin_graph for clock-data separation ***"); + if (trace_ >= 6) + pg_.print(ls, "\t *** pin_graph for clock-data separation ***"); + else + lputs("\t --- pin_graph for clock-data separation ---"); lprintf("\t pg_. numN()= %u numE()= %u\n", pg_.numN(), pg_.numE()); lputs(); pg_.printSum(ls, 0); lputs(); - pg_.printEdges(ls, "|edges|"); + if (trace_ >= 6) + pg_.printEdges(ls, "|edges|"); flush_out(true); } @@ -2540,7 +2566,7 @@ string BLIF_file::writePinGraph(CStr fn0) const noexcept { string fn = str::concat(topModel_.c_str(), "_", fn0); - bool wrDot_ok = pg_.writeDot(fn.c_str(), nullptr, true, true); + bool wrDot_ok = pg_.writeDot(fn.c_str(), nullptr, nodeTable, noDeg0); if (!wrDot_ok) { flush_out(true); err_puts(); lprintf2("[Error] could not write pin_graph to file '%s'\n", fn.c_str()); diff --git a/planning/src/file_io/pln_blif_file.h b/planning/src/file_io/pln_blif_file.h index 3939a415..026aa36b 100644 --- a/planning/src/file_io/pln_blif_file.h +++ b/planning/src/file_io/pln_blif_file.h @@ -215,6 +215,7 @@ struct BLIF_file : public fio::MMapReader CStr cOut() const noexcept { return out_.empty() ? "{e}" : out_.c_str(); } CStr cPrimType() const noexcept; + CStr cPortName() const noexcept; bool isDanglingTerm(uint term) const noexcept; @@ -350,7 +351,7 @@ struct BLIF_file : public fio::MMapReader bool createPinGraph() noexcept; bool linkPinGraph() noexcept; - string writePinGraph(CStr fn0) const noexcept; + string writePinGraph(CStr fn0, bool nodeTable=true, bool noDeg0=true) const noexcept; bool checkClockSepar(vector& clocked) noexcept; diff --git a/planning/src/main.cpp b/planning/src/main.cpp index a63f4214..bd54d259 100644 --- a/planning/src/main.cpp +++ b/planning/src/main.cpp @@ -1,4 +1,4 @@ -static const char* _pln_VERSION_STR = "pln0360"; +static const char* _pln_VERSION_STR = "pln0361"; #include "RS/rsEnv.h" #include "util/pln_log.h" diff --git a/planning/src/util/geo/iv.h b/planning/src/util/geo/iv.h index b678f3bd..b560bc49 100644 --- a/planning/src/util/geo/iv.h +++ b/planning/src/util/geo/iv.h @@ -44,10 +44,6 @@ inline uint64_t hashComb(uint64_t a, const std::string& s) noexcept { return hashComb(a, str::hashf(s)); } -inline constexpr uint64_t hashCantor(uint64_t a, uint64_t b) noexcept { - return ((a + b) >> 1) * (a + b + 1) + b; -} - inline constexpr int protAdd(int a, int b) noexcept { int64_t c = int64_t(a) + int64_t(b); if (c > INT_MAX) return INT_MAX; @@ -96,6 +92,11 @@ inline constexpr int64_t protRound64(double x) noexcept { return int64_t(x - 0.5); } +inline constexpr uint64_t hashCantor(uint64_t a, uint64_t b) noexcept { + double apb = double(a + b); + return protRound64(0.5 * apb * (apb + 1) + b); +} + struct Iv { int a_ = INT_MIN, b_ = INT_MIN; @@ -119,7 +120,7 @@ struct Iv { bool valid() const noexcept { return b_ != INT_MIN; } bool normal() const noexcept { return a_ <= b_; } static bool normal(int a, int b) noexcept { return a <= b; } - void invalidate() noexcept { b_ = INT_MIN; } + void inval() noexcept { b_ = INT_MIN; } void normalize() noexcept { if (a_ > b_) std::swap(a_, b_); } diff --git a/planning/src/util/nw/Nw.cpp b/planning/src/util/nw/Nw.cpp index aca96598..9f69bd25 100644 --- a/planning/src/util/nw/Nw.cpp +++ b/planning/src/util/nw/Nw.cpp @@ -51,6 +51,8 @@ uint NW::insK(uint64_t k) noexcept { newNid = nid_at(I - nids_.begin()); ndStor_.pop_back(); nids_.pop_back(); + // if (newNid == 36) + // lputs4(); } else { newNid = p->id_; nids_.pop_back(); @@ -60,8 +62,8 @@ uint NW::insK(uint64_t k) noexcept { } assert(nodeRef(newNid).key_ == k); - //if (newNid == 27) - // lputs1(); + //if (newNid == 36) + // lputs4(); return newNid; } diff --git a/planning/src/util/nw/Nw.h b/planning/src/util/nw/Nw.h index 1e685733..e6fec488 100644 --- a/planning/src/util/nw/Nw.h +++ b/planning/src/util/nw/Nw.h @@ -483,6 +483,8 @@ struct NW { uint printEdges(ostream& os, CStr msg = nullptr) const noexcept; uint dumpEdges(CStr msg = nullptr) const noexcept; + bool printEdge(uint eid) const noexcept; + uint printSum(ostream& os, uint16_t forDot) const noexcept; uint printMetis(ostream& os, bool nodeTable) const noexcept; diff --git a/planning/src/util/nw/Nw_io.cpp b/planning/src/util/nw/Nw_io.cpp index 72534d8c..5a1a9877 100644 --- a/planning/src/util/nw/Nw_io.cpp +++ b/planning/src/util/nw/Nw_io.cpp @@ -477,6 +477,22 @@ uint NW::printEdges(ostream& os, CStr msg) const noexcept { } uint NW::dumpEdges(CStr msg) const noexcept { return printEdges(lout(), msg); } +bool NW::printEdge(uint eid) const noexcept { + lprintf(" (graph edge) eid= %u", eid); + if (not hasEdge(eid)) { + lputs(" "); + return false; + } + const Edge& e = edgeRef(eid); + uint n1 = e.n1_; + uint n2 = e.n2_; + + lprintf(" fr %u '%s' to %u '%s'\n", + n1, cnodeName(n1), n2, cnodeName(n2)); + + return true; +} + uint NW::printSum(ostream& os, uint16_t forDot) const noexcept { dot_comment(os, forDot); if (empty()) {