@@ -1747,9 +1747,8 @@ bool BLIF_file::linkNodes() noexcept {
17471747 if (!par) {
17481748 if (nd.is_RAM () or nd.is_DSP ()) {
17491749 const string& net = nd.out_ ;
1750- bool is_ram = nd.is_RAM ();
17511750 uint rid = nd.realId (*this );
1752- const BNode& realNd = bnodeRef (rid);
1751+ BNode& realNd = bnodeRef (rid);
17531752 const vector<string>& realData = realNd.realData_ ;
17541753 assert (not realData.empty ());
17551754 int dataTerm = findTermByNet (realData, net);
@@ -1760,12 +1759,13 @@ bool BLIF_file::linkNodes() noexcept {
17601759 // RAM or DSP output bits may be unused
17611760 if (trace_ >= 4 ) {
17621761 lprintf (" skipping dangling cell output issue for %s at line %u\n " ,
1763- is_ram ? " RAM " : " DSP " , realNd.lnum_ );
1762+ realNd. cPrimType () , realNd.lnum_ );
17641763 lprintf (" dangling net: %s term# %i %s\n " ,
17651764 net.c_str (), dataTerm, realData[dataTerm].c_str ());
17661765 lputs ();
17671766 }
1768- if (is_ram)
1767+ realNd.dangTerms_ .push_back (dataTerm);
1768+ if (nd.is_RAM ())
17691769 dang_RAM_outputs_.emplace_back (realNd.id_ , dataTerm);
17701770 else
17711771 dang_DSP_outputs_.emplace_back (realNd.id_ , dataTerm);
@@ -2482,5 +2482,54 @@ string BLIF_file::writePinGraph(CStr fn0) const noexcept {
24822482 return {};
24832483}
24842484
2485+ string BLIF_file::writeBlif (const string& toFn, bool cleanUp) noexcept {
2486+ if (toFn.empty ())
2487+ return {};
2488+ if (!fsz_ || !sz_ || !buf_ || fnm_.empty ())
2489+ return {};
2490+ if (not hasLines ())
2491+ return {};
2492+
2493+ string fn2 = (toFn == fnm_ ? str::concat (" 2_" , toFn) : toFn);
2494+
2495+ CStr cnm = fn2.c_str ();
2496+ FILE* f = ::fopen (cnm, " w" );
2497+ if (!f) {
2498+ if (trace_ >= 3 ) {
2499+ flush_out (true );
2500+ lprintf (" ERROR writeBlif() could not open file for writing: %s\n " , cnm);
2501+ flush_out (true );
2502+ }
2503+ return {};
2504+ }
2505+
2506+ size_t cnt = 0 , n = lines_.size ();
2507+ for (size_t i = 0 ; i < n; i++) {
2508+ CStr cs = lines_[i];
2509+ if (!cs || !cs[0 ]) continue ;
2510+ ::fputs (cs, f);
2511+ ::fputc (' \n ' , f);
2512+ if (::ferror (f)) {
2513+ if (trace_ >= 3 ) {
2514+ flush_out (true );
2515+ lprintf (" ERROR writeBlif() error during writing: %s\n " , cnm);
2516+ flush_out (true );
2517+ }
2518+ break ;
2519+ }
2520+ cnt++;
2521+ }
2522+
2523+ ::fclose (f);
2524+
2525+ if (trace_ >= 4 ) {
2526+ flush_out (trace_ >= 5 );
2527+ lprintf (" writeBlif OK written #lines= %zu\n " , cnt);
2528+ }
2529+ flush_out (trace_ >= 5 );
2530+
2531+ return fn2;
2532+ }
2533+
24852534}
24862535
0 commit comments