/* g++ mklist.C -o mklist.exe */ #include #include #include #include #include #include #include #include #include using namespace std; int main() { const int debug = 0; const char *listname="resultlist_all.txt"; // all tests const char *listnameSelected="resultlist_orig.txt"; // in selected timespan const int kMaxWafer = 29; // 11..27 = V4, 28..29 = V5 const int kMinWafer = 28; const int kNWafer = kMaxWafer - kMinWafer + 1; const int kMaxChipsPerWafer = 10000; const int kMaxRCode = 9; int waferCount[kNWafer][kMaxRCode] = {0}; const int kMaxChips = kNWafer * kMaxChipsPerWafer; const int kFirstChip = kMinWafer*kMaxChipsPerWafer; const int kLastChip = (kMaxWafer+1)*kMaxChipsPerWafer - 1; const int kNErrBits = 15; // check for 15 different errors const char *kBitStr[] = { "FileCount", "VRef", "ACurr", "Sync", // 0x1, 0x2, 0x4, 0x8 "PedAna", "RmsAna", "Gain", "RiseTime", // 0x10, 0x20, 0x40, 0x80 "Xtalk", "RingOsc", "i2c", "Jtag", // 0x100, 0x200, 0x400, 0x800 "Mem", "DFT", "BitCheck" // 0x1000, 0x2000, 0x4000 }; const int kFirstErrBit = 2; const int kFirstErrBitVal = 2; int nTestsChip[kMaxChips] = {0}; int nTestsChipSelected[kMaxChips] = {0}; int nTestsChipSelectedGood[kMaxChips] = {0}; int nTestsChipSelectedBad[kMaxChips] = {0}; int errcodeSelectedBad[kMaxChips] = {0}; string lastFile[kMaxChips]; string lastFileSelected[kMaxChips]; string lastFileSelectedGood[kMaxChips]; string lastFileSelectedBad[kMaxChips]; int trayChip[kMaxChips] = {0}; int minChip = 999999; int maxChip = 0; const int kMaxTrays = 1000; int trayCount[kMaxTrays][kMaxRCode] = {0}; ifstream flist(listname); if (!flist) { cerr << " - can't open flist for input" << endl; return 1; } ifstream flistSelected(listnameSelected); if (!flistSelected) { cerr << " - can't open flistSelected for input" << endl; return 1; } int nfiles = 0; const int kMaxLengthLine = 1000; const int kMaxLengthSAMPA = 67; // SAMPA result*log file format char filename[kMaxLengthSAMPA]; char lineStr[kMaxLengthLine]; int nchips = 0; int ista = 0; int idate = 0; int itime = 0; int chipnum = 0; int ichip = 0; // index for (ichip = 0; ichip dates; while ( flist.good() ) { flist >> filename; if (! flist.good() ) { break; } if (debug>1) cout << " nfiles " << nfiles << " filename " << filename << endl; nfiles++; // split string in directory substrings stringstream ss( filename ); vector result; int nresult = 0; while( ss.good() ) { string substr; getline( ss, substr, '/' ); result.push_back( substr ); nresult++; } idate = atoi ( result[4].c_str() ); if (debug>1) cout << " idate " << idate << endl; if (debug>1) cout << " nresult " << nresult << " last-result " << result[nresult-1] << endl; dates.push_back(idate); // let's get the parts of the strings we need string str (result[nresult-1]); string strChip = str.substr(6,6); chipnum = atoi(strChip.c_str()); if ( (chipnum >= kFirstChip) && (chipnum <= kLastChip) ) { ichip = chipnum - kFirstChip; if (debug>1) cout << " strChip " << strChip << " chipnum " << chipnum << " ichip " << ichip << endl; /* // 2nd string for date and station info string str2 (result[nresult-2]); string strTime = str2.substr(0,6); itime = atoi(strTime.c_str()); if (debug>1) cout << " itime " << itime << endl; string strSta = str2.substr(10,1); ista = atoi(strSta.c_str()); if (debug>1) cout << " ista " << ista << endl; */ nTestsChip[ichip]++; lastFile[ichip] = filename; if (minChip > ichip) minChip = ichip; if (maxChip < ichip) maxChip = ichip; } nfiles++; } // flist flist.close(); // Selected file int nfilesSelected = 0; while ( flistSelected.good() ) { flistSelected >> filename; if (! flistSelected.good() ) { break; } if (debug>1) cout << " nfilesSelected " << nfilesSelected << " filename " << filename << endl; nfilesSelected++; // split string in directory substrings stringstream ss( filename ); vector result; int nresult = 0; while( ss.good() ) { string substr; getline( ss, substr, '/' ); result.push_back( substr ); nresult++; } if (debug>1) cout << " nresult " << nresult << " last-result " << result[nresult-1] << endl; // let's get the parts of the strings we need string str (result[nresult-1]); string strChip = str.substr(6,6); chipnum = atoi(strChip.c_str()); if ( (chipnum >= kFirstChip) && (chipnum <= kLastChip) ) { ichip = chipnum - kFirstChip; if (debug>1) cout << " selected strChip " << strChip << " chipnum " << chipnum << " ichip " << ichip << endl; nTestsChipSelected[ichip]++; lastFileSelected[ichip] = filename; // good and bad counters and filenames ifstream fin(filename); if (!fin) { cerr << __LINE__ << " - can't open file " << filename << " for input" << endl; return 1; } char lineCopy[kMaxLengthLine]; char lineCopy2[kMaxLengthLine]; int nlines = 0; while (fin.good()) { fin.getline(lineStr, kMaxLengthLine); if (!fin.good()) break; if (nlines > 1) sprintf(lineCopy2, "%s", lineCopy); sprintf(lineCopy, "%s", lineStr); nlines++; } fin.close(); string strLast( lineCopy ); string strCode = strLast.substr(6,1); if (debug > 1) { cout << " strLast " << strLast << endl; cout << " strCode " << strCode << endl; } icode = atoi ( strCode.c_str() ); if (icode == 0) { // good nTestsChipSelectedGood[ichip]++; lastFileSelectedGood[ichip] = filename; } else { // bad nTestsChipSelectedBad[ichip]++; lastFileSelectedBad[ichip] = filename; char * pch; pch = strtok (lineCopy2, " ,.-"); pch = strtok (NULL, " ,.-"); errcode = strtol(pch, NULL, 16); // printf ("pch %s errcode %d\n",pch, errcode); errcodeSelectedBad[ichip] = errcode; } } nfilesSelected++; } // flistSelected flistSelected.close(); // GET TRAY,COL,ROW POS INFO ifstream fChipPos("chipsQR.out"); int nchipsQR = 0; int minTray = kMaxTrays; int maxTray = 0; while ( fChipPos.good() ) { fChipPos >> itray >> icol >> irow >> chipnum; if (! fChipPos.good() ) { break; } if ( (chipnum >= kFirstChip) && (chipnum <= kLastChip) ) { ichip = chipnum - kFirstChip; trayChip[ichip] = itray; if (minTray > itray) minTray = itray; if (maxTray < itray) maxTray = itray; if (debug>1) cout << " nchipsQR " << nchipsQR << " ichip " << ichip << " itray " << itray << endl; } nchipsQR++; } fChipPos.close(); // report the results, get status of the last file/test in selected time ofstream fout("filelist_last.txt"); ofstream foutSelected("filelist_last_selected.txt"); ofstream foutSelectedGoodBad("filelist_last_selected_good_and_bad.txt"); for (ichip = minChip; ichip<=maxChip; ichip++) { if (nTestsChip[ichip] > 0) { ifstream fin(lastFile[ichip].c_str()); if (!fin) { cerr << __LINE__ << " - can't open file " << lastFile[ichip].c_str() << " for input" << endl; return 1; } char lineCopy[kMaxLengthLine]; while (fin.good()) { fin.getline(lineStr, kMaxLengthLine); if (!fin.good()) break; sprintf(lineCopy, "%s", lineStr); } fin.close(); string strLast( lineCopy ); string strCode = strLast.substr(6,1); if (debug > 1) { cout << " strLast " << strLast << endl; cout << " strCode " << strCode << endl; } icode = atoi ( strCode.c_str() ); itray = trayChip[ichip]; trayCount[itray][icode]++; chipnum = ichip + kFirstChip; iwafer = chipnum / 10000; // 10000 = # chips per wafer-lot (max) waferCount[iwafer][icode]++; fout << nTestsChip[ichip] << " " << trayChip[ichip] << " " << icode << " " << lastFile[ichip] << endl; if (nTestsChipSelected[ichip] > 0) { // report on last file in selected range foutSelected << nTestsChipSelected[ichip] << " " << trayChip[ichip] << " " << icode << " " << lastFileSelected[ichip] << endl; if ( (nTestsChipSelectedGood[ichip] > 0) && (nTestsChipSelectedBad[ichip] > 0) ) { errcode = errcodeSelectedBad[ichip]; foutSelectedGoodBad << nTestsChipSelectedGood[ichip] << " " << lastFileSelectedGood[ichip] << " " << nTestsChipSelectedBad[ichip] << " " << lastFileSelectedBad[ichip] << " 0x" << hex << errcode << dec << " : "; for (int ibit=kFirstErrBit; ibit 0 ) { foutSelectedGoodBad << kBitStr[ibit] << " "; } } foutSelectedGoodBad << endl; } } } } fout.close(); foutSelected.close(); foutSelectedGoodBad.close(); // detailed statistics // tray ofstream foutTray("tray_stats.log"); foutTray << "Tray nTot nOK nB2 nC1 nC2" << endl; for (itray = minTray; itray<=maxTray; itray++) { int nSum = trayCount[itray][0] + trayCount[itray][2] + trayCount[itray][5] + trayCount[itray][6]; if (nSum > 0) { sprintf(lineStr, " %3d %3d %3d %3d %3d %3d", itray, nSum, trayCount[itray][0], trayCount[itray][2], trayCount[itray][5], trayCount[itray][6] ); foutTray << lineStr << endl; } } foutTray.close(); // wafer double yield = 0; double yieldOpt = 0; ofstream foutWafer("wafer_stats.log"); foutWafer << "WaferLot nTot nOK nB2 nC1 nC2 yield yieldOpt" << endl; for (iwafer = kMinWafer; iwafer<=kMaxWafer; iwafer++) { int nSum = waferCount[iwafer][0] + waferCount[iwafer][2] + waferCount[iwafer][5] + waferCount[iwafer][6]; if (nSum>0) { yield = (100.0*waferCount[iwafer][0])/nSum; yieldOpt = 100.0*(nSum - waferCount[iwafer][2])/nSum; sprintf(lineStr, " %4d %4d %4d %4d %4d %4d %4.1f%% %4.1f%%", iwafer, nSum, waferCount[iwafer][0], waferCount[iwafer][2], waferCount[iwafer][5], waferCount[iwafer][6], yield, yieldOpt ); foutWafer << lineStr << endl; } } foutWafer << "[yield=nOK/nTot yieldOpt=(nTot-nB2)/nTot]" << endl; foutWafer.close(); // date info ofstream foutDate("date_stats.log"); ifstream finDate("dates.txt"); while ( finDate.good() ) { finDate >> idate; if (! finDate.good() ) { break; } int mycount = std::count (dates.begin(), dates.end(), idate); sprintf(lineStr, "%d : %4d tests", idate, mycount); foutDate << lineStr << endl; } finDate.close(); foutDate.close(); return 0; }