@@ -25,6 +25,7 @@ void BLIF_file::reset(CStr nm, uint16_t tr) noexcept {
2525 inputs_lnum_ = outputs_lnum_ = 0 ;
2626 err_lnum_ = err_lnum2_ = 0 ;
2727 err_msg_.clear ();
28+ err_info2_.clear ();
2829 pg_.clear ();
2930 pg2blif_.clear ();
3031
@@ -253,6 +254,7 @@ bool BLIF_file::readBlif() noexcept {
253254
254255 rd_ok_ = chk_ok_ = false ;
255256 err_msg_.clear ();
257+ err_info2_.clear ();
256258 trace_ = 0 ;
257259
258260 {
@@ -779,6 +781,17 @@ uint BLIF_file::countFFs() const noexcept {
779781 return cnt;
780782}
781783
784+ uint BLIF_file::countWires () const noexcept {
785+ if (numNodes () == 0 or fabricRealNodes_.empty ())
786+ return 0 ;
787+ uint cnt = 0 ;
788+ for (const BNode* x : fabricRealNodes_) {
789+ if (x->is_WIRE ())
790+ cnt++;
791+ }
792+ return cnt;
793+ }
794+
782795uint BLIF_file::countCBUFs () const noexcept {
783796 uint nn = numNodes ();
784797 if (nn == 0 )
@@ -1628,24 +1641,24 @@ void BLIF_file::BNode::allInputPins(vector<string>& V) const noexcept {
16281641 return ;
16291642}
16301643
1631- BLIF_file::BNode* BLIF_file::findOutputPort (const string& contact ) noexcept {
1632- assert (not contact .empty ());
1644+ BLIF_file::BNode* BLIF_file::findOutputPort (const string& sig ) noexcept {
1645+ assert (not sig .empty ());
16331646 if (topOutputs_.empty ()) return nullptr ;
16341647
16351648 // TMP linear
16361649 for (BNode* x : topOutputs_) {
1637- if (x->out_ == contact ) return x;
1650+ if (x->out_ == sig ) return x;
16381651 }
16391652 return nullptr ;
16401653}
16411654
1642- BLIF_file::BNode* BLIF_file::findInputPort (const string& contact ) noexcept {
1643- assert (not contact .empty ());
1655+ BLIF_file::BNode* BLIF_file::findInputPort (const string& sig ) noexcept {
1656+ assert (not sig .empty ());
16441657 if (topInputs_.empty ()) return nullptr ;
16451658
16461659 // TMP linear
16471660 for (BNode* x : topInputs_) {
1648- if (x->out_ == contact ) return x;
1661+ if (x->out_ == sig ) return x;
16491662 }
16501663 return nullptr ;
16511664}
@@ -2010,7 +2023,7 @@ bool BLIF_file::checkClockSepar(vector<BNode*>& clocked) noexcept {
20102023 }
20112024
20122025 bool color_ok = true ;
2013- CStr viol_prefix = " ===!!! clock-data separation error " ;
2026+ CStr viol_prefix = " [Error] clock-data separation ERROR " ;
20142027
20152028 // -- check that end-points of red edges are red
20162029 for (NW::cEI E (pg_); E.valid (); ++E) {
@@ -2039,11 +2052,18 @@ bool BLIF_file::checkClockSepar(vector<BNode*>& clocked) noexcept {
20392052 lprintf (" %s: blif lines: %u - %u\n " ,
20402053 viol_prefix, err_lnum_, err_lnum2_);
20412054 char B[512 ] = {};
2042- ::sprintf (B, " line %u : %s " , err_lnum_, bnode1.kw_.c_str());
2055+ ::sprintf (B, " ERROR line %u : %s " , err_lnum_, bnode1.kw_.c_str());
20432056 logVec (bnode1.data_ , B);
2044- ::sprintf (B, " line %u : %s " , err_lnum2_, bnode2.kw_.c_str());
2057+ ::sprintf (B, " ERROR line %u : %s " , err_lnum2_, bnode2.kw_.c_str());
20452058 logVec (bnode2.data_ , B);
20462059 flush_out (true );
2060+ if (bnode1.isTopInput () and bnode2.is_WIRE ()) {
2061+ err_info2_ = str::concat ( " clock input port " , bnode1.out_ ,
2062+ " drives feedthrough wire at line " ,
2063+ std::to_string (err_lnum2_) );
2064+ lprintf (" error-info: %s\n " , err_info2_.c_str ());
2065+ flush_out (true );
2066+ }
20472067 }
20482068 break ;
20492069 }
@@ -2060,7 +2080,8 @@ bool BLIF_file::checkClockSepar(vector<BNode*>& clocked) noexcept {
20602080
20612081 if (!color_ok) {
20622082 flush_out (true ); err_puts ();
2063- lprintf2 (" [Error] clock-data separation error\n " );
2083+ lprintf2 (" [Error] clock-data separation error: lines %u - %u\n " ,
2084+ err_lnum_, err_lnum2_);
20642085 err_puts (); flush_out (true );
20652086 return false ;
20662087 }
@@ -2097,6 +2118,7 @@ bool BLIF_file::createPinGraph() noexcept {
20972118 if (fabricNodes_.empty ()) return false ;
20982119
20992120 err_msg_.clear ();
2121+ err_info2_.clear ();
21002122 uint64_t key = 0 ;
21012123 uint nid = 0 , kid = 0 , eid = 0 ;
21022124 vector<string> INP;
@@ -2146,6 +2168,54 @@ bool BLIF_file::createPinGraph() noexcept {
21462168 vector<qTup> Q;
21472169 Q.reserve (topInputs_.size ());
21482170
2171+ // -- link in-ports to out-ports via feedthrough wires
2172+ for (BNode* x : fabricRealNodes_) {
2173+ if (x->is_WIRE ()) {
2174+ BNode& w = *x;
2175+ assert (w.data_ .size () == 2 );
2176+ const string& w_inp = w.data_ .front ();
2177+ const string& w_out = w.data_ .back ();
2178+ BNode* iport = findInputPort (w_inp);
2179+ if (!iport)
2180+ continue ;
2181+ BNode* oport = findOutputPort (w_out);
2182+ if (!oport)
2183+ continue ;
2184+ assert (iport->isTopInput ());
2185+ assert (oport->isTopOutput ());
2186+ // NW-nodes for i/o ports should exist already
2187+ assert (iport->nw_id_ );
2188+ assert (oport->nw_id_ );
2189+ assert (pg_.hasNode (iport->nw_id_ ));
2190+ assert (pg_.hasNode (oport->nw_id_ ));
2191+ assert (map_pg2blif (iport->nw_id_ ) == iport->id_ );
2192+ assert (map_pg2blif (oport->nw_id_ ) == oport->id_ );
2193+
2194+ // NW keys and nodes for wire pseudo-cell:
2195+ uint64_t w_k1 = hashCantor (w.id_ , 1 ) + max_key1;
2196+ uint64_t w_k2 = hashCantor (w.id_ , 2 ) + max_key1;
2197+ assert (w_k1);
2198+ assert (w_k2);
2199+ assert (w_k1 != w_k2);
2200+ uint w_n1 = pg_.insK (w_k1);
2201+ assert (w_n1);
2202+ uint w_n2 = pg_.insK (w_k2);
2203+ assert (w_n2);
2204+ pg2blif_.emplace (w_n1, w.id_ );
2205+ pg2blif_.emplace (w_n2, w.id_ );
2206+ pg_.setNodeName4 (w_n1, w.id_ , w.lnum_ , 1 , " FTwireI" );
2207+ pg_.setNodeName4 (w_n2, w.id_ , w.lnum_ , 2 , " FTwireO" );
2208+
2209+ // link feedthrough:
2210+ uint ee;
2211+ ee = pg_.linkNodes (iport->nw_id_ , w_n1, false );
2212+ ee = pg_.linkNodes (w_n1, w_n2, true );
2213+ ee = pg_.linkNodes (w_n2, oport->nw_id_ , false );
2214+ if (trace_ >= 11 )
2215+ lprintf (" \t\t ee = %u\n " , ee);
2216+ }
2217+ }
2218+
21492219 // -- link from input ports to fabric
21502220 for (BNode* p : topInputs_) {
21512221 INP.clear ();
@@ -2163,9 +2233,6 @@ bool BLIF_file::createPinGraph() noexcept {
21632233 lprintf (" %s\n " , port.cPortName ());
21642234 }
21652235
2166- // if (port.id_ == 24)
2167- // lputs1();
2168-
21692236 for (const upair& pa : PAR) {
21702237 if (pa.first == port.id_ )
21712238 continue ;
@@ -2295,12 +2362,12 @@ bool BLIF_file::createPinGraph() noexcept {
22952362 uint cn_realId = cn.realId (*this );
22962363 key = hashCantor (cn_realId, i + 1 ) + max_key1;
22972364 assert (key);
2298- // if (key == 110)
2299- // lputs3();
23002365 kid = pg_.findNode (key);
23012366 if (kid) {
2302- lprintf (" \t\t ___ found nid %u '%s' for key %zu" ,
2303- kid, pg_.cnodeName (kid), key);
2367+ if (trace_ >= 8 ) {
2368+ lprintf (" \t\t ___ found nid %u '%s' for key %zu" ,
2369+ kid, pg_.cnodeName (kid), key);
2370+ }
23042371 }
23052372 else {
23062373 kid = pg_.insK (key);
@@ -2529,7 +2596,8 @@ bool BLIF_file::createPinGraph() noexcept {
25292596
25302597 pg_.setNwName (" pin_graph" );
25312598
2532- // writePinGraph("pin_graph_1.dot");
2599+ if (trace_ >= 8 )
2600+ writePinGraph (" Dpin_graph_1.dot" , true , false );
25332601
25342602#ifndef NDEBUG
25352603 // -- verify that all NW IDs are mapped to BNodes:
@@ -2577,11 +2645,13 @@ string BLIF_file::writePinGraph(CStr fn0, bool nodeTable, bool noDeg0) const noe
25772645 err_puts (); flush_out (true );
25782646 }
25792647
2580- lprintf (" (writePinGraph) status:%s file: %s\n " ,
2581- wrDot_ok ? " OK" : " FAIL" ,
2582- fn.c_str ());
2648+ if (not wrDot_ok or trace_ >= 4 ) {
2649+ lprintf (" (writePinGraph) status:%s file: %s\n\n " ,
2650+ wrDot_ok ? " OK" : " FAIL" ,
2651+ fn.c_str ());
2652+ }
25832653
2584- flush_out (true );
2654+ flush_out (false );
25852655 if (wrDot_ok)
25862656 return fn;
25872657 return {};
0 commit comments