From 76c27be30b07f93e2854a21f2bd49c85bdd70c90 Mon Sep 17 00:00:00 2001 From: Dennis Dieleman-nxa26780 Date: Tue, 5 Dec 2017 14:10:01 +0100 Subject: [PATCH 1/2] Using wafer_id instead of lot_id and splitting on -, w, and W for batchnr. Also added a method to log a string to stdf --- v93k/src/origen/origen/helpers.hpp | 3 + v93k/src/origen/origen/helpers/misc.cpp | 82 +++++++++++++++++++++++++ v93k/src/origen/origen/site.cpp | 12 ++-- 3 files changed, 91 insertions(+), 6 deletions(-) diff --git a/v93k/src/origen/origen/helpers.hpp b/v93k/src/origen/origen/helpers.hpp index dc583d8..4c5a58a 100644 --- a/v93k/src/origen/origen/helpers.hpp +++ b/v93k/src/origen/origen/helpers.hpp @@ -20,6 +20,9 @@ int numberOfZeros(uint32_t); int64_t toInt (string, int = 0); uint64_t toUInt (string, int = 0); vector split(const string&, char); +void logString(string testname, int testnr, string stringToLog); +void tokenize( vector & strVector, const string & string1, const string & delimiters); +string getModelfileValue(string env_var, string default_name); void split(const string&, char, vector&); string toHex (const uint64_t&); string toStr (const uint64_t&); diff --git a/v93k/src/origen/origen/helpers/misc.cpp b/v93k/src/origen/origen/helpers/misc.cpp index cb41bdb..ac0af25 100644 --- a/v93k/src/origen/origen/helpers/misc.cpp +++ b/v93k/src/origen/origen/helpers/misc.cpp @@ -19,6 +19,65 @@ uint64_t flip(uint64_t input, int size) { return output; } +// Log string to stdf +void logString(string testname, int testnr, string stringToLog) { + stringstream dtr_text; + dtr_text << "STRRES " << CURRENT_SITE_NUMBER() << " pin " << testnr << " (" << testname << ") = (" << stringToLog << ") ()"; + PUT_DATALOG(dtr_text.str()); +} + +void tokenize( vector & strVector, const string & string1, const string & delimiters) +{ + size_t start = 0, end = 0; + + while ( end != string::npos) { + end = string1.find_first_of( delimiters, start); + // If at end, use length=maxLength. Else use length=end-start. + strVector.push_back( string1.substr( start, + (end == string::npos) ? string::npos : end - start)); + + // If at end, use start=maxSize. Else use start=end+delimiter. + start = ( ( end > (string::npos - delimiters.size()) ) + ? string::npos : end + delimiters.size()); + } +}; + +// get_modelfile_value +// returns the value of e.g. lot_id, as it is defined in the modelfile +// if no value is found in the modelfile, an empty string is returned +// if required, error handling has to be done by caller!!! +string getModelfileValue(string env_var, string default_name) { + string rValue; + + // retrieve value of unix environment variable with the name env_var; + stringstream ss; + string name; + ss << getenv(env_var.c_str()); + ss >> name; + + // if not set, than use the default name + if (name.empty()) { + name = default_name; + } + + // now retrieve value from application model file + char value[CI_CPI_MAX_MODL_STRING_LEN * 2]; + + long ret = GetModelfileString(const_cast(name.c_str()), value); + switch (ret) { + case 0: // OK + rValue = value; + break; + case 1: // Error on name + rValue = ""; + break; + default: + Error error("getModelFileString", + "internal Error occurred, while retrieving modelfile value"); + throw error; + } + return rValue; +} /// Split the given string by the given delimiter and return the results in a vector of strings /// @@ -29,6 +88,29 @@ vector split(const string &str, char delim) { return elems; } +/** + * splits up a given string in substrings, where substrings are found through given delimter characters + * + * @param[out] strVector vector of substrings + * @param[in] string string to tokenize + * @param[in] "list" of delimiter characters + */ +void tokenize( vector & strVector, const string & string1, const string & delimiters) +{ + size_t start = 0, end = 0; + + while ( end != string::npos) { + end = string1.find_first_of( delimiters, start); + // If at end, use length=maxLength. Else use length=end-start. + strVector.push_back( string1.substr( start, + (end == string::npos) ? string::npos : end - start)); + + // If at end, use start=maxSize. Else use start=end+delimiter. + start = ( ( end > (string::npos - delimiters.size()) ) + ? string::npos : end + delimiters.size()); + } +}; + /// This version places the result in the supplied vector rather than returning a new one void split(const string &str, char delim, vector &elems) { stringstream ss; diff --git a/v93k/src/origen/origen/site.cpp b/v93k/src/origen/origen/site.cpp index c7b8e4f..c423006 100644 --- a/v93k/src/origen/origen/site.cpp +++ b/v93k/src/origen/origen/site.cpp @@ -38,16 +38,16 @@ void Site::lotid(uint64_t val) { lotid(id); } - /// Get the lot ID. If it has not previously been set to a value it will be automatically queried from the test system. string Site::lotid() { if (!lotidSet) { - char value[CI_CPI_MAX_MODL_STRING_LEN * 2]; - if (!GetModelfileString(const_cast("LOT_ID"), value)) { - _lotid = (string) value; - } else { - _lotid = "Undefined"; + string WId = getModelfileValue("WAFER_ID", "wafer_id"); + if (WId.empty()) { + WId = "UNDEF-W01AA"; } + vector list; + tokenize(list, WId, "-wW"); + _lotid = list.at(0); lotidSet = true; } return _lotid; From 56ade11beb05b0f1ce08e329c20a296ebcfc448f Mon Sep 17 00:00:00 2001 From: Dennis Dieleman-nxa26780 Date: Tue, 5 Dec 2017 14:20:12 +0100 Subject: [PATCH 2/2] Fixing previous commit --- v93k/src/origen/origen/helpers/misc.cpp | 16 ---------------- 1 file changed, 16 deletions(-) diff --git a/v93k/src/origen/origen/helpers/misc.cpp b/v93k/src/origen/origen/helpers/misc.cpp index ac0af25..dbbe55e 100644 --- a/v93k/src/origen/origen/helpers/misc.cpp +++ b/v93k/src/origen/origen/helpers/misc.cpp @@ -26,22 +26,6 @@ void logString(string testname, int testnr, string stringToLog) { PUT_DATALOG(dtr_text.str()); } -void tokenize( vector & strVector, const string & string1, const string & delimiters) -{ - size_t start = 0, end = 0; - - while ( end != string::npos) { - end = string1.find_first_of( delimiters, start); - // If at end, use length=maxLength. Else use length=end-start. - strVector.push_back( string1.substr( start, - (end == string::npos) ? string::npos : end - start)); - - // If at end, use start=maxSize. Else use start=end+delimiter. - start = ( ( end > (string::npos - delimiters.size()) ) - ? string::npos : end + delimiters.size()); - } -}; - // get_modelfile_value // returns the value of e.g. lot_id, as it is defined in the modelfile // if no value is found in the modelfile, an empty string is returned