Skip to content

Commit 005a248

Browse files
committed
checker: error message for clock-data
1 parent c62f405 commit 005a248

File tree

3 files changed

+59
-10
lines changed

3 files changed

+59
-10
lines changed

planning/src/file_readers/pln_blif_file.cpp

Lines changed: 40 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -21,9 +21,10 @@ void BLIF_file::reset(CStr nm, uint16_t tr) noexcept {
2121
constantNodes_.clear();
2222
rd_ok_ = chk_ok_ = false;
2323
inputs_lnum_ = outputs_lnum_ = 0;
24-
err_lnum_ = 0;
24+
err_lnum_ = err_lnum2_ = 0;
2525
err_msg_.clear();
2626
pg_.clear();
27+
pg2blif_.clear();
2728
}
2829

2930
// "model "
@@ -251,7 +252,7 @@ bool BLIF_file::readBlif() noexcept {
251252
V.reserve(16);
252253

253254
inputs_lnum_ = outputs_lnum_ = 0;
254-
err_lnum_ = 0;
255+
err_lnum_ = err_lnum2_ = 0;
255256
for (size_t i = 1; i < lsz; i++) {
256257
CStr cs = lines_[i];
257258
if (!cs || !cs[0]) continue;
@@ -432,8 +433,10 @@ bool BLIF_file::checkBlif() noexcept {
432433
bool separ_ok = checkClockSepar(clocked);
433434
if (not separ_ok) {
434435
string tmp = err_msg_;
435-
err_msg_ = "clock-data separation issue at line ";
436+
err_msg_ = "clock-data separation issue at lines: ";
436437
err_msg_ += std::to_string(err_lnum_);
438+
err_msg_ += ", ";
439+
err_msg_ += std::to_string(err_lnum2_);
437440
err_msg_ += " ";
438441
err_msg_ += tmp;
439442
flush_out(true);
@@ -1478,9 +1481,11 @@ bool BLIF_file::checkClockSepar(vector<const Node*>& clocked) noexcept {
14781481
}
14791482
}
14801483

1481-
writePinGraph("pin_graph_2.dot");
1484+
if (trace_ >= 4)
1485+
writePinGraph("pin_graph_2.dot");
14821486

14831487
bool color_ok = true;
1488+
CStr viol_prefix = " ===>>> clock color violation";
14841489

14851490
// -- check that end-points of red edges are red
14861491
for (NW::cEI E(pg_); E.valid(); ++E) {
@@ -1491,6 +1496,28 @@ bool BLIF_file::checkClockSepar(vector<const Node*>& clocked) noexcept {
14911496
const NW::Node& p2 = pg_.nodeRef(ed.n2_);
14921497
if (!p1.isRed() or !p2.isRed()) {
14931498
color_ok = false;
1499+
if (pg2blif_.count(p1.id_) and pg2blif_.count(p2.id_)) {
1500+
uint b1 = map_pg2blif(p1.id_);
1501+
uint b2 = map_pg2blif(p2.id_);
1502+
string nm1 = p1.getName();
1503+
string nm2 = p2.getName();
1504+
const Node& bnode1 = bnodeRef(b1);
1505+
const Node& bnode2 = bnodeRef(b2);
1506+
err_lnum_ = bnode1.lnum_;
1507+
err_lnum2_ = bnode2.lnum_;
1508+
flush_out(true);
1509+
lprintf("%s: pin-graph nodes: #%u:%s - #%u:%s\n",
1510+
viol_prefix, p1.id_, nm1.c_str(), p2.id_, nm2.c_str());
1511+
flush_out(true);
1512+
lprintf("%s: blif lines: %u - %u\n",
1513+
viol_prefix, err_lnum_, err_lnum2_);
1514+
char B[512] = {};
1515+
::sprintf(B, " line %u : %s ", err_lnum_, bnode1.kw_.c_str());
1516+
logVec(bnode1.data_, B);
1517+
::sprintf(B, " line %u : %s ", err_lnum2_, bnode2.kw_.c_str());
1518+
logVec(bnode2.data_, B);
1519+
flush_out(true);
1520+
}
14941521
break;
14951522
}
14961523
}
@@ -1519,6 +1546,7 @@ struct qTup {
15191546

15201547
bool BLIF_file::createPinGraph() noexcept {
15211548
pg_.clear();
1549+
pg2blif_.clear();
15221550
if (!rd_ok_) return false;
15231551
if (topInputs_.empty() and topOutputs_.empty()) return false;
15241552
if (fabricNodes_.empty()) return false;
@@ -1530,6 +1558,8 @@ bool BLIF_file::createPinGraph() noexcept {
15301558
vector<upair> PAR;
15311559
char nm_buf[512] = {};
15321560

1561+
pg2blif_.reserve(2 * nodePool_.size() + 1);
1562+
15331563
// -- create pg-nodes for topInputs_
15341564
for (Node* p : topInputs_) {
15351565
Node& port = *p;
@@ -1539,6 +1569,7 @@ bool BLIF_file::createPinGraph() noexcept {
15391569
pg_.setNodeName(nid, port.out_);
15401570
pg_.nodeRef(nid).markInp(true);
15411571
port.nw_id_ = nid;
1572+
pg2blif_.emplace(nid, port.id_);
15421573
}
15431574

15441575
// -- create pg-nodes for topOutputs_
@@ -1550,6 +1581,7 @@ bool BLIF_file::createPinGraph() noexcept {
15501581
pg_.setNodeName(nid, port.out_);
15511582
pg_.nodeRef(nid).markOut(true);
15521583
port.nw_id_ = nid;
1584+
pg2blif_.emplace(nid, port.id_);
15531585
}
15541586

15551587
vector<qTup> Q;
@@ -1573,7 +1605,7 @@ bool BLIF_file::createPinGraph() noexcept {
15731605
for (const upair& pa : PAR) {
15741606
if (pa.first == port.id_)
15751607
continue;
1576-
const Node& par = nodeRef(pa.first);
1608+
const Node& par = bnodeRef(pa.first);
15771609
uint pinIndex = pa.second;
15781610

15791611
INP.clear();
@@ -1601,6 +1633,7 @@ bool BLIF_file::createPinGraph() noexcept {
16011633
assert(kid);
16021634
assert(key != port.id_); // bc port.id_ is a key for port
16031635
assert(pg_.hasKey(port.id_)); //
1636+
pg2blif_.emplace(kid, par.id_);
16041637

16051638
pg_.nodeRef(kid).setCid(par.id_);
16061639
::snprintf(nm_buf, 510, "%s_%uL_%up%u",
@@ -1634,8 +1667,9 @@ bool BLIF_file::createPinGraph() noexcept {
16341667
eid = pg_.linkNodes(q.inpNid_, kid, true);
16351668

16361669
::snprintf(nm_buf, 510, "nd%u_L%u_Q%u",
1637-
kid, nodeRef(q.cellId_).lnum_, q.cellId_);
1670+
kid, bnodeRef(q.cellId_).lnum_, q.cellId_);
16381671
pg_.setNodeName(kid, nm_buf);
1672+
pg2blif_.emplace(kid, q.cellId_);
16391673
}
16401674
}
16411675

planning/src/file_readers/pln_blif_file.h

Lines changed: 18 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,8 @@
77
#include "util/geo/xyz.h"
88
#include "util/nw/Nw.h"
99

10+
#include <unordered_map>
11+
1012
namespace pln {
1113

1214
using std::string;
@@ -180,11 +182,11 @@ struct BLIF_file : public fio::MMapReader
180182

181183
}; // Node
182184

183-
Node& nodeRef(uint id) noexcept {
185+
Node& bnodeRef(uint id) noexcept {
184186
assert(id > 0 and id < nodePool_.size());
185187
return nodePool_[id];
186188
}
187-
const Node& nodeRef(uint id) const noexcept {
189+
const Node& bnodeRef(uint id) const noexcept {
188190
assert(id > 0 and id < nodePool_.size());
189191
return nodePool_[id];
190192
}
@@ -195,7 +197,7 @@ struct BLIF_file : public fio::MMapReader
195197
vector<string> outputs_;
196198

197199
size_t inputs_lnum_ = 0, outputs_lnum_ = 0;
198-
mutable uint err_lnum_ = 0;
200+
mutable uint err_lnum_ = 0, err_lnum2_ = 0;
199201

200202
string err_msg_;
201203
uint16_t trace_ = 0;
@@ -252,13 +254,26 @@ struct BLIF_file : public fio::MMapReader
252254
// pair: 1st - nodeId, 2nd - pinIndex
253255
void getFabricParents(uint of, const string& contact, vector<upair>& PAR) noexcept;
254256

257+
uint map_pg2blif(uint pg_nid) const noexcept {
258+
assert(pg_nid);
259+
assert(not pg2blif_.empty());
260+
const auto F = pg2blif_.find(pg_nid);
261+
assert(F != pg2blif_.end());
262+
if (F == pg2blif_.end())
263+
return 0;
264+
return F->second;
265+
}
266+
267+
// DATA:
255268
std::vector<Node> nodePool_; // nodePool_[0] is a fake node "parent of root"
256269

257270
std::vector<Node*> topInputs_, topOutputs_;
258271
std::vector<Node*> fabricNodes_, constantNodes_;
259272

260273
std::vector<Node*> latches_; // latches are not checked for now
261274

275+
std::unordered_map<uint, uint> pg2blif_; // map IDs from NW to BLIF_file::Node::id_
276+
262277
NW pg_; // Pin Graph
263278
};
264279

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

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

0 commit comments

Comments
 (0)