@@ -435,7 +435,7 @@ bool BLIF_file::checkBlif() noexcept {
435
435
if (!topInputs_.empty () and !topOutputs_.empty ()) {
436
436
if (trace_ >= 5 )
437
437
pg_.setTrace (trace_);
438
- vector<const BNode*> clocked;
438
+ vector<BNode*> clocked;
439
439
collectClockedNodes (clocked);
440
440
uint clocked_sz = clocked.size ();
441
441
if (trace_ >= 3 ) {
@@ -636,15 +636,15 @@ uint BLIF_file::printPrimitives(std::ostream& os, bool instCounts) const noexcep
636
636
return Prim_MAX_ID;
637
637
}
638
638
639
- void BLIF_file::collectClockedNodes (vector<const BNode*>& V) noexcept {
639
+ void BLIF_file::collectClockedNodes (vector<BNode*>& V) noexcept {
640
640
V.clear ();
641
641
uint nn = numNodes ();
642
642
if (nn == 0 )
643
643
return ;
644
644
645
645
V.reserve (20 );
646
646
for (uint i = 1 ; i <= nn; i++) {
647
- const BNode& nd = nodePool_[i];
647
+ BNode& nd = nodePool_[i];
648
648
uint t = nd.ptype_ ;
649
649
if (!t or t >= Prim_MAX_ID)
650
650
continue ;
@@ -1555,7 +1555,7 @@ bool BLIF_file::linkNodes() noexcept {
1555
1555
return true ;
1556
1556
}
1557
1557
1558
- bool BLIF_file::checkClockSepar (vector<const BNode*>& clocked) noexcept {
1558
+ bool BLIF_file::checkClockSepar (vector<BNode*>& clocked) noexcept {
1559
1559
auto & ls = lout ();
1560
1560
if (::getenv (" pln_dont_check_clock_separation" ))
1561
1561
return true ;
@@ -1727,6 +1727,8 @@ struct qTup {
1727
1727
}
1728
1728
};
1729
1729
1730
+ static CStr s_possible_cdrivers = " {iport, CLK_BUF, I_SERDES}" ;
1731
+
1730
1732
bool BLIF_file::createPinGraph () noexcept {
1731
1733
pg_.clear ();
1732
1734
pg2blif_.clear ();
@@ -1822,32 +1824,40 @@ bool BLIF_file::createPinGraph() noexcept {
1822
1824
lputs ();
1823
1825
}
1824
1826
1825
- assert ( par.cell_hc_ );
1826
- key = hashCantor (par. id_ , pinIndex+1 ) + max_key1;
1827
+ uint par_realId = par.realId (* this );
1828
+ key = hashCantor (par_realId , pinIndex+1 ) + max_key1;
1827
1829
assert (key);
1828
- assert (not pg_.hasKey (key));
1830
+ kid = pg_.findNode (key);
1831
+ if (kid) {
1832
+ // virtual MOG effect
1833
+ if (trace_ >= 7 ) {
1834
+ lprintf (" (virtual MOG effect) node exists: key=%zu nid=%u\n " ,
1835
+ key, kid);
1836
+ }
1837
+ continue ;
1838
+ }
1829
1839
kid = pg_.insK (key);
1830
1840
assert (kid);
1831
1841
assert (key != port.id_ ); // bc port.id_ is a key for port
1832
1842
assert (pg_.hasKey (port.id_ )); //
1833
- pg2blif_.emplace (kid, par. id_ );
1843
+ pg2blif_.emplace (kid, par_realId );
1834
1844
1835
- pg_.nodeRef (kid).setCid (par. id_ );
1845
+ pg_.nodeRef (kid).setCid (par_realId );
1836
1846
::snprintf (nm_buf, 510 , " %s_%uL_%up%u" ,
1837
1847
par.hasPrimType() ? par.cPrimType() : "NP",
1838
- par.lnum_, par.id_ , pinIndex);
1848
+ par.lnum_, par_realId , pinIndex);
1839
1849
1840
1850
assert (not pg_.nodeRef (kid).inp_flag_ );
1841
- pg_.setNodeName4 (kid, par. id_ , par.lnum_ , pinIndex+1 , par.cPrimType ());
1851
+ pg_.setNodeName4 (kid, par_realId , par.lnum_ , pinIndex+1 , par.cPrimType ());
1842
1852
pg_.nodeRef (kid).markClk (is_clock);
1843
1853
1844
- if (trace_ >= 6 )
1854
+ if (trace_ >= 7 )
1845
1855
lprintf (" ALT nodeName %s --> %s\n " , pg_.cnodeName (kid), nm_buf);
1846
1856
1847
1857
eid = pg_.linK (port.id_ , key);
1848
1858
assert (eid);
1849
1859
1850
- Q.emplace_back (kid, par. id_ , pinIndex, par.out_ .c_str ());
1860
+ Q.emplace_back (kid, par_realId , pinIndex, par.out_ .c_str ());
1851
1861
}
1852
1862
}
1853
1863
@@ -1885,27 +1895,27 @@ bool BLIF_file::createPinGraph() noexcept {
1885
1895
}
1886
1896
1887
1897
// -- create pg-nodes for sequential input pins
1888
- vector<const BNode*> clocked;
1898
+ vector<BNode*> clocked;
1889
1899
collectClockedNodes (clocked);
1890
1900
if (trace_ >= 4 )
1891
1901
lprintf (" createPinGraph: clocked.size()= %zu\n " , clocked.size ());
1892
1902
if (not clocked.empty ()) {
1893
1903
string inp1;
1894
- for (const BNode* cnp : clocked) {
1895
- const BNode& cn = *cnp;
1904
+ for (BNode* cnp : clocked) {
1905
+ BNode& cn = *cnp;
1896
1906
assert (cn.hasPrimType ());
1897
1907
if (cn.ptype_ == prim::CLK_BUF or cn.ptype_ == prim::FCLK_BUF)
1898
1908
continue ;
1899
- // lputs9();
1909
+
1900
1910
for (uint i = 0 ; i < cn.inPins_ .size (); i++) {
1901
1911
const string& inp = cn.inPins_ [i];
1902
1912
assert (not inp.empty ());
1903
1913
if (not pr_pin_is_clock (cn.ptype_ , inp))
1904
1914
continue ;
1905
- assert (cn.cell_hc_ );
1906
- key = hashCantor (cn.id_ , i + 1 ) + max_key1;
1915
+
1916
+ uint cn_realId = cn.realId (*this );
1917
+ key = hashCantor (cn_realId, i + 1 ) + max_key1;
1907
1918
assert (key);
1908
- // assert(not pg_.hasKey(key));
1909
1919
kid = pg_.insK (key);
1910
1920
assert (kid);
1911
1921
pg_.nodeRef (kid).markClk (true );
@@ -1914,32 +1924,33 @@ bool BLIF_file::createPinGraph() noexcept {
1914
1924
kid, cn.lnum_);
1915
1925
1916
1926
assert (not pg_.nodeRef (kid).inp_flag_ );
1917
- pg_.setNodeName4 (kid, cn. id_ , cn.lnum_ , i+1 , cn.cPrimType ());
1918
- pg2blif_.emplace (kid, cn. id_ );
1927
+ pg_.setNodeName4 (kid, cn_realId , cn.lnum_ , i+1 , cn.cPrimType ());
1928
+ pg2blif_.emplace (kid, cn_realId );
1919
1929
1920
1930
const string& inet = cn.inSigs_ [i];
1921
1931
assert (not inet.empty ());
1922
- const BNode* driver = findDriverNode (cn. id_ , inet);
1932
+ const BNode* driver = findDriverNode (cn_realId , inet);
1923
1933
if (!driver) {
1924
1934
flush_out (true ); err_puts ();
1925
1935
lprintf2 (" [Error] no driver for clock node #%u %s line:%u\n " ,
1926
- cn. id_ , cn.cPrimType (), cn.lnum_ );
1936
+ cn_realId , cn.cPrimType (), cn.lnum_ );
1927
1937
err_puts (); flush_out (true );
1928
1938
return false ;
1929
1939
}
1940
+ uint driver_realId = driver->realId (*this );
1930
1941
1931
1942
if (trace_ >= 5 ) {
1932
1943
lputs9 ();
1933
1944
lprintf (" from cn#%u %s " ,
1934
- cn. id_ , cn.cPrimType () );
1945
+ cn_realId , cn.cPrimType () );
1935
1946
lprintf ( " CLOCK_TRACE driver-> id_%u %s out_net %s\n " ,
1936
- driver-> id_ , driver->cPrimType (), driver->out_ .c_str () );
1947
+ driver_realId , driver->cPrimType (), driver->out_ .c_str () );
1937
1948
}
1938
1949
1939
- if (not driver->is_CLK_BUF () and not driver-> isTopInput ()) {
1950
+ if (not driver->canDriveClockNode ()) {
1940
1951
flush_out (true ); err_puts ();
1941
- lprintf2 (" [Error] bad driver for clock node #%u must be CLK_BUF or iport \n " ,
1942
- cn. id_ );
1952
+ lprintf2 (" [Error] bad driver (%s) for clock node #%u must be %s \n " ,
1953
+ driver-> cPrimType (), cn_realId, s_possible_cdrivers );
1943
1954
err_puts (); flush_out (true );
1944
1955
return false ;
1945
1956
}
@@ -1949,7 +1960,7 @@ bool BLIF_file::createPinGraph() noexcept {
1949
1960
uint opin_nid = pg_.findNode (opin_key);
1950
1961
if (opin_nid) {
1951
1962
assert (pg_.nodeRef (opin_nid).isNamed ());
1952
- assert (map_pg2blif (opin_nid) == driver-> id_ );
1963
+ assert (map_pg2blif (opin_nid) == driver_realId );
1953
1964
}
1954
1965
else {
1955
1966
opin_nid = pg_.insK (opin_key);
@@ -1964,9 +1975,9 @@ bool BLIF_file::createPinGraph() noexcept {
1964
1975
}
1965
1976
1966
1977
assert (not pg_.nodeRef (opin_nid).inp_flag_ );
1967
- pg_.setNodeName3 (opin_nid, driver-> id_ ,
1978
+ pg_.setNodeName3 (opin_nid, driver_realId ,
1968
1979
driver->lnum_ , driver->out_ .c_str ());
1969
- pg2blif_.emplace (opin_nid, driver-> id_ );
1980
+ pg2blif_.emplace (opin_nid, driver_realId );
1970
1981
}
1971
1982
1972
1983
assert (opin_nid and kid);
@@ -1991,7 +2002,7 @@ bool BLIF_file::createPinGraph() noexcept {
1991
2002
return false ;
1992
2003
}
1993
2004
1994
- uint64_t ipin_key = hashCantor (dn.id_ , 1 ) + max_key1;
2005
+ uint64_t ipin_key = hashCantor (dn.realId (* this ) , 1 ) + max_key1;
1995
2006
assert (ipin_key);
1996
2007
uint ipin_nid = pg_.findNode (ipin_key);
1997
2008
if (ipin_nid) {
@@ -2041,10 +2052,10 @@ bool BLIF_file::createPinGraph() noexcept {
2041
2052
drv_drv->out_ .c_str (), drv_drv->lnum_ );
2042
2053
}
2043
2054
2044
- if (not drv_drv->is_CLK_BUF () and not drv_drv-> isTopInput ()) {
2055
+ if (not drv_drv->canDriveClockNode ()) {
2045
2056
flush_out (true ); err_puts ();
2046
- lprintf2 (" [Error] bad driver (%s) for clock-buf node #%u line:%u must be CLK_BUF or iport \n " ,
2047
- drv_drv->cPrimType (), dn.id_ , dn.lnum_ );
2057
+ lprintf2 (" [Error] bad driver (%s) for clock-buf node #%u line:%u must be %s \n " ,
2058
+ drv_drv->cPrimType (), dn.id_ , dn.lnum_ , s_possible_cdrivers );
2048
2059
err_puts (); flush_out (true );
2049
2060
err_lnum_ = dn.lnum_ ;
2050
2061
err_lnum2_ = drv_drv->lnum_ ;
@@ -2055,17 +2066,17 @@ bool BLIF_file::createPinGraph() noexcept {
2055
2066
// and connect it to the iput of CLK_BUF 'dn'
2056
2067
2057
2068
assert (drv_drv->out_ == inp1);
2058
- assert (drv_drv->cell_hc_ );
2059
2069
uint64_t drv_drv_outKey = 0 ;
2060
2070
uint drv_drv_outNid = 0 ;
2061
2071
nid = kid = 0 ;
2072
+ uint drv_drv_realId = drv_drv->realId (*this );
2062
2073
2063
2074
if (drv_drv->isTopInput ()) {
2064
2075
assert (drv_drv->nw_id_ );
2065
2076
drv_drv_outNid = drv_drv->nw_id_ ;
2066
2077
assert (pg_.hasNode (drv_drv_outNid));
2067
2078
assert (pg2blif_.count (drv_drv_outNid));
2068
- assert (map_pg2blif (drv_drv_outNid) == drv_drv-> id_ );
2079
+ assert (map_pg2blif (drv_drv_outNid) == drv_drv_realId );
2069
2080
drv_drv_outKey = pg_.nodeRefCk (drv_drv_outNid).key_ ;
2070
2081
assert (drv_drv_outKey);
2071
2082
}
@@ -2076,7 +2087,7 @@ bool BLIF_file::createPinGraph() noexcept {
2076
2087
drv_drv_outNid = pg_.insK (drv_drv_outKey);
2077
2088
assert (drv_drv_outNid);
2078
2089
pg_.nodeRef (drv_drv_outNid).markClk (true );
2079
- pg2blif_.emplace (drv_drv_outNid, drv_drv-> id_ );
2090
+ pg2blif_.emplace (drv_drv_outNid, drv_drv_realId );
2080
2091
2081
2092
if (not pg_.nodeRefCk (drv_drv_outNid).isNamed ()) {
2082
2093
::snprintf (nm_buf, 510 , " nd%u_L%u_" ,
@@ -2089,7 +2100,7 @@ bool BLIF_file::createPinGraph() noexcept {
2089
2100
}
2090
2101
2091
2102
assert (not pg_.nodeRef (drv_drv_outNid).inp_flag_ );
2092
- pg_.setNodeName3 (drv_drv_outNid, drv_drv-> id_ ,
2103
+ pg_.setNodeName3 (drv_drv_outNid, drv_drv_realId ,
2093
2104
drv_drv->lnum_ , drv_drv->out_ .c_str ());
2094
2105
}
2095
2106
@@ -2114,6 +2125,16 @@ bool BLIF_file::createPinGraph() noexcept {
2114
2125
}
2115
2126
}
2116
2127
2128
+ // mark prim-types in NW:
2129
+ for (const auto I : pg2blif_) {
2130
+ uint nw_id = I.first ;
2131
+ uint bl_id = I.second ;
2132
+ const BNode& bnode = bnodeRef (bl_id);
2133
+ assert (not bnode.isVirtualMog ());
2134
+ if (bnode.hasPrimType ())
2135
+ pg_.nodeRefCk (nw_id).markPrim (bnode.ptype_ );
2136
+ }
2137
+
2117
2138
pg_.setNwName (" pin_graph" );
2118
2139
2119
2140
// writePinGraph("pin_graph_1.dot");
0 commit comments