@@ -1291,6 +1291,27 @@ BLIF_file::Node* BLIF_file::findFabricDriver(uint of, const string& contact) noe
1291
1291
return nullptr ;
1292
1292
}
1293
1293
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
+
1294
1315
void BLIF_file::link2 (Node& from, Node& to) noexcept {
1295
1316
assert (from.id_ );
1296
1317
assert (to.id_ );
@@ -1455,17 +1476,17 @@ bool BLIF_file::linkNodes() noexcept {
1455
1476
}
1456
1477
1457
1478
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 " ))
1459
1480
return true ;
1460
1481
if (clocked.empty ())
1461
1482
return true ;
1462
1483
1463
1484
bool ok = createPinGraph ();
1464
1485
if (!ok) {
1465
1486
flush_out (true ); err_puts ();
1466
- lprintf2 (" [Error] NOT createPinGraph() \n " );
1487
+ lprintf2 (" [Error] could not create Pin Graph \n " );
1467
1488
err_puts (); flush_out (true );
1468
- return true ;
1489
+ return false ;
1469
1490
}
1470
1491
if (pg_.size () < 3 )
1471
1492
return true ;
@@ -1707,12 +1728,13 @@ bool BLIF_file::createPinGraph() noexcept {
1707
1728
if (trace_ >= 4 )
1708
1729
lprintf (" createPinGraph: clocked.size()= %zu\n " , clocked.size ());
1709
1730
if (not clocked.empty ()) {
1731
+ string inp1;
1710
1732
for (const Node* cnp : clocked) {
1711
1733
const Node& cn = *cnp;
1712
1734
assert (cn.hasPrimType ());
1713
1735
if (cn.ptype_ == prim::CLK_BUF or cn.ptype_ == prim::FCLK_BUF)
1714
1736
continue ;
1715
- lputs9 ();
1737
+ // lputs9();
1716
1738
for (uint i = 0 ; i < cn.inPins_ .size (); i++) {
1717
1739
const string& inp = cn.inPins_ [i];
1718
1740
assert (not inp.empty ());
@@ -1734,9 +1756,30 @@ bool BLIF_file::createPinGraph() noexcept {
1734
1756
1735
1757
const string& inet = cn.inSigs_ [i];
1736
1758
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
+ }
1740
1783
1741
1784
uint64_t qk = hashComb (driver->id_ , driver->out_ );
1742
1785
assert (qk);
@@ -1750,6 +1793,52 @@ bool BLIF_file::createPinGraph() noexcept {
1750
1793
1751
1794
eid = pg_.linK (qk, key);
1752
1795
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
+ }
1753
1842
}
1754
1843
}
1755
1844
}
0 commit comments