@@ -373,7 +373,7 @@ bool BLIF_file::checkBlif() noexcept {
373
373
flush_out (true );
374
374
}
375
375
}
376
- if (trace_ >= 6 ) {
376
+ if (trace_ >= 7 ) {
377
377
printCarryNodes (ls);
378
378
flush_out (true );
379
379
}
@@ -503,6 +503,10 @@ uint BLIF_file::printNodes(std::ostream& os) const noexcept {
503
503
const Node& nd = nodePool_[i];
504
504
CStr pts = nd.cPrimType ();
505
505
assert (pts);
506
+
507
+ if (trace_ >= 5 )
508
+ lputs ();
509
+
506
510
os_printf (os,
507
511
" |%u| L:%u %s ptype:%s inDeg=%u outDeg=%u par=%u out:%s mog:%i/%i " ,
508
512
i, nd.lnum_ , nd.kw_ .c_str (), pts,
@@ -515,6 +519,18 @@ uint BLIF_file::printNodes(std::ostream& os) const noexcept {
515
519
size_t sz = nd.data_ .size ();
516
520
prnArray (os, A, sz, " " );
517
521
}
522
+
523
+ if (trace_ >= 5 ) {
524
+ const string* A = nd.inPins_ .data ();
525
+ size_t sz = nd.inPins_ .size ();
526
+ os_printf (os, " ##inPins=%zu " , sz);
527
+ prnArray (os, A, sz, " " );
528
+ //
529
+ A = nd.inSigs_ .data ();
530
+ sz = nd.inSigs_ .size ();
531
+ os_printf (os, " ##inSigs=%zu " , sz);
532
+ prnArray (os, A, sz, " " );
533
+ }
518
534
}
519
535
520
536
os << endl;
@@ -1002,7 +1018,7 @@ bool BLIF_file::createNodes() noexcept {
1002
1018
if (nd.data_ .size () > 1 ) {
1003
1019
const string& last = nd.data_ .back ();
1004
1020
size_t llen = last.length ();
1005
- if (!last.empty () && llen < 2047 ) {
1021
+ if (!last.empty () and llen < 2047 ) {
1006
1022
// replace '=' by 'space' and tokenize:
1007
1023
::strcpy (buf, last.c_str());
1008
1024
for (uint k = 0 ; k < llen; k++) {
@@ -1011,6 +1027,37 @@ bool BLIF_file::createNodes() noexcept {
1011
1027
Fio::split_spa (buf, V);
1012
1028
if (not V.empty ()) nd.out_ = V.back ();
1013
1029
}
1030
+ // lputs9();
1031
+ // fill inPins_, inSigs_:
1032
+ nd.inPins_ .clear ();
1033
+ nd.inSigs_ .clear ();
1034
+ const string* DA = nd.data_ .data ();
1035
+ size_t DA_sz = nd.data_ .size ();
1036
+ if (DA_sz > 2 and nd.kw_ == " .subckt" ) {
1037
+ // skip 1st (type) and last (output) terms in data_
1038
+ nd.inSigs_ .reserve (DA_sz - 1 );
1039
+ for (uint di = 1 ; di < DA_sz - 1 ; di++) {
1040
+ nd.inSigs_ .push_back (DA[di]);
1041
+ }
1042
+ }
1043
+ if (not nd.inSigs_ .empty ()) {
1044
+ std::sort (nd.inSigs_ .begin (), nd.inSigs_ .end ());
1045
+ pr_get_inputs (nd.ptype_ , nd.inPins_ );
1046
+ assert (nd.inPins_ .size () == nd.inSigs_ .size ());
1047
+ std::sort (nd.inPins_ .begin (), nd.inPins_ .end ());
1048
+ // strip everything before '=' in inSigs_, e.g. A[1]=sig_a --> sig_a
1049
+ for (string& ss : nd.inSigs_ ) {
1050
+ assert (!ss.empty ());
1051
+ V.clear ();
1052
+ ::strcpy (buf, ss.c_str());
1053
+ size_t len = ss.length ();
1054
+ for (uint k = 0 ; k < len; k++) {
1055
+ if (buf[k] == ' =' ) buf[k] = ' ' ;
1056
+ }
1057
+ Fio::split_spa (buf, V);
1058
+ if (not V.empty ()) ss = V.back ();
1059
+ }
1060
+ }
1014
1061
}
1015
1062
fabricNodes_.push_back (&nd);
1016
1063
continue ;
@@ -1149,8 +1196,8 @@ BLIF_file::Node* BLIF_file::findInputPort(const string& contact) noexcept {
1149
1196
}
1150
1197
1151
1198
// searches inputs
1152
- BLIF_file::Node* BLIF_file::findFabricParent (uint of, const string& contact, int & pinIndex ) noexcept {
1153
- pinIndex = -1 ;
1199
+ BLIF_file::Node* BLIF_file::findFabricParent (uint of, const string& contact, int & pin ) noexcept {
1200
+ pin = -1 ;
1154
1201
assert (not contact.empty ());
1155
1202
if (fabricNodes_.empty ()) return nullptr ;
1156
1203
@@ -1159,13 +1206,33 @@ BLIF_file::Node* BLIF_file::findFabricParent(uint of, const string& contact, int
1159
1206
if (x->id_ == of) continue ;
1160
1207
int pinIdx = x->in_contact (contact);
1161
1208
if (pinIdx >= 0 ) {
1162
- pinIndex = pinIdx;
1209
+ pin = pinIdx;
1163
1210
return x;
1164
1211
}
1165
1212
}
1166
1213
return nullptr ;
1167
1214
}
1168
1215
1216
+ void BLIF_file::getFabricParents (uint of, const string& contact, vector<upair>& PAR) noexcept {
1217
+ assert (not contact.empty ());
1218
+ if (fabricNodes_.empty ()) return ;
1219
+
1220
+ // TMP linear
1221
+ for (const Node* x : fabricNodes_) {
1222
+ if (x->id_ == of) continue ;
1223
+ const Node& nx = *x;
1224
+ if (nx.inSigs_ .empty ())
1225
+ continue ;
1226
+ size_t in_sz = nx.inSigs_ .size ();
1227
+ assert (nx.inPins_ .size () == in_sz);
1228
+ for (uint k = 0 ; k < in_sz; k++) {
1229
+ if (nx.inSigs_ [k] == contact) {
1230
+ PAR.emplace_back (nx.id_ , k);
1231
+ }
1232
+ }
1233
+ }
1234
+ }
1235
+
1169
1236
// matches out_
1170
1237
BLIF_file::Node* BLIF_file::findFabricDriver (uint of, const string& contact) noexcept {
1171
1238
assert (not contact.empty ());
@@ -1420,6 +1487,7 @@ bool BLIF_file::createPinGraph() noexcept {
1420
1487
uint64_t key = 0 ;
1421
1488
uint nid = 0 , kid = 0 , eid = 0 ;
1422
1489
vector<string> INP;
1490
+ vector<upair> PAR;
1423
1491
1424
1492
// -- create pg-nodes for topInputs_
1425
1493
for (const Node* p : topInputs_) {
@@ -1440,51 +1508,60 @@ bool BLIF_file::createPinGraph() noexcept {
1440
1508
}
1441
1509
1442
1510
// -- link from input ports to fabric
1443
- lputs9 ();
1511
+ // lputs9();
1444
1512
for (Node* p : topInputs_) {
1445
1513
INP.clear ();
1446
1514
Node& port = *p;
1447
1515
assert (!port.out_ .empty ());
1448
1516
1517
+ PAR.clear ();
1518
+ getFabricParents (port.id_ , port.out_ , PAR);
1519
+
1449
1520
if (trace_ >= 5 ) {
1450
- lprintf (" TopInput: lnum_= %u %s\n " ,
1451
- port.lnum_ , port.out_ .c_str ());
1521
+ lputs ();
1522
+ lprintf (" TopInput: lnum_= %u %s PAR.size()= %zu\n " ,
1523
+ port.lnum_ , port.out_ .c_str (), PAR.size ());
1452
1524
}
1453
1525
1454
- int pinIndex = -1 ;
1455
- Node* par = findFabricParent (port.id_ , port.out_ , pinIndex);
1456
- if (!par) {
1457
- continue ;
1458
- }
1526
+ for (const upair& pa : PAR) {
1527
+ const Node& par = nodeRef (pa.first );
1528
+ uint pinIndex = pa.second ;
1459
1529
1460
- pr_get_inputs (par->ptype_ , INP);
1530
+ INP.clear ();
1531
+ pr_get_inputs (par.ptype_ , INP);
1461
1532
1462
- if (trace_ >= 5 ) {
1463
- lprintf (" FabricParent par: lnum_= %u kw_= %s ptype_= %s #inputs= %u\n " ,
1464
- par-> lnum_ , par-> kw_ .c_str (), par-> cPrimType (),
1465
- pr_num_inputs (par-> ptype_ ));
1466
- logVec (INP, " [par_inputs] " );
1467
- lputs ();
1468
- }
1533
+ if (trace_ >= 5 ) {
1534
+ lprintf (" FabricParent par: lnum_= %u kw_= %s ptype_= %s #inputs= %u\n " ,
1535
+ par. lnum_ , par. kw_ .c_str (), par. cPrimType (),
1536
+ pr_num_inputs (par. ptype_ ));
1537
+ logVec (INP, " [par_inputs] " );
1538
+ lputs ();
1539
+ }
1469
1540
1470
- assert (par-> cell_hc_ );
1471
- key = hashComb (par-> cell_hc_ , pinIndex);
1472
- assert (key);
1473
- kid = pg_.insK (key);
1474
- assert (kid);
1541
+ assert (par. cell_hc_ );
1542
+ key = hashComb (par. cell_hc_ , pinIndex);
1543
+ assert (key);
1544
+ kid = pg_.insK (key);
1545
+ assert (kid);
1475
1546
1476
- eid = pg_.linK (port.id_ , kid);
1477
- assert (eid);
1547
+ eid = pg_.linK (port.id_ , kid);
1548
+ assert (eid);
1549
+ }
1478
1550
}
1479
1551
1480
1552
if (1 ) {
1481
1553
1554
+ pg_.setNwName (" pin_graph" );
1482
1555
pg_.dump (" \t *** pg_ separ ***" );
1483
1556
lprintf (" \t pg_. numN()= %u numE()= %u\n " , pg_.numN (), pg_.numE ());
1484
1557
lputs ();
1485
1558
pg_.printSum (ls, 0 );
1486
1559
lputs ();
1487
1560
pg_.dumpEdges (" |edges|" );
1561
+ lputs ();
1562
+
1563
+ bool wrDot_ok = pg_.writeDot (" pinGraph.dot" , nullptr , true );
1564
+ lprintf (" wrDot_ok:%i\n " , wrDot_ok);
1488
1565
1489
1566
}
1490
1567
0 commit comments