Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
56 changes: 41 additions & 15 deletions planning/src/file_io/pln_blif_file.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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) {
Expand Down Expand Up @@ -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;
Expand Down Expand Up @@ -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());
Expand Down Expand Up @@ -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",
Expand Down Expand Up @@ -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);
}

Expand All @@ -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());
Expand Down
3 changes: 2 additions & 1 deletion planning/src/file_io/pln_blif_file.h
Original file line number Diff line number Diff line change
Expand Up @@ -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;

Expand Down Expand Up @@ -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<BNode*>& clocked) noexcept;

Expand Down
2 changes: 1 addition & 1 deletion planning/src/main.cpp
Original file line number Diff line number Diff line change
@@ -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"
Expand Down
11 changes: 6 additions & 5 deletions planning/src/util/geo/iv.h
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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;

Expand All @@ -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_);
}
Expand Down
6 changes: 4 additions & 2 deletions planning/src/util/nw/Nw.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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();
Expand All @@ -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;
}

Expand Down
2 changes: 2 additions & 0 deletions planning/src/util/nw/Nw.h
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
16 changes: 16 additions & 0 deletions planning/src/util/nw/Nw_io.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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(" <not_present>");
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()) {
Expand Down
Loading