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..dbbe55e 100644 --- a/v93k/src/origen/origen/helpers/misc.cpp +++ b/v93k/src/origen/origen/helpers/misc.cpp @@ -19,6 +19,49 @@ 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()); +} + +// 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 +72,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;