Skip to content

Commit 8624ef6

Browse files
authored
Merge pull request #816 from os-fpga/checker_clock_data_improvement
pln: improve clock-data checker
2 parents 3bcbd12 + cd88eff commit 8624ef6

File tree

3 files changed

+102
-8
lines changed

3 files changed

+102
-8
lines changed

planning/src/file_io/pln_blif_file.cpp

Lines changed: 96 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1291,6 +1291,27 @@ BLIF_file::Node* BLIF_file::findFabricDriver(uint of, const string& contact) noe
12911291
return nullptr;
12921292
}
12931293

1294+
// finds TopInput or FabricDriver
1295+
BLIF_file::Node* BLIF_file::findDriverNode(uint of, const string& contact) noexcept {
1296+
assert(not contact.empty());
1297+
if (fabricNodes_.empty()) return nullptr;
1298+
1299+
// TMP linear
1300+
size_t sz = topInputs_.size();
1301+
if (sz) {
1302+
Node** A = topInputs_.data();
1303+
for (size_t i = 0; i < sz; i++) {
1304+
Node* np = A[i];
1305+
assert(np);
1306+
if (np->out_ == contact) {
1307+
return np;
1308+
}
1309+
}
1310+
}
1311+
1312+
return findFabricDriver(of, contact);
1313+
}
1314+
12941315
void BLIF_file::link2(Node& from, Node& to) noexcept {
12951316
assert(from.id_);
12961317
assert(to.id_);
@@ -1455,17 +1476,17 @@ bool BLIF_file::linkNodes() noexcept {
14551476
}
14561477

14571478
bool BLIF_file::checkClockSepar(vector<const Node*>& clocked) noexcept {
1458-
if (not ::getenv("pln_check_clock_separation"))
1479+
if (::getenv("pln_dont_check_clock_separation"))
14591480
return true;
14601481
if (clocked.empty())
14611482
return true;
14621483

14631484
bool ok = createPinGraph();
14641485
if (!ok) {
14651486
flush_out(true); err_puts();
1466-
lprintf2("[Error] NOT createPinGraph()\n");
1487+
lprintf2("[Error] could not create Pin Graph\n");
14671488
err_puts(); flush_out(true);
1468-
return true;
1489+
return false;
14691490
}
14701491
if (pg_.size() < 3)
14711492
return true;
@@ -1707,12 +1728,13 @@ bool BLIF_file::createPinGraph() noexcept {
17071728
if (trace_ >= 4)
17081729
lprintf(" createPinGraph: clocked.size()= %zu\n", clocked.size());
17091730
if (not clocked.empty()) {
1731+
string inp1;
17101732
for (const Node* cnp : clocked) {
17111733
const Node& cn = *cnp;
17121734
assert(cn.hasPrimType());
17131735
if (cn.ptype_ == prim::CLK_BUF or cn.ptype_ == prim::FCLK_BUF)
17141736
continue;
1715-
lputs9();
1737+
// lputs9();
17161738
for (uint i = 0; i < cn.inPins_.size(); i++) {
17171739
const string& inp = cn.inPins_[i];
17181740
assert(not inp.empty());
@@ -1734,9 +1756,30 @@ bool BLIF_file::createPinGraph() noexcept {
17341756

17351757
const string& inet = cn.inSigs_[i];
17361758
assert(not inet.empty());
1737-
const Node* driver = findFabricDriver(cn.id_, inet);
1738-
if (!driver)
1739-
continue;
1759+
const Node* driver = findDriverNode(cn.id_, inet);
1760+
if (!driver) {
1761+
flush_out(true); err_puts();
1762+
lprintf2("[Error] no driver for clock node #%u %s line:%u\n",
1763+
cn.id_, cn.cPrimType(), cn.lnum_);
1764+
err_puts(); flush_out(true);
1765+
return false;
1766+
}
1767+
1768+
if (trace_ >= 5) {
1769+
lputs9();
1770+
lprintf(" from cn#%u %s ",
1771+
cn.id_, cn.cPrimType() );
1772+
lprintf( " CLOCK_TRACE driver-> id_%u %s out_net %s\n",
1773+
driver->id_, driver->cPrimType(), driver->out_.c_str() );
1774+
}
1775+
1776+
if (not driver->is_CLK_BUF() and not driver->isTopInput()) {
1777+
flush_out(true); err_puts();
1778+
lprintf2("[Error] bad driver for clock node #%u must be CLK_BUF or iport\n",
1779+
cn.id_);
1780+
err_puts(); flush_out(true);
1781+
return false;
1782+
}
17401783

17411784
uint64_t qk = hashComb(driver->id_, driver->out_);
17421785
assert(qk);
@@ -1750,6 +1793,52 @@ bool BLIF_file::createPinGraph() noexcept {
17501793

17511794
eid = pg_.linK(qk, key);
17521795
assert(eid);
1796+
1797+
if (driver->is_CLK_BUF()) {
1798+
// step upward again
1799+
1800+
inp1 = driver->firstInputPin();
1801+
if (inp1.empty()) {
1802+
lprintf("\n\t\t\t return false at %s : %u\n", __FILE__, __LINE__);
1803+
return false;
1804+
}
1805+
if (inp1 == "$true" or inp1 == "$false" or inp1 == "$undef") {
1806+
lprintf("\n\t\t\t return false at %s : %u\n", __FILE__, __LINE__);
1807+
return false;
1808+
}
1809+
1810+
if (trace_ >= 5) {
1811+
lprintf( "\t\t CLOCK_TRACE_inp1 %s\n",
1812+
inp1.c_str() );
1813+
}
1814+
1815+
const Node& dn = *driver;
1816+
Node* drv_drv = findFabricDriver(dn.id_, inp1); // driver-of-driver
1817+
1818+
if (!drv_drv) {
1819+
flush_out(true); err_puts();
1820+
lprintf2("[Error] no driver for clock-buf node #%u %s line:%u\n",
1821+
dn.id_, dn.cPrimType(), dn.lnum_);
1822+
err_puts(); flush_out(true);
1823+
return false;
1824+
}
1825+
1826+
if (trace_ >= 4) {
1827+
lputs();
1828+
lprintf(" CLOCK_TRACE drv_drv-> id_%u %s out_net %s line:%u\n",
1829+
drv_drv->id_, drv_drv->cPrimType(),
1830+
drv_drv->out_.c_str(), drv_drv->lnum_);
1831+
}
1832+
1833+
if (not drv_drv->is_CLK_BUF() and not drv_drv->isTopInput()) {
1834+
flush_out(true); err_puts();
1835+
lprintf2("[Error] bad drv_drv for clock-buf node #%u line:%u must be CLK_BUF or iport\n",
1836+
dn.id_, dn.lnum_);
1837+
err_puts(); flush_out(true);
1838+
return false;
1839+
}
1840+
1841+
}
17531842
}
17541843
}
17551844
}

planning/src/file_io/pln_blif_file.h

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -132,6 +132,9 @@ struct BLIF_file : public fio::MMapReader
132132
return ptype_ == O_BUF or ptype_ == O_BUF_DS or
133133
ptype_ == O_BUFT or ptype_ == O_BUFT_DS;
134134
}
135+
bool is_CLK_BUF() const noexcept {
136+
return ptype_ == prim::CLK_BUF;
137+
}
135138

136139
string firstInputPin() const noexcept;
137140

@@ -250,6 +253,8 @@ struct BLIF_file : public fio::MMapReader
250253
Node* findFabricParent(uint of, const string& contact, int& pinIndex) noexcept; // searches inputs
251254
Node* findFabricDriver(uint of, const string& contact) noexcept; // matches out_
252255

256+
Node* findDriverNode(uint of, const string& contact) noexcept;
257+
253258
// collects matching input pins from all cells
254259
// pair: 1st - nodeId, 2nd - pinIndex
255260
void getFabricParents(uint of, const string& contact, vector<upair>& PAR) 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 = "pln0320";
1+
static const char* _pln_VERSION_STR = "pln0321";
22

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

0 commit comments

Comments
 (0)