@@ -25,6 +25,7 @@ void BLIF_file::reset(CStr nm, uint16_t tr) noexcept {
25
25
inputs_lnum_ = outputs_lnum_ = 0 ;
26
26
err_lnum_ = err_lnum2_ = 0 ;
27
27
err_msg_.clear ();
28
+ err_info2_.clear ();
28
29
pg_.clear ();
29
30
pg2blif_.clear ();
30
31
@@ -253,6 +254,7 @@ bool BLIF_file::readBlif() noexcept {
253
254
254
255
rd_ok_ = chk_ok_ = false ;
255
256
err_msg_.clear ();
257
+ err_info2_.clear ();
256
258
trace_ = 0 ;
257
259
258
260
{
@@ -779,6 +781,17 @@ uint BLIF_file::countFFs() const noexcept {
779
781
return cnt;
780
782
}
781
783
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
+
782
795
uint BLIF_file::countCBUFs () const noexcept {
783
796
uint nn = numNodes ();
784
797
if (nn == 0 )
@@ -1628,24 +1641,24 @@ void BLIF_file::BNode::allInputPins(vector<string>& V) const noexcept {
1628
1641
return ;
1629
1642
}
1630
1643
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 ());
1633
1646
if (topOutputs_.empty ()) return nullptr ;
1634
1647
1635
1648
// TMP linear
1636
1649
for (BNode* x : topOutputs_) {
1637
- if (x->out_ == contact ) return x;
1650
+ if (x->out_ == sig ) return x;
1638
1651
}
1639
1652
return nullptr ;
1640
1653
}
1641
1654
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 ());
1644
1657
if (topInputs_.empty ()) return nullptr ;
1645
1658
1646
1659
// TMP linear
1647
1660
for (BNode* x : topInputs_) {
1648
- if (x->out_ == contact ) return x;
1661
+ if (x->out_ == sig ) return x;
1649
1662
}
1650
1663
return nullptr ;
1651
1664
}
@@ -2010,7 +2023,7 @@ bool BLIF_file::checkClockSepar(vector<BNode*>& clocked) noexcept {
2010
2023
}
2011
2024
2012
2025
bool color_ok = true ;
2013
- CStr viol_prefix = " ===!!! clock-data separation error " ;
2026
+ CStr viol_prefix = " [Error] clock-data separation ERROR " ;
2014
2027
2015
2028
// -- check that end-points of red edges are red
2016
2029
for (NW::cEI E (pg_); E.valid (); ++E) {
@@ -2039,11 +2052,18 @@ bool BLIF_file::checkClockSepar(vector<BNode*>& clocked) noexcept {
2039
2052
lprintf (" %s: blif lines: %u - %u\n " ,
2040
2053
viol_prefix, err_lnum_, err_lnum2_);
2041
2054
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());
2043
2056
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());
2045
2058
logVec (bnode2.data_ , B);
2046
2059
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
+ }
2047
2067
}
2048
2068
break ;
2049
2069
}
@@ -2060,7 +2080,8 @@ bool BLIF_file::checkClockSepar(vector<BNode*>& clocked) noexcept {
2060
2080
2061
2081
if (!color_ok) {
2062
2082
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_);
2064
2085
err_puts (); flush_out (true );
2065
2086
return false ;
2066
2087
}
@@ -2097,6 +2118,7 @@ bool BLIF_file::createPinGraph() noexcept {
2097
2118
if (fabricNodes_.empty ()) return false ;
2098
2119
2099
2120
err_msg_.clear ();
2121
+ err_info2_.clear ();
2100
2122
uint64_t key = 0 ;
2101
2123
uint nid = 0 , kid = 0 , eid = 0 ;
2102
2124
vector<string> INP;
@@ -2146,6 +2168,54 @@ bool BLIF_file::createPinGraph() noexcept {
2146
2168
vector<qTup> Q;
2147
2169
Q.reserve (topInputs_.size ());
2148
2170
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
+
2149
2219
// -- link from input ports to fabric
2150
2220
for (BNode* p : topInputs_) {
2151
2221
INP.clear ();
@@ -2163,9 +2233,6 @@ bool BLIF_file::createPinGraph() noexcept {
2163
2233
lprintf (" %s\n " , port.cPortName ());
2164
2234
}
2165
2235
2166
- // if (port.id_ == 24)
2167
- // lputs1();
2168
-
2169
2236
for (const upair& pa : PAR) {
2170
2237
if (pa.first == port.id_ )
2171
2238
continue ;
@@ -2295,12 +2362,12 @@ bool BLIF_file::createPinGraph() noexcept {
2295
2362
uint cn_realId = cn.realId (*this );
2296
2363
key = hashCantor (cn_realId, i + 1 ) + max_key1;
2297
2364
assert (key);
2298
- // if (key == 110)
2299
- // lputs3();
2300
2365
kid = pg_.findNode (key);
2301
2366
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
+ }
2304
2371
}
2305
2372
else {
2306
2373
kid = pg_.insK (key);
@@ -2529,7 +2596,8 @@ bool BLIF_file::createPinGraph() noexcept {
2529
2596
2530
2597
pg_.setNwName (" pin_graph" );
2531
2598
2532
- // writePinGraph("pin_graph_1.dot");
2599
+ if (trace_ >= 8 )
2600
+ writePinGraph (" Dpin_graph_1.dot" , true , false );
2533
2601
2534
2602
#ifndef NDEBUG
2535
2603
// -- 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
2577
2645
err_puts (); flush_out (true );
2578
2646
}
2579
2647
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
+ }
2583
2653
2584
- flush_out (true );
2654
+ flush_out (false );
2585
2655
if (wrDot_ok)
2586
2656
return fn;
2587
2657
return {};
0 commit comments