Skip to content

Commit 51e3c1e

Browse files
authored
Merge pull request #828 from os-fpga/checker_improved_violation_report
checker: improved violation report
2 parents e31f21d + e85b0a6 commit 51e3c1e

File tree

6 files changed

+116
-26
lines changed

6 files changed

+116
-26
lines changed

planning/src/RS/rsCheck.cpp

Lines changed: 18 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -42,8 +42,11 @@ bool do_check_blif(CStr cfn) {
4242
return false;
4343
}
4444

45+
uint numInp = bfile.numInputs();
46+
uint numOut = bfile.numOutputs();
47+
4548
lprintf(" (blif_file) #inputs= %u #outputs= %u topModel= %s\n",
46-
bfile.numInputs(), bfile.numOutputs(), bfile.topModel_.c_str());
49+
numInp, numOut, bfile.topModel_.c_str());
4750

4851
if (tr >= 4) {
4952
flush_out(true);
@@ -58,14 +61,20 @@ bool do_check_blif(CStr cfn) {
5861
bool chk_ok = bfile.checkBlif();
5962
assert(chk_ok == bfile.chk_ok_);
6063

61-
lprintf("===== passed: %s\n", chk_ok ? "YES" : "NO");
62-
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) {
64+
lprintf("===== passed: %s\n", chk_ok ? "YES" : "NO");
65+
66+
ls << "----- topModel: " << bfile.topModel_ << endl;
67+
ls << "----- file: " << bfile.fnm_ << endl;
68+
ls << "----- #inputs= " << numInp << endl;
69+
ls << "----- #outputs= " << numOut << endl;
70+
ls << "----- #LUTs= " << bfile.countLUTs() << endl;
71+
ls << "----- #FFs= " << bfile.countFFs() << endl;
72+
ls << "----- #CLK_BUFs= " << bfile.countCBUFs() << endl;
73+
ls << "----- PinGraph: " << bfile.pinGraphFile_ << endl;
74+
if (bfile.num_MOGs_ and tr >= 5) {
6775
ls << ">>>>> [NOTE] num_MOGs_ = " << bfile.num_MOGs_ << endl;
6876
}
77+
lprintf("===== passed: %s\n", chk_ok ? "YES" : "NO");
6978

7079
flush_out(true);
7180
if (chk_ok) {
@@ -81,8 +90,9 @@ bool do_check_blif(CStr cfn) {
8190
ls << "[Error] !!! " << bfile.err_msg_ << endl;
8291

8392
flush_out(true);
93+
uint errLnum = std::max(bfile.err_lnum_, bfile.err_lnum2_);
8494
lprintf2("ERROR: BLIF verification failed at %s:%u\n",
85-
bfile.fnm_.c_str(), bfile.err_lnum_);
95+
bfile.fnm_.c_str(), errLnum);
8696

8797
return false;
8898
}

planning/src/file_io/pln_blif_file.cpp

Lines changed: 68 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -664,6 +664,51 @@ std::array<uint, Prim_MAX_ID> BLIF_file::countTypes() const noexcept {
664664
return A;
665665
}
666666

667+
uint BLIF_file::countLUTs() const noexcept {
668+
uint nn = numNodes();
669+
if (nn == 0)
670+
return 0;
671+
672+
uint cnt = 0;
673+
for (uint i = 1; i <= nn; i++) {
674+
const BNode& nd = nodePool_[i];
675+
if (nd.is_LUT())
676+
cnt++;
677+
}
678+
679+
return cnt;
680+
}
681+
682+
uint BLIF_file::countFFs() const noexcept {
683+
uint nn = numNodes();
684+
if (nn == 0)
685+
return 0;
686+
687+
uint cnt = 0;
688+
for (uint i = 1; i <= nn; i++) {
689+
const BNode& nd = nodePool_[i];
690+
if (nd.is_FF())
691+
cnt++;
692+
}
693+
694+
return cnt;
695+
}
696+
697+
uint BLIF_file::countCBUFs() const noexcept {
698+
uint nn = numNodes();
699+
if (nn == 0)
700+
return 0;
701+
702+
uint cnt = 0;
703+
for (uint i = 1; i <= nn; i++) {
704+
const BNode& nd = nodePool_[i];
705+
if (nd.is_CLK_BUF())
706+
cnt++;
707+
}
708+
709+
return cnt;
710+
}
711+
667712
uint BLIF_file::countCarryNodes() const noexcept {
668713
uint nn = numNodes();
669714
if (nn == 0)
@@ -1574,22 +1619,20 @@ bool BLIF_file::checkClockSepar(vector<const BNode*>& clocked) noexcept {
15741619
lputs();
15751620
}
15761621

1577-
if (trace_ >= 3) {
1578-
pinGraphFile_ = writePinGraph("_PinGraph.dot");
1579-
}
1580-
15811622
bool color_ok = true;
1582-
CStr viol_prefix = " ===>>> clock color violation";
1623+
CStr viol_prefix = " ===!!! clock-data separation error";
15831624

15841625
// -- check that end-points of red edges are red
15851626
for (NW::cEI E(pg_); E.valid(); ++E) {
15861627
const NW::Edge& ed = *E;
15871628
if (not ed.isRed())
15881629
continue;
1589-
const NW::Node& p1 = pg_.nodeRef(ed.n1_);
1590-
const NW::Node& p2 = pg_.nodeRef(ed.n2_);
1630+
NW::Node& p1 = pg_.nodeRef(ed.n1_);
1631+
NW::Node& p2 = pg_.nodeRef(ed.n2_);
15911632
if (!p1.isRed() or !p2.isRed()) {
15921633
color_ok = false;
1634+
p1.markViol(true);
1635+
p2.markViol(true);
15931636
if (pg2blif_.count(p1.id_) and pg2blif_.count(p2.id_)) {
15941637
uint b1 = map_pg2blif(p1.id_);
15951638
uint b2 = map_pg2blif(p2.id_);
@@ -1616,6 +1659,22 @@ bool BLIF_file::checkClockSepar(vector<const BNode*>& clocked) noexcept {
16161659
}
16171660
}
16181661

1662+
if (color_ok)
1663+
pg_.setNwName("pin_graph_OK");
1664+
else
1665+
pg_.setNwName("pin_graph_VIOL");
1666+
1667+
if (trace_ >= 3) {
1668+
pinGraphFile_ = writePinGraph("_PinGraph.dot");
1669+
}
1670+
1671+
if (!color_ok) {
1672+
flush_out(true); err_puts();
1673+
lprintf2("[Error] clock-data separation error\n");
1674+
err_puts(); flush_out(true);
1675+
return false;
1676+
}
1677+
16191678
return color_ok;
16201679
}
16211680

@@ -1936,15 +1995,15 @@ bool BLIF_file::createPinGraph() noexcept {
19361995
BNode* drv_drv = findDriverNode(dn.id_, inp1);
19371996

19381997
if (!drv_drv) {
1939-
lputs8();
1998+
lputs();
19401999
flush_out(true); err_puts();
19412000
lprintf2("[Error] no driver for clock-buf node #%u %s line:%u\n",
19422001
dn.id_, dn.cPrimType(), dn.lnum_);
19432002
err_puts(); flush_out(true);
19442003
return false;
19452004
}
19462005

1947-
if (trace_ >= 4) {
2006+
if (trace_ >= 5) {
19482007
lputs();
19492008
lprintf(" CLOCK_TRACE drv_drv-> id_%u %s out_net %s line:%u\n",
19502009
drv_drv->id_, drv_drv->cPrimType(),

planning/src/file_io/pln_blif_file.h

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -153,6 +153,12 @@ struct BLIF_file : public fio::MMapReader
153153
bool is_CLK_BUF() const noexcept {
154154
return ptype_ == prim::CLK_BUF;
155155
}
156+
bool is_LUT() const noexcept {
157+
return prim::pr_is_LUT(ptype_);
158+
}
159+
bool is_FF() const noexcept {
160+
return prim::pr_is_DFF(ptype_);
161+
}
156162

157163
string firstInputNet() const noexcept;
158164

@@ -243,6 +249,9 @@ struct BLIF_file : public fio::MMapReader
243249
uint numInputs() const noexcept { return inputs_.size(); }
244250
uint numOutputs() const noexcept { return outputs_.size(); }
245251
uint numNodes() const noexcept { return nodePool_.empty() ? 0 : nodePool_.size() - 1; }
252+
uint countLUTs() const noexcept;
253+
uint countFFs() const noexcept;
254+
uint countCBUFs() const noexcept;
246255

247256
void collectClockedNodes(vector<const BNode*>& V) noexcept;
248257
std::array<uint, prim::Prim_MAX_ID> countTypes() const noexcept;

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

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

planning/src/util/nw/Nw.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -157,6 +157,7 @@ struct NW {
157157
void markInp(bool val) noexcept { inp_flag_ = val; }
158158
void markOut(bool val) noexcept { out_flag_ = val; }
159159
void markClk(bool val) noexcept { clk_flag_ = val; }
160+
void markViol(bool val) noexcept { viol_flag_ = val; }
160161
bool isClk() const noexcept { return clk_flag_; }
161162
bool terminal() const noexcept { return sink_flag_ or root_flag_; }
162163

@@ -189,6 +190,7 @@ struct NW {
189190
bool inp_flag_ = false;
190191
bool out_flag_ = false;
191192
bool clk_flag_ = false;
193+
bool viol_flag_ = false;
192194
string name_;
193195
};
194196

planning/src/util/nw/Nw_io.cpp

Lines changed: 18 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -335,18 +335,22 @@ void NW::Node::nprint_dot(ostream& os) const noexcept {
335335
char attrib[512] = {};
336336

337337
if (!inp_flag_ and !clk_flag_) {
338-
if (isRed())
338+
if (isRed()) {
339339
::strcpy(attrib, "[ shape=octagon, color=purple, fillcolor=pink, style=filled ];");
340-
else
340+
}
341+
else {
341342
::strcpy(attrib, "[ shape=record, style=rounded ];");
343+
if (viol_flag_)
344+
::strcpy(attrib, "[ shape=doubleoctagon, color=blueviolet, fillcolor=violet, style=filled ];");
345+
}
342346
}
343347
else {
344348
if (inp_flag_) {
345349
CStr cs = isRed() ? "red" : "gray";
346350
::sprintf(attrib, "[ shape=box, color=%s, style=filled ];", cs);
347351
}
348352
else if (clk_flag_) {
349-
CStr cs = isRed() ? "violet" : "orange";
353+
CStr cs = isRed() ? "maroon" : "orange";
350354
::sprintf(attrib, "[ shape=ellipse, color=%s, style=filled ];", cs);
351355
}
352356
}
@@ -358,12 +362,14 @@ void NW::Node::nprint_dot(ostream& os) const noexcept {
358362
void NW::Edge::eprint_dot(ostream& os, char arrow, const NW& g) const noexcept {
359363
assert(arrow == '>' or arrow == '-');
360364
char buf[2048] = {};
361-
g.nodeRef(n1_).getName(buf);
365+
const Node& nd1 = g.nodeRef(n1_);
366+
nd1.getName(buf);
362367
be_dot_friendly(buf);
363368
os_printf(os, "%s -%c ", buf, arrow);
364369

365370
buf[0] = 0;
366-
g.nodeRef(n2_).getName(buf);
371+
const Node& nd2 = g.nodeRef(n2_);
372+
nd2.getName(buf);
367373
be_dot_friendly(buf);
368374
os << buf;
369375

@@ -372,8 +378,12 @@ void NW::Edge::eprint_dot(ostream& os, char arrow, const NW& g) const noexcept {
372378
inCell_ ? "style=dashed" : "",
373379
color_ ? "color=" : ""
374380
);
375-
if (color_)
376-
::strcat(attrib, i2color(color_));
381+
if (color_) {
382+
if (nd1.viol_flag_ and nd2.viol_flag_)
383+
::strcat(attrib, "cyan3");
384+
else
385+
::strcat(attrib, i2color(color_));
386+
}
377387
::strcat(attrib, " ]");
378388

379389
os_printf(os, "%s;\n", attrib);
@@ -593,7 +603,7 @@ static const char* _colorNames[] = {
593603

594604
CStr NW::i2color(uint i) noexcept {
595605
if (i == c_Red)
596-
return "darkviolet";
606+
return "darkorange3";
597607
return _colorNames[ i % (c_MAX_COLOR + 1) ];
598608
}
599609

0 commit comments

Comments
 (0)