@@ -197,6 +197,28 @@ CStr BLIF_file::BNode::cPrimType() const noexcept {
197197 return ptype_ == prim::A_ZERO ? " {e}" : pr_enum2str (ptype_);
198198}
199199
200+ int BLIF_file::findTermByNet (const vector<string>& D, const string& net) noexcept {
201+ assert (not net.empty ());
202+ assert (not D.empty ());
203+ if (net.empty () or D.empty ())
204+ return -1 ;
205+
206+ int64_t sz = D.size ();
207+ assert (sz < INT_MAX);
208+
209+ // lputs();
210+ // logVec(D, " _bnode.D ");
211+ // lputs();
212+
213+ for (int i = sz - 1 ; i >= 0 ; i--) {
214+ CStr term = D[i].c_str ();
215+ CStr p = ::strchr (term, ' =' );
216+ if (p and net == p+1 )
217+ return i;
218+ }
219+ return -1 ;
220+ }
221+
200222bool BLIF_file::readBlif () noexcept {
201223 inputs_.clear ();
202224 outputs_.clear ();
@@ -507,15 +529,16 @@ bool BLIF_file::checkBlif(vector<string>& badInputs,
507529 if (trace_ >= 8 ) {
508530 // string written = pr_write_yaml( FIFO36K );
509531 // string written = pr_write_yaml( FIFO18KX2 );
510- string written = pr_write_yaml ( TDP_RAM36K );
532+ // string written = pr_write_yaml( TDP_RAM36K );
533+ string written = pr_write_yaml ( TDP_RAM18KX2 );
511534 flush_out (true );
512535 if (written.empty ()) {
513536 lprintf (" \t\t FAIL: pr_write_yaml() FAILED\n\n " );
514537 } else {
515538 lprintf (" \t written: %s\n\n " , written.c_str ());
516539 if (0 ) {
517540 lprintf (" \n " );
518- for (int bb = 30 ; bb >= 0 ; bb--) {
541+ for (int bb = 15 ; bb >= 0 ; bb--) {
519542 lprintf (" \" RDATA_A[%i]\" ," , bb);
520543 }
521544 lputs ();
@@ -1127,6 +1150,12 @@ bool BLIF_file::createNodes() noexcept {
11271150 if (not starts_w_subckt (cs + 1 , len - 1 ))
11281151 continue ;
11291152 Fio::split_spa (lines_[L], V);
1153+ // if (L == 48) {
1154+ // string delWire1151 = "$delete_wire$1151";
1155+ // lputs8();
1156+ // int dTerm = findTermByNet(V, delWire1151);
1157+ // lprintf(" dTerm= %i\n", dTerm);
1158+ // }
11301159 if (V.size () > 1 and V.front () == " .subckt" ) {
11311160 Prim_t pt = pr_str2enum ( V[1 ].c_str () );
11321161 if (pr_is_MOG (pt)) {
@@ -1172,7 +1201,6 @@ bool BLIF_file::createNodes() noexcept {
11721201 if (starts_w_names (cs + 1 , len - 1 )) {
11731202 Fio::split_spa (lines_[L], V);
11741203 if (V.size () > 1 and V.front () == " .names" ) {
1175- // lputs9();
11761204 nodePool_.emplace_back (" .names" , L);
11771205 BNode& nd = nodePool_.back ();
11781206 nd.data_ .assign (V.begin () + 1 , V.end ());
@@ -1209,7 +1237,6 @@ bool BLIF_file::createNodes() noexcept {
12091237 nd.ptype_ = pr_str2enum (nd.data_front ());
12101238 nd.place_output_at_back (nd.data_ );
12111239 if (pr_is_DSP (nd.ptype_ )) {
1212- // lputs9();
12131240 vector<string> TK;
12141241 // search for .param DSP_MODE "MULTIPLY"
12151242 // to flag clock-less DSP
@@ -1285,6 +1312,13 @@ bool BLIF_file::createNodes() noexcept {
12851312 continue ;
12861313 assert (!nd.is_mog_ );
12871314
1315+ // if (nd.lnum_ == 48) {
1316+ // string delWire1151 = "$delete_wire$1151";
1317+ // lputs8();
1318+ // int dTerm = findTermByNet(nd.data_, delWire1151);
1319+ // lprintf(" dTerm= %i\n", dTerm);
1320+ // }
1321+
12881322 s_is_MOG (nd, V);
12891323 bool is_mog = V.size () > 1 ;
12901324 if (is_mog) {
@@ -1294,15 +1328,16 @@ bool BLIF_file::createNodes() noexcept {
12941328 logVec (V, " [V-terms] " );
12951329 lputs ();
12961330 }
1297- // lputs9();
12981331
1332+ vector<string> dataCopy { nd.data_ };
12991333 s_remove_MOG_terms (nd);
13001334 uint startVirtual = nodePool_.size ();
13011335 for (uint j = 1 ; j < V.size (); j++) {
13021336 nodePool_.emplace_back (nd);
13031337 nodePool_.back ().virtualOrigin_ = i;
13041338 nodePool_.back ().is_mog_ = true ;
13051339 }
1340+ nd.realData_ .swap (dataCopy);
13061341 nd.data_ .push_back (V.front ());
13071342 nd.is_mog_ = true ;
13081343 // give one output term to each virtual MOG:
@@ -1341,8 +1376,6 @@ bool BLIF_file::createNodes() noexcept {
13411376 }
13421377 if (nd.kw_ == " .subckt" or nd.kw_ == " .gate" ) {
13431378 if (nd.data_ .size () > 1 ) {
1344- // if (nd.lnum_ == 47)
1345- // lputs8();
13461379 const string& last = nd.data_ .back ();
13471380 size_t llen = last.length ();
13481381 if (!last.empty () and llen < 4095 ) {
@@ -1637,7 +1670,6 @@ bool BLIF_file::linkNodes() noexcept {
16371670 assert (fab_nd);
16381671 BNode& nd = *fab_nd;
16391672 if (nd.out_ .empty ()) {
1640- // lputs8();
16411673 err_msg_ = str::concat (" incomplete fabric cell: " , nd.kw_ );
16421674 if (!nd.data_ .empty ()) {
16431675 err_msg_ += str::concat (" " , nd.data_ .front ());
@@ -1708,20 +1740,35 @@ bool BLIF_file::linkNodes() noexcept {
17081740 assert (!nd.out_ .empty ());
17091741 if (nd.parent_ )
17101742 continue ;
1743+ // if (nd.lnum_ == 48)
1744+ // lputs7();
17111745 int pinIndex = -1 ;
17121746 BNode* par = findFabricParent (nd.id_ , nd.out_ , pinIndex);
17131747 if (!par) {
17141748 if (nd.is_RAM () or nd.is_DSP ()) {
1749+ const string& net = nd.out_ ;
17151750 bool is_ram = nd.is_RAM ();
1751+ uint rid = nd.realId (*this );
1752+ const BNode& realNd = bnodeRef (rid);
1753+ const vector<string>& realData = realNd.realData_ ;
1754+ assert (not realData.empty ());
1755+ int dataTerm = findTermByNet (realData, net);
1756+ assert (dataTerm >= 0 );
1757+ assert (dataTerm < int64_t (realData.size ()));
1758+ if (dataTerm < 0 )
1759+ continue ;
17161760 // RAM or DSP output bits may be unused
1717- if (trace_ >= 5 ) {
1761+ if (trace_ >= 4 ) {
17181762 lprintf (" skipping dangling cell output issue for %s at line %u\n " ,
1719- is_ram ? " RAM" : " DSP" , nd.lnum_ );
1763+ is_ram ? " RAM" : " DSP" , realNd.lnum_ );
1764+ lprintf (" dangling net: %s term# %i %s\n " ,
1765+ net.c_str (), dataTerm, realData[dataTerm].c_str ());
1766+ lputs ();
17201767 }
17211768 if (is_ram)
1722- dang_RAM_outputs_.emplace_back (nd .id_ );
1769+ dang_RAM_outputs_.emplace_back (realNd .id_ , dataTerm );
17231770 else
1724- dang_DSP_outputs_.emplace_back (nd .id_ );
1771+ dang_DSP_outputs_.emplace_back (realNd .id_ , dataTerm );
17251772 continue ;
17261773 }
17271774 err_msg_ = " dangling cell output: " ;
@@ -1934,7 +1981,7 @@ bool BLIF_file::checkClockSepar(vector<BNode*>& clocked) noexcept {
19341981 else
19351982 pg_.setNwName (" pin_graph_VIOL" );
19361983
1937- if (trace_ >= 3 ) {
1984+ if (not ::getenv ( " pln_blif_dont_write_pinGraph " ) ) {
19381985 pinGraphFile_ = writePinGraph (" _PinGraph.dot" );
19391986 }
19401987
0 commit comments