@@ -78,11 +78,17 @@ static inline bool ends_with_gpio(const char* z, size_t len) noexcept {
78
78
79
79
static inline bool starts_with_A2F (const char * z) noexcept {
80
80
assert (z);
81
+ if (!z[0 ])
82
+ return false ;
83
+ assert (::strlen (z) >= 3 );
81
84
return z[0 ] == ' A' and z[1 ] == ' 2' and z[2 ] == ' F' ;
82
85
}
83
86
84
87
static inline bool starts_with_F2A (const char * z) noexcept {
85
88
assert (z);
89
+ if (!z[0 ])
90
+ return false ;
91
+ assert (::strlen (z) >= 3 );
86
92
return z[0 ] == ' F' and z[1 ] == ' 2' and z[2 ] == ' A' ;
87
93
}
88
94
@@ -160,9 +166,9 @@ Pin* RapidCsvReader::BCD::annotatePin(const string& udes_pn,
160
166
161
167
const char * RapidCsvReader::str_Mode_dir (BCD::ModeDir t) noexcept {
162
168
// enum ModeDir
163
- // { No_dir, Input_dir, Output_dir, HasBoth_dir, AllEnabled_dir };
169
+ // { No_dir, Input_dir, Output_dir, HasBoth_dir, AllEnabled_dir };
164
170
static const char * enumS[] =
165
- { " No_dir" , " Input_dir" , " Output_dir" , " HasBoth_dir" , " AllEnabled_dir" };
171
+ { " No_dir" , " Input_dir" , " Output_dir" , " HasBoth_dir" , " AllEnabled_dir" };
166
172
constexpr size_t n = sizeof (enumS) / sizeof (enumS[0 ]);
167
173
static_assert (n == BCD::AllEnabled_dir + 1 );
168
174
uint i = uint (t);
@@ -172,7 +178,7 @@ const char* RapidCsvReader::str_Mode_dir(BCD::ModeDir t) noexcept {
172
178
173
179
std::ostream& operator <<(std::ostream& os, const RapidCsvReader::BCD& b) {
174
180
os << " (bcd-" << b.row_ << ' '
175
- << " grp:" << b.groupA_ << " " << b.bump_ << " " << b.customer_ << " "
181
+ << " grp:" << b.groupA_ << " " << b.bump_B_ << " " << b.customer_ << " "
176
182
<< b.ball_ID_ << " ITP: " << b.IO_tile_pin_ << " XYZ: " << b.xyz_
177
183
<< " colM:" << b.col_M_ << " fc:" << b.fullchipName_
178
184
<< " ci:" << b.customerInternal () << " axi:" << int (b.is_axi_ )
@@ -218,7 +224,7 @@ string RapidCsvReader::Tile::key2() const noexcept {
218
224
}
219
225
220
226
// returns spreadsheet column label ("A", "B", "BC", etc) for column index 'i'
221
- static inline string label_column (int i) noexcept {
227
+ string RapidCsvReader::label_of_column (int i) noexcept {
222
228
assert (i >= 0 && i < 1000 );
223
229
string label;
224
230
@@ -277,7 +283,10 @@ static bool get_row_modes(const fio::CSV_Reader& crd, uint rowNum,
277
283
278
284
const string* R = crd.getRow (rowNum);
279
285
if (!R) {
280
- lout () << " \n ERROR reading csv: failed row: " << rowNum << endl;
286
+ flush_out (true );
287
+ err_puts ();
288
+ lprintf2 (" [Error] pin_c: ERROR reading csv: failed row: %u\n " , rowNum+2 );
289
+ flush_out (true );
281
290
return false ;
282
291
}
283
292
@@ -293,7 +302,7 @@ static bool get_row_modes(const fio::CSV_Reader& crd, uint rowNum,
293
302
}
294
303
295
304
if (ltrace () >= 8 ) {
296
- lout () << " ROW-" << rowNum;
305
+ lout () << " ROW-" << rowNum+ 2 ;
297
306
for (uint c = 0 ; c < nc; c++) lout () << " | " << R[c];
298
307
lputs (" |" );
299
308
}
@@ -344,7 +353,7 @@ bool RapidCsvReader::initCols(const fio::CSV_Reader& crd) {
344
353
<< col_headers_.front () << " ... " << col_headers_.back () << ' ]' << endl;
345
354
if (tr >= 5 ) {
346
355
for (uint i = 0 ; i < nc; i++) {
347
- string col_label = label_column (i);
356
+ string col_label = label_of_column (i);
348
357
const string& hdr_i = col_headers_[i];
349
358
ls << " --- " << i << ' -' << col_label << " hdr_i= " << hdr_i << endl;
350
359
}
@@ -582,14 +591,14 @@ bool RapidCsvReader::createTiles(bool uniq_XY) {
582
591
// 2. add tiles_ avoiding duplicates if possible
583
592
tPool.emplace_back (bcd_good_[first_valid_k]->xyz_ ,
584
593
bcd_good_[first_valid_k]->groupA_ ,
585
- bcd_good_[first_valid_k]->bump_ ,
594
+ bcd_good_[first_valid_k]->bump_B_ ,
586
595
first_valid_k);
587
596
for (uint k = first_valid_k + 1 ; k < sz_bcd_good; k++) {
588
597
const BCD& bcd = *bcd_good_[k];
589
598
const XY& loc = bcd.xyz_ ;
590
- if (tPool.back ().eq (loc, bcd.bump_ ))
599
+ if (tPool.back ().eq (loc, bcd.bump_B_ ))
591
600
continue ;
592
- tPool.emplace_back (loc, bcd.groupA_ , bcd.bump_ , k);
601
+ tPool.emplace_back (loc, bcd.groupA_ , bcd.bump_B_ , k);
593
602
}
594
603
595
604
uint sz = tPool.size ();
@@ -885,7 +894,7 @@ bool RapidCsvReader::read_csv(const string& fn, uint num_udes_pins) {
885
894
mode_names_.reserve (col_headers_.size ());
886
895
start_MODE_col_ = 0 ;
887
896
for (uint col = 0 ; col < col_headers_.size (); col++) {
888
- string col_label = label_column (col);
897
+ string col_label = label_of_column (col);
889
898
const string& orig_hdr_i = col_headers_[col]; // before case conversion
890
899
hdr_i = orig_hdr_i;
891
900
@@ -1114,15 +1123,15 @@ bool RapidCsvReader::read_csv(const string& fn, uint num_udes_pins) {
1114
1123
1115
1124
for (uint i = 0 ; i < num_rows; i++) {
1116
1125
BCD& bcd = *bcd_[i];
1117
- bcd.bump_ = bump_pin_name[i];
1118
- if (bcd.bump_ .empty ()) {
1126
+ bcd.bump_B_ = bump_pin_name[i];
1127
+ if (bcd.bump_B_ .empty ()) {
1119
1128
if (bcd.customerInternal ().empty () && tr >= 4 ) {
1120
- lprintf (" (WW) both bcd.bump_ and bcd.customerInternal_ are empty on row# %u\n " , i);
1129
+ lprintf (" (WW) both bcd.bump_B_ and bcd.customerInternal_ are empty on row# %u\n " , i);
1121
1130
// assert(0);
1122
1131
}
1123
1132
}
1124
1133
bcd.normalize ();
1125
- // assert(!bcd.bump_ .empty()); // no-assert, could be clock: colM = F2CLK
1134
+ // assert(!bcd.bump_B_ .empty()); // no-assert, could be clock: colM = F2CLK
1126
1135
}
1127
1136
1128
1137
flush_out (false );
@@ -1225,15 +1234,25 @@ bool RapidCsvReader::read_csv(const string& fn, uint num_udes_pins) {
1225
1234
}
1226
1235
}
1227
1236
1237
+ bool always_print = ::getenv (" pinc_always_print_csv" );
1238
+ bool write_debug = (tr >= 8 or ::getenv (" pinc_write_debug_csv" ));
1239
+
1228
1240
if (tr >= 6 ) {
1229
1241
flush_out (false );
1230
1242
print_bcd_stats (lout ());
1231
1243
flush_out (true );
1232
1244
print_axi_bcd (lout ());
1233
1245
flush_out (false );
1234
- print_csv ();
1246
+ if (tr >= 7 or always_print) {
1247
+ print_csv ();
1248
+ }
1249
+ } else if (always_print) {
1250
+ print_csv ();
1235
1251
}
1236
1252
1253
+ if (write_debug)
1254
+ write_debug_csv ();
1255
+
1237
1256
flush_out (false );
1238
1257
return true ;
1239
1258
}
@@ -1336,13 +1355,15 @@ uint RapidCsvReader::print_axi_bcd(std::ostream& os) const noexcept {
1336
1355
}
1337
1356
1338
1357
void RapidCsvReader::print_csv () const {
1339
- flush_out (false );
1358
+ flush_out (true );
1340
1359
lputs (" print_csv()" );
1341
1360
auto & ls = lout ();
1342
1361
ls << " #row\t Bump/Pin Name \t Customer Name \t Ball ID "
1343
- << " \t IO_tile_pin\t IO_tile_pin_x\t IO_tile_pin_y\t IO_tile_pin_z"
1362
+ << " IO_tile_pin\t X Y Z"
1363
+ << " \t column-M"
1364
+ << " rxtx_dir"
1344
1365
<< " \t Customer Internal Name" << endl;
1345
- string dash = str::sReplicate (' -' , 139u );
1366
+ string dash = str::sReplicate (' -' , 131u );
1346
1367
ls << dash << endl;
1347
1368
1348
1369
uint num_rows = numRows ();
@@ -1351,17 +1372,93 @@ void RapidCsvReader::print_csv() const {
1351
1372
const BCD& b = *bcd_[i];
1352
1373
const XYZ& p = b.xyz_ ;
1353
1374
lprintf (" %-5u " , i + 2 );
1354
- lprintf (" %12s " , b.bump_ .c_str ());
1375
+ lprintf (" %12s " , b.bump_B_ .c_str ());
1355
1376
lprintf (" %22s " , b.customer_ .c_str ());
1356
1377
lprintf (" %6s " , b.ball_ID_ .c_str ());
1357
1378
ls << " \t " << b.IO_tile_pin_ << " \t " << p.x_ << " " << p.y_ << " "
1358
- << p.z_ ;
1379
+ << p.z_ << " " ;
1380
+ lprintf (" %10s " , b.col_M_ .c_str ());
1381
+ lprintf (" %16s " , str_Mode_dir (b.rxtx_dir_ ));
1382
+ if (b.dirContradiction ()) {
1383
+ ls << " DIR_CONTRADICTION " ;
1384
+ }
1359
1385
lprintf (" %22s " , b.customerInternal ().c_str ());
1360
1386
ls << endl;
1361
1387
}
1362
1388
1363
1389
ls << dash << endl;
1364
- ls << " Total Records: " << num_rows << endl;
1390
+ lprintf (" Total Records: %u\n " , num_rows);
1391
+ flush_out (true );
1392
+ }
1393
+
1394
+ void RapidCsvReader::write_debug_csv () const {
1395
+ flush_out (true );
1396
+ string cwd = get_CWD ();
1397
+ lprintf (" write_debug_csv() in work_dir = %s\n " , cwd.c_str ());
1398
+
1399
+ CStr fn = " DEBUG_PINC_PT.csv" ;
1400
+ std::ofstream fos (fn);
1401
+ if (not fos.is_open ()) {
1402
+ flush_out (true );
1403
+ lprintf2 (" ERROR write_debug_csv() could not open file for writing: %s\n " , fn);
1404
+ flush_out (true );
1405
+ return ;
1406
+ }
1407
+
1408
+ lprintf (" writing %s ...\n " , fn);
1409
+
1410
+ fos << " #row\t Bump/Pin Name \t Customer Name \t Ball ID "
1411
+ << " IO_tile_pin\t X Y Z"
1412
+ << " \t column-M"
1413
+ << " rxtx_dir"
1414
+ << " \t Customer Internal Name" << endl;
1415
+ string dash = str::sReplicate (' -' , 131u );
1416
+ fos << dash << endl;
1417
+
1418
+ uint num_rows = numRows ();
1419
+ assert (bcd_.size () == num_rows);
1420
+ for (uint i = 0 ; i < num_rows; i++) {
1421
+ const BCD& b = *bcd_[i];
1422
+ const XYZ& p = b.xyz_ ;
1423
+ os_printf (fos, " %-5u " , i + 2 );
1424
+ os_printf (fos, " %12s " , b.bump_B_ .c_str ());
1425
+ os_printf (fos, " %22s " , b.customer_ .c_str ());
1426
+ os_printf (fos, " %6s " , b.ball_ID_ .c_str ());
1427
+ fos << " \t " << b.IO_tile_pin_ << " \t " << p.x_ << " " << p.y_ << " "
1428
+ << p.z_ << " " ;
1429
+ os_printf (fos, " %10s " , b.col_M_ .c_str ());
1430
+ os_printf (fos, " %16s " , str_Mode_dir (b.rxtx_dir_ ));
1431
+ if (b.dirContradiction ()) {
1432
+ os_printf (fos, " DIR_CONTRADICTION " );
1433
+ }
1434
+ os_printf (fos, " %22s " , b.customerInternal ().c_str ());
1435
+ fos << endl;
1436
+ }
1437
+
1438
+ fos << dash << endl;
1439
+
1440
+ lprintf (" wrote %s\n " , fn);
1441
+ flush_out (true );
1442
+ }
1443
+
1444
+ vector<uint> RapidCsvReader::get_enabled_rows_for_mode (const string& mode) const noexcept {
1445
+ if (mode.empty ())
1446
+ return {};
1447
+ uint col_idx = getModeCol (mode);
1448
+ if (!col_idx)
1449
+ return {};
1450
+ vector<string> col = crd_->getColumn (mode);
1451
+ if (col.empty ())
1452
+ return {};
1453
+
1454
+ vector<uint> result;
1455
+ result.reserve (col.size ());
1456
+ for (uint r = 0 ; r < col.size (); r++) {
1457
+ if (col[r] == " Y" )
1458
+ result.push_back (r);
1459
+ }
1460
+
1461
+ return result;
1365
1462
}
1366
1463
1367
1464
XYZ RapidCsvReader::get_axi_xyz_by_name (const string& axi_name,
@@ -1589,7 +1686,7 @@ string RapidCsvReader::bumpName2CustomerName(
1589
1686
// tmp linear search
1590
1687
for (uint i = 0 ; i < num_rows; i++) {
1591
1688
const BCD& bcd = *bcd_[i];
1592
- if (bcd.bump_ == bump_nm) return bcd.customer_ ;
1689
+ if (bcd.bump_B_ == bump_nm) return bcd.customer_ ;
1593
1690
}
1594
1691
1595
1692
return {};
0 commit comments