Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions v93k/src/origen/origen/helpers.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,9 @@ int numberOfZeros(uint32_t);
int64_t toInt (string, int = 0);
uint64_t toUInt (string, int = 0);
vector<string> split(const string&, char);
void logString(string testname, int testnr, string stringToLog);
void tokenize( vector<string> & strVector, const string & string1, const string & delimiters);
string getModelfileValue(string env_var, string default_name);
void split(const string&, char, vector<string>&);
string toHex (const uint64_t&);
string toStr (const uint64_t&);
Expand Down
66 changes: 66 additions & 0 deletions v93k/src/origen/origen/helpers/misc.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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<char*>(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
///
Expand All @@ -29,6 +72,29 @@ vector<string> 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<string> & 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<string> &elems) {
stringstream ss;
Expand Down
12 changes: 6 additions & 6 deletions v93k/src/origen/origen/site.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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<char*>("LOT_ID"), value)) {
_lotid = (string) value;
} else {
_lotid = "Undefined";
string WId = getModelfileValue("WAFER_ID", "wafer_id");
if (WId.empty()) {
WId = "UNDEF-W01AA";
}
vector <string> list;
tokenize(list, WId, "-wW");
_lotid = list.at(0);
lotidSet = true;
}
return _lotid;
Expand Down