Verilated headers no longer "use namespace std;"
This commit is contained in:
parent
5d3fef21b0
commit
c2e8062f84
3
Changes
3
Changes
|
|
@ -4,6 +4,9 @@ The contributors that suggested a given feature are shown in []. Thanks!
|
||||||
|
|
||||||
* Verilator 3.911 devel
|
* Verilator 3.911 devel
|
||||||
|
|
||||||
|
** Verilated headers no longer "use namespace std;"
|
||||||
|
User's code without "std::" prefixes may need "use namespace std;" to compile.
|
||||||
|
|
||||||
*** Support or/and/xor array intrinsic methods, bug1210. [Mike Popoloski]
|
*** Support or/and/xor array intrinsic methods, bug1210. [Mike Popoloski]
|
||||||
|
|
||||||
*** Support package export, bug1217. [Usuario Eda]
|
*** Support package export, bug1217. [Usuario Eda]
|
||||||
|
|
|
||||||
|
|
@ -364,7 +364,7 @@ QData VL_POWSS_QQW(int obits, int, int rbits, QData lhs, WDataInP rwp, bool lsig
|
||||||
// Do a va_arg returning a quad, assuming input argument is anything less than wide
|
// Do a va_arg returning a quad, assuming input argument is anything less than wide
|
||||||
#define _VL_VA_ARG_Q(ap, bits) (((bits) <= VL_WORDSIZE) ? va_arg(ap,IData) : va_arg(ap,QData))
|
#define _VL_VA_ARG_Q(ap, bits) (((bits) <= VL_WORDSIZE) ? va_arg(ap,IData) : va_arg(ap,QData))
|
||||||
|
|
||||||
void _vl_vsformat(string& output, const char* formatp, va_list ap) {
|
void _vl_vsformat(std::string& output, const char* formatp, va_list ap) {
|
||||||
// Format a Verilog $write style format into the output list
|
// Format a Verilog $write style format into the output list
|
||||||
// The format must be pre-processed (and lower cased) by Verilator
|
// The format must be pre-processed (and lower cased) by Verilator
|
||||||
// Arguments are in "width, arg-value (or WDataIn* if wide)" form
|
// Arguments are in "width, arg-value (or WDataIn* if wide)" form
|
||||||
|
|
@ -420,7 +420,7 @@ void _vl_vsformat(string& output, const char* formatp, va_list ap) {
|
||||||
}
|
}
|
||||||
case '@': { // Verilog/C++ string
|
case '@': { // Verilog/C++ string
|
||||||
va_arg(ap, int); // # bits is ignored
|
va_arg(ap, int); // # bits is ignored
|
||||||
const string* cstrp = va_arg(ap, const string*);
|
const std::string* cstrp = va_arg(ap, const std::string*);
|
||||||
output += *cstrp;
|
output += *cstrp;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
@ -559,7 +559,7 @@ void _vl_vsformat(string& output, const char* formatp, va_list ap) {
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
string msg = string("Unknown _vl_vsformat code: ")+pos[0];
|
std::string msg = std::string("Unknown _vl_vsformat code: ")+pos[0];
|
||||||
vl_fatal(__FILE__,__LINE__,"",msg.c_str());
|
vl_fatal(__FILE__,__LINE__,"",msg.c_str());
|
||||||
break;
|
break;
|
||||||
} // switch
|
} // switch
|
||||||
|
|
@ -577,7 +577,7 @@ static inline void _vl_vsss_advance(FILE* fp, int& floc) {
|
||||||
if (fp) fgetc(fp);
|
if (fp) fgetc(fp);
|
||||||
else floc -= 8;
|
else floc -= 8;
|
||||||
}
|
}
|
||||||
static inline int _vl_vsss_peek(FILE* fp, int& floc, WDataInP fromp, const string& fstr) {
|
static inline int _vl_vsss_peek(FILE* fp, int& floc, WDataInP fromp, const std::string& fstr) {
|
||||||
// Get a character without advancing
|
// Get a character without advancing
|
||||||
if (fp) {
|
if (fp) {
|
||||||
int data = fgetc(fp);
|
int data = fgetc(fp);
|
||||||
|
|
@ -594,14 +594,14 @@ static inline int _vl_vsss_peek(FILE* fp, int& floc, WDataInP fromp, const stri
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
static inline void _vl_vsss_skipspace(FILE* fp, int& floc, WDataInP fromp, const string& fstr) {
|
static inline void _vl_vsss_skipspace(FILE* fp, int& floc, WDataInP fromp, const std::string& fstr) {
|
||||||
while (1) {
|
while (1) {
|
||||||
int c = _vl_vsss_peek(fp, floc, fromp, fstr);
|
int c = _vl_vsss_peek(fp, floc, fromp, fstr);
|
||||||
if (c==EOF || !isspace(c)) return;
|
if (c==EOF || !isspace(c)) return;
|
||||||
_vl_vsss_advance(fp, floc);
|
_vl_vsss_advance(fp, floc);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
static inline void _vl_vsss_read(FILE* fp, int& floc, WDataInP fromp, const string& fstr,
|
static inline void _vl_vsss_read(FILE* fp, int& floc, WDataInP fromp, const std::string& fstr,
|
||||||
char* tmpp, const char* acceptp) {
|
char* tmpp, const char* acceptp) {
|
||||||
// Read into tmp, consisting of characters from acceptp list
|
// Read into tmp, consisting of characters from acceptp list
|
||||||
char* cp = tmpp;
|
char* cp = tmpp;
|
||||||
|
|
@ -651,7 +651,7 @@ static inline void _vl_vsss_based(WDataOutP owp, int obits, int baseLog2, const
|
||||||
|
|
||||||
IData _vl_vsscanf(FILE* fp, // If a fscanf
|
IData _vl_vsscanf(FILE* fp, // If a fscanf
|
||||||
int fbits, WDataInP fromp, // Else if a sscanf
|
int fbits, WDataInP fromp, // Else if a sscanf
|
||||||
const string& fstr, // if a sscanf to string
|
const std::string& fstr, // if a sscanf to string
|
||||||
const char* formatp, va_list ap) {
|
const char* formatp, va_list ap) {
|
||||||
// Read a Verilog $sscanf/$fscanf style format into the output list
|
// Read a Verilog $sscanf/$fscanf style format into the output list
|
||||||
// The format must be pre-processed (and lower cased) by Verilator
|
// The format must be pre-processed (and lower cased) by Verilator
|
||||||
|
|
@ -766,7 +766,7 @@ IData _vl_vsscanf(FILE* fp, // If a fscanf
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
default:
|
default:
|
||||||
string msg = string("Unknown _vl_vsscanf code: ")+pos[0];
|
std::string msg = std::string("Unknown _vl_vsscanf code: ")+pos[0];
|
||||||
vl_fatal(__FILE__,__LINE__,"",msg.c_str());
|
vl_fatal(__FILE__,__LINE__,"",msg.c_str());
|
||||||
break;
|
break;
|
||||||
} // switch
|
} // switch
|
||||||
|
|
@ -852,7 +852,7 @@ IData VL_FGETS_IXI(int obits, void* destp, IData fpi) {
|
||||||
return got;
|
return got;
|
||||||
}
|
}
|
||||||
|
|
||||||
IData VL_FOPEN_NI(const string& filename, IData mode) {
|
IData VL_FOPEN_NI(const std::string& filename, IData mode) {
|
||||||
char modez[5];
|
char modez[5];
|
||||||
_VL_VINT_TO_STRING(VL_WORDSIZE, modez, &mode);
|
_VL_VINT_TO_STRING(VL_WORDSIZE, modez, &mode);
|
||||||
return VL_FOPEN_S(filename.c_str(), modez);
|
return VL_FOPEN_S(filename.c_str(), modez);
|
||||||
|
|
@ -880,7 +880,7 @@ void VL_FCLOSE_I(IData fdi) {
|
||||||
}
|
}
|
||||||
|
|
||||||
void VL_SFORMAT_X(int obits, CData& destr, const char* formatp, ...) {
|
void VL_SFORMAT_X(int obits, CData& destr, const char* formatp, ...) {
|
||||||
VL_STATIC_OR_THREAD string output; // static only for speed
|
VL_STATIC_OR_THREAD std::string output; // static only for speed
|
||||||
output = "";
|
output = "";
|
||||||
va_list ap;
|
va_list ap;
|
||||||
va_start(ap,formatp);
|
va_start(ap,formatp);
|
||||||
|
|
@ -891,7 +891,7 @@ void VL_SFORMAT_X(int obits, CData& destr, const char* formatp, ...) {
|
||||||
}
|
}
|
||||||
|
|
||||||
void VL_SFORMAT_X(int obits, SData& destr, const char* formatp, ...) {
|
void VL_SFORMAT_X(int obits, SData& destr, const char* formatp, ...) {
|
||||||
VL_STATIC_OR_THREAD string output; // static only for speed
|
VL_STATIC_OR_THREAD std::string output; // static only for speed
|
||||||
output = "";
|
output = "";
|
||||||
va_list ap;
|
va_list ap;
|
||||||
va_start(ap,formatp);
|
va_start(ap,formatp);
|
||||||
|
|
@ -902,7 +902,7 @@ void VL_SFORMAT_X(int obits, SData& destr, const char* formatp, ...) {
|
||||||
}
|
}
|
||||||
|
|
||||||
void VL_SFORMAT_X(int obits, IData& destr, const char* formatp, ...) {
|
void VL_SFORMAT_X(int obits, IData& destr, const char* formatp, ...) {
|
||||||
VL_STATIC_OR_THREAD string output; // static only for speed
|
VL_STATIC_OR_THREAD std::string output; // static only for speed
|
||||||
output = "";
|
output = "";
|
||||||
va_list ap;
|
va_list ap;
|
||||||
va_start(ap,formatp);
|
va_start(ap,formatp);
|
||||||
|
|
@ -913,7 +913,7 @@ void VL_SFORMAT_X(int obits, IData& destr, const char* formatp, ...) {
|
||||||
}
|
}
|
||||||
|
|
||||||
void VL_SFORMAT_X(int obits, QData& destr, const char* formatp, ...) {
|
void VL_SFORMAT_X(int obits, QData& destr, const char* formatp, ...) {
|
||||||
VL_STATIC_OR_THREAD string output; // static only for speed
|
VL_STATIC_OR_THREAD std::string output; // static only for speed
|
||||||
output = "";
|
output = "";
|
||||||
va_list ap;
|
va_list ap;
|
||||||
va_start(ap,formatp);
|
va_start(ap,formatp);
|
||||||
|
|
@ -924,7 +924,7 @@ void VL_SFORMAT_X(int obits, QData& destr, const char* formatp, ...) {
|
||||||
}
|
}
|
||||||
|
|
||||||
void VL_SFORMAT_X(int obits, void* destp, const char* formatp, ...) {
|
void VL_SFORMAT_X(int obits, void* destp, const char* formatp, ...) {
|
||||||
VL_STATIC_OR_THREAD string output; // static only for speed
|
VL_STATIC_OR_THREAD std::string output; // static only for speed
|
||||||
output = "";
|
output = "";
|
||||||
va_list ap;
|
va_list ap;
|
||||||
va_start(ap,formatp);
|
va_start(ap,formatp);
|
||||||
|
|
@ -934,7 +934,7 @@ void VL_SFORMAT_X(int obits, void* destp, const char* formatp, ...) {
|
||||||
_VL_STRING_TO_VINT(obits, destp, (int)output.length(), output.c_str());
|
_VL_STRING_TO_VINT(obits, destp, (int)output.length(), output.c_str());
|
||||||
}
|
}
|
||||||
|
|
||||||
void VL_SFORMAT_X(int obits_ignored, string &output, const char* formatp, ...) {
|
void VL_SFORMAT_X(int obits_ignored, std::string &output, const char* formatp, ...) {
|
||||||
if (obits_ignored) {}
|
if (obits_ignored) {}
|
||||||
output = "";
|
output = "";
|
||||||
va_list ap;
|
va_list ap;
|
||||||
|
|
@ -943,8 +943,8 @@ void VL_SFORMAT_X(int obits_ignored, string &output, const char* formatp, ...) {
|
||||||
va_end(ap);
|
va_end(ap);
|
||||||
}
|
}
|
||||||
|
|
||||||
string VL_SFORMATF_NX(const char* formatp, ...) {
|
std::string VL_SFORMATF_NX(const char* formatp, ...) {
|
||||||
VL_STATIC_OR_THREAD string output; // static only for speed
|
VL_STATIC_OR_THREAD std::string output; // static only for speed
|
||||||
output = "";
|
output = "";
|
||||||
va_list ap;
|
va_list ap;
|
||||||
va_start(ap,formatp);
|
va_start(ap,formatp);
|
||||||
|
|
@ -955,7 +955,7 @@ string VL_SFORMATF_NX(const char* formatp, ...) {
|
||||||
}
|
}
|
||||||
|
|
||||||
void VL_WRITEF(const char* formatp, ...) {
|
void VL_WRITEF(const char* formatp, ...) {
|
||||||
VL_STATIC_OR_THREAD string output; // static only for speed
|
VL_STATIC_OR_THREAD std::string output; // static only for speed
|
||||||
output = "";
|
output = "";
|
||||||
va_list ap;
|
va_list ap;
|
||||||
va_start(ap,formatp);
|
va_start(ap,formatp);
|
||||||
|
|
@ -967,7 +967,7 @@ void VL_WRITEF(const char* formatp, ...) {
|
||||||
}
|
}
|
||||||
|
|
||||||
void VL_FWRITEF(IData fpi, const char* formatp, ...) {
|
void VL_FWRITEF(IData fpi, const char* formatp, ...) {
|
||||||
VL_STATIC_OR_THREAD string output; // static only for speed
|
VL_STATIC_OR_THREAD std::string output; // static only for speed
|
||||||
output = "";
|
output = "";
|
||||||
FILE* fp = VL_CVT_I_FP(fpi);
|
FILE* fp = VL_CVT_I_FP(fpi);
|
||||||
if (VL_UNLIKELY(!fp)) return;
|
if (VL_UNLIKELY(!fp)) return;
|
||||||
|
|
@ -1016,7 +1016,7 @@ IData VL_SSCANF_IWX(int lbits, WDataInP lwp, const char* formatp, ...) {
|
||||||
va_end(ap);
|
va_end(ap);
|
||||||
return got;
|
return got;
|
||||||
}
|
}
|
||||||
IData VL_SSCANF_INX(int, const string& ld, const char* formatp, ...) {
|
IData VL_SSCANF_INX(int, const std::string& ld, const char* formatp, ...) {
|
||||||
va_list ap;
|
va_list ap;
|
||||||
va_start(ap,formatp);
|
va_start(ap,formatp);
|
||||||
IData got = _vl_vsscanf(NULL, ld.length()*8, NULL, ld, formatp, ap);
|
IData got = _vl_vsscanf(NULL, ld.length()*8, NULL, ld, formatp, ap);
|
||||||
|
|
@ -1034,12 +1034,12 @@ void VL_READMEM_W(bool hex, int width, int depth, int array_lsb, int fnwords,
|
||||||
WDataInP ofilenamep, void* memp, IData start, IData end) {
|
WDataInP ofilenamep, void* memp, IData start, IData end) {
|
||||||
char ofilenamez[VL_TO_STRING_MAX_WORDS*VL_WORDSIZE+1];
|
char ofilenamez[VL_TO_STRING_MAX_WORDS*VL_WORDSIZE+1];
|
||||||
_VL_VINT_TO_STRING(fnwords*VL_WORDSIZE, ofilenamez, ofilenamep);
|
_VL_VINT_TO_STRING(fnwords*VL_WORDSIZE, ofilenamez, ofilenamep);
|
||||||
string ofilenames(ofilenamez);
|
std::string ofilenames(ofilenamez);
|
||||||
return VL_READMEM_N(hex,width,depth,array_lsb,fnwords,ofilenames,memp,start,end);
|
return VL_READMEM_N(hex,width,depth,array_lsb,fnwords,ofilenames,memp,start,end);
|
||||||
}
|
}
|
||||||
|
|
||||||
void VL_READMEM_N(bool hex, int width, int depth, int array_lsb, int fnwords,
|
void VL_READMEM_N(bool hex, int width, int depth, int array_lsb, int fnwords,
|
||||||
const string& ofilenamep, void* memp, IData start, IData end) {
|
const std::string& ofilenamep, void* memp, IData start, IData end) {
|
||||||
if (fnwords) {}
|
if (fnwords) {}
|
||||||
FILE* fp = fopen(ofilenamep.c_str(), "r");
|
FILE* fp = fopen(ofilenamep.c_str(), "r");
|
||||||
if (VL_UNLIKELY(!fp)) {
|
if (VL_UNLIKELY(!fp)) {
|
||||||
|
|
@ -1150,13 +1150,13 @@ IData VL_SYSTEM_IW(int lhswords, WDataInP filenamep) {
|
||||||
}
|
}
|
||||||
|
|
||||||
IData VL_TESTPLUSARGS_I(const char* formatp) {
|
IData VL_TESTPLUSARGS_I(const char* formatp) {
|
||||||
const string& match = VerilatedImp::argPlusMatch(formatp);
|
const std::string& match = VerilatedImp::argPlusMatch(formatp);
|
||||||
if (match == "") return 0;
|
if (match == "") return 0;
|
||||||
else return 1;
|
else return 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
IData VL_VALUEPLUSARGS_INW(int rbits, const string& ld, WDataOutP rwp) {
|
IData VL_VALUEPLUSARGS_INW(int rbits, const std::string& ld, WDataOutP rwp) {
|
||||||
string prefix;
|
std::string prefix;
|
||||||
bool inPct = false;
|
bool inPct = false;
|
||||||
bool done = false;
|
bool done = false;
|
||||||
char fmt = ' ';
|
char fmt = ' ';
|
||||||
|
|
@ -1179,7 +1179,7 @@ IData VL_VALUEPLUSARGS_INW(int rbits, const string& ld, WDataOutP rwp) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
const string& match = VerilatedImp::argPlusMatch(prefix.c_str());
|
const std::string& match = VerilatedImp::argPlusMatch(prefix.c_str());
|
||||||
const char* dp = match.c_str() + 1 /*leading + */ + prefix.length();
|
const char* dp = match.c_str() + 1 /*leading + */ + prefix.length();
|
||||||
if (match == "") return 0;
|
if (match == "") return 0;
|
||||||
|
|
||||||
|
|
@ -1214,8 +1214,8 @@ IData VL_VALUEPLUSARGS_INW(int rbits, const string& ld, WDataOutP rwp) {
|
||||||
_VL_CLEAN_INPLACE_W(rbits,rwp);
|
_VL_CLEAN_INPLACE_W(rbits,rwp);
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
IData VL_VALUEPLUSARGS_INN(int, const string& ld, string& rdr) {
|
IData VL_VALUEPLUSARGS_INN(int, const std::string& ld, std::string& rdr) {
|
||||||
string prefix;
|
std::string prefix;
|
||||||
bool inPct = false;
|
bool inPct = false;
|
||||||
bool done = false;
|
bool done = false;
|
||||||
for (const char* posp = ld.c_str(); !done && *posp; ++posp) {
|
for (const char* posp = ld.c_str(); !done && *posp; ++posp) {
|
||||||
|
|
@ -1235,15 +1235,15 @@ IData VL_VALUEPLUSARGS_INN(int, const string& ld, string& rdr) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
const string& match = VerilatedImp::argPlusMatch(prefix.c_str());
|
const std::string& match = VerilatedImp::argPlusMatch(prefix.c_str());
|
||||||
const char* dp = match.c_str() + 1 /*leading + */ + prefix.length();
|
const char* dp = match.c_str() + 1 /*leading + */ + prefix.length();
|
||||||
if (match == "") return 0;
|
if (match == "") return 0;
|
||||||
rdr = string(dp);
|
rdr = std::string(dp);
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
const char* vl_mc_scan_plusargs(const char* prefixp) {
|
const char* vl_mc_scan_plusargs(const char* prefixp) {
|
||||||
const string& match = VerilatedImp::argPlusMatch(prefixp);
|
const std::string& match = VerilatedImp::argPlusMatch(prefixp);
|
||||||
static VL_THREAD char outstr[VL_VALUE_STRING_MAX_WIDTH];
|
static VL_THREAD char outstr[VL_VALUE_STRING_MAX_WIDTH];
|
||||||
if (match == "") return NULL;
|
if (match == "") return NULL;
|
||||||
strncpy(outstr, match.c_str()+strlen(prefixp)+1, // +1 to skip the "+"
|
strncpy(outstr, match.c_str()+strlen(prefixp)+1, // +1 to skip the "+"
|
||||||
|
|
@ -1255,7 +1255,7 @@ const char* vl_mc_scan_plusargs(const char* prefixp) {
|
||||||
//===========================================================================
|
//===========================================================================
|
||||||
// Heavy functions
|
// Heavy functions
|
||||||
|
|
||||||
string VL_CVT_PACK_STR_NW(int lwords, WDataInP lwp) {
|
std::string VL_CVT_PACK_STR_NW(int lwords, WDataInP lwp) {
|
||||||
// See also _VL_VINT_TO_STRING
|
// See also _VL_VINT_TO_STRING
|
||||||
char destout[VL_TO_STRING_MAX_WORDS*VL_WORDSIZE+1];
|
char destout[VL_TO_STRING_MAX_WORDS*VL_WORDSIZE+1];
|
||||||
int obits = lwords * VL_WORDSIZE;
|
int obits = lwords * VL_WORDSIZE;
|
||||||
|
|
@ -1272,7 +1272,7 @@ string VL_CVT_PACK_STR_NW(int lwords, WDataInP lwp) {
|
||||||
start = false; // Drop leading 0s
|
start = false; // Drop leading 0s
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return string(destout, len);
|
return std::string(destout, len);
|
||||||
}
|
}
|
||||||
|
|
||||||
//===========================================================================
|
//===========================================================================
|
||||||
|
|
@ -1311,7 +1311,7 @@ void Verilated::commandArgs(int argc, const char** argv) {
|
||||||
}
|
}
|
||||||
|
|
||||||
const char* Verilated::commandArgsPlusMatch(const char* prefixp) {
|
const char* Verilated::commandArgsPlusMatch(const char* prefixp) {
|
||||||
const string& match = VerilatedImp::argPlusMatch(prefixp);
|
const std::string& match = VerilatedImp::argPlusMatch(prefixp);
|
||||||
static VL_THREAD char outstr[VL_VALUE_STRING_MAX_WIDTH];
|
static VL_THREAD char outstr[VL_VALUE_STRING_MAX_WIDTH];
|
||||||
if (match == "") return "";
|
if (match == "") return "";
|
||||||
strncpy(outstr, match.c_str(), VL_VALUE_STRING_MAX_WIDTH);
|
strncpy(outstr, match.c_str(), VL_VALUE_STRING_MAX_WIDTH);
|
||||||
|
|
@ -1442,12 +1442,12 @@ void VerilatedScope::varInsert(int finalize, const char* namep, void* datap,
|
||||||
} else {
|
} else {
|
||||||
// We could have a linked list of ranges, but really this whole thing needs
|
// We could have a linked list of ranges, but really this whole thing needs
|
||||||
// to be generalized to support structs and unions, etc.
|
// to be generalized to support structs and unions, etc.
|
||||||
vl_fatal(__FILE__,__LINE__,"",(string("Unsupported multi-dimensional public varInsert: ")+namep).c_str());
|
vl_fatal(__FILE__,__LINE__,"",(std::string("Unsupported multi-dimensional public varInsert: ")+namep).c_str());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
va_end(ap);
|
va_end(ap);
|
||||||
|
|
||||||
m_varsp->insert(make_pair(namep,var));
|
m_varsp->insert(std::make_pair(namep,var));
|
||||||
}
|
}
|
||||||
|
|
||||||
// cppcheck-suppress unusedFunction // Used by applications
|
// cppcheck-suppress unusedFunction // Used by applications
|
||||||
|
|
@ -1463,19 +1463,19 @@ VerilatedVar* VerilatedScope::varFind(const char* namep) const {
|
||||||
|
|
||||||
void* VerilatedScope::exportFindNullError(int funcnum) {
|
void* VerilatedScope::exportFindNullError(int funcnum) {
|
||||||
// Slowpath - Called only when find has failed
|
// Slowpath - Called only when find has failed
|
||||||
string msg = (string("Testbench C called '")
|
std::string msg = (std::string("Testbench C called '")
|
||||||
+VerilatedImp::exportName(funcnum)
|
+VerilatedImp::exportName(funcnum)
|
||||||
+"' but scope wasn't set, perhaps due to dpi import call without 'context'");
|
+"' but scope wasn't set, perhaps due to dpi import call without 'context'");
|
||||||
vl_fatal("unknown",0,"", msg.c_str());
|
vl_fatal("unknown",0,"", msg.c_str());
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
void* VerilatedScope::exportFindError(int funcnum) const {
|
void* VerilatedScope::exportFindError(int funcnum) const {
|
||||||
// Slowpath - Called only when find has failed
|
// Slowpath - Called only when find has failed
|
||||||
string msg = (string("Testbench C called '")
|
std::string msg = (std::string("Testbench C called '")
|
||||||
+VerilatedImp::exportName(funcnum)
|
+VerilatedImp::exportName(funcnum)
|
||||||
+"' but this DPI export function exists only in other scopes, not scope '"
|
+"' but this DPI export function exists only in other scopes, not scope '"
|
||||||
+name()+"'");
|
+name()+"'");
|
||||||
vl_fatal("unknown",0,"", msg.c_str());
|
vl_fatal("unknown",0,"", msg.c_str());
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -40,7 +40,6 @@
|
||||||
// <iostream> avoided to reduce compile time
|
// <iostream> avoided to reduce compile time
|
||||||
// <map> avoided and instead in verilated_heavy.h to reduce compile time
|
// <map> avoided and instead in verilated_heavy.h to reduce compile time
|
||||||
// <string> avoided and instead in verilated_heavy.h to reduce compile time
|
// <string> avoided and instead in verilated_heavy.h to reduce compile time
|
||||||
using namespace std;
|
|
||||||
|
|
||||||
//=============================================================================
|
//=============================================================================
|
||||||
// Switches
|
// Switches
|
||||||
|
|
|
||||||
|
|
@ -90,9 +90,9 @@ public:
|
||||||
class VerilatedCovImp : VerilatedCovImpBase {
|
class VerilatedCovImp : VerilatedCovImpBase {
|
||||||
private:
|
private:
|
||||||
// TYPES
|
// TYPES
|
||||||
typedef map<string,int> ValueIndexMap;
|
typedef std::map<std::string,int> ValueIndexMap;
|
||||||
typedef map<int,string> IndexValueMap;
|
typedef std::map<int,std::string> IndexValueMap;
|
||||||
typedef deque<VerilatedCovImpItem*> ItemList;
|
typedef std::deque<VerilatedCovImpItem*> ItemList;
|
||||||
|
|
||||||
private:
|
private:
|
||||||
// MEMBERS
|
// MEMBERS
|
||||||
|
|
@ -119,18 +119,18 @@ public:
|
||||||
|
|
||||||
private:
|
private:
|
||||||
// PRIVATE METHODS
|
// PRIVATE METHODS
|
||||||
int valueIndex(const string& value) {
|
int valueIndex(const std::string& value) {
|
||||||
static int nextIndex = KEY_UNDEF+1;
|
static int nextIndex = KEY_UNDEF+1;
|
||||||
ValueIndexMap::iterator iter = m_valueIndexes.find(value);
|
ValueIndexMap::iterator iter = m_valueIndexes.find(value);
|
||||||
if (iter != m_valueIndexes.end()) return iter->second;
|
if (iter != m_valueIndexes.end()) return iter->second;
|
||||||
nextIndex++; assert(nextIndex>0);
|
nextIndex++; assert(nextIndex>0);
|
||||||
m_valueIndexes.insert(make_pair(value, nextIndex));
|
m_valueIndexes.insert(std::make_pair(value, nextIndex));
|
||||||
m_indexValues.insert(make_pair(nextIndex, value));
|
m_indexValues.insert(std::make_pair(nextIndex, value));
|
||||||
return nextIndex;
|
return nextIndex;
|
||||||
}
|
}
|
||||||
string dequote(const string& text) {
|
std::string dequote(const std::string& text) {
|
||||||
// Quote any special characters
|
// Quote any special characters
|
||||||
string rtn;
|
std::string rtn;
|
||||||
for (const char* pos = text.c_str(); *pos; ++pos) {
|
for (const char* pos = text.c_str(); *pos; ++pos) {
|
||||||
if (!isprint(*pos) || *pos=='%' || *pos=='"') {
|
if (!isprint(*pos) || *pos=='%' || *pos=='"') {
|
||||||
char hex[10]; sprintf(hex,"%%%02X",pos[0]);
|
char hex[10]; sprintf(hex,"%%%02X",pos[0]);
|
||||||
|
|
@ -141,7 +141,7 @@ private:
|
||||||
}
|
}
|
||||||
return rtn;
|
return rtn;
|
||||||
}
|
}
|
||||||
bool legalKey(const string& key) {
|
bool legalKey(const std::string& key) {
|
||||||
// Because we compress long keys to a single letter, and
|
// Because we compress long keys to a single letter, and
|
||||||
// don't want applications to either get confused if they use
|
// don't want applications to either get confused if they use
|
||||||
// a letter differently, nor want them to rely on our compression...
|
// a letter differently, nor want them to rely on our compression...
|
||||||
|
|
@ -150,17 +150,17 @@ private:
|
||||||
if (key.length()==2 && isdigit(key[1])) return false;
|
if (key.length()==2 && isdigit(key[1])) return false;
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
string keyValueFormatter (const string& key, const string& value) {
|
std::string keyValueFormatter (const std::string& key, const std::string& value) {
|
||||||
string name;
|
std::string name;
|
||||||
if (key.length()==1 && isalpha(key[0])) {
|
if (key.length()==1 && isalpha(key[0])) {
|
||||||
name += string("\001")+key;
|
name += std::string("\001")+key;
|
||||||
} else {
|
} else {
|
||||||
name += string("\001")+dequote(key);
|
name += std::string("\001")+dequote(key);
|
||||||
}
|
}
|
||||||
name += string("\002")+dequote(value);
|
name += std::string("\002")+dequote(value);
|
||||||
return name;
|
return name;
|
||||||
}
|
}
|
||||||
string combineHier (const string& old, const string& add) {
|
std::string combineHier (const std::string& old, const std::string& add) {
|
||||||
// (foo.a.x, foo.b.x) => foo.*.x
|
// (foo.a.x, foo.b.x) => foo.*.x
|
||||||
// (foo.a.x, foo.b.y) => foo.*
|
// (foo.a.x, foo.b.y) => foo.*
|
||||||
// (foo.a.x, foo.b) => foo.*
|
// (foo.a.x, foo.b) => foo.*
|
||||||
|
|
@ -178,7 +178,7 @@ private:
|
||||||
|
|
||||||
// We used to backup and split on only .'s but it seems better to be verbose
|
// We used to backup and split on only .'s but it seems better to be verbose
|
||||||
// and not assume . is the separator
|
// and not assume . is the separator
|
||||||
string prefix = string(a,apre-a);
|
std::string prefix = std::string(a,apre-a);
|
||||||
|
|
||||||
// Scan backward to last mismatch
|
// Scan backward to last mismatch
|
||||||
const char* apost = a+strlen(a)-1;
|
const char* apost = a+strlen(a)-1;
|
||||||
|
|
@ -187,19 +187,19 @@ private:
|
||||||
&& apost>apre && bpost>bpre) { apost--; bpost--; }
|
&& apost>apre && bpost>bpre) { apost--; bpost--; }
|
||||||
|
|
||||||
// Forward to . so we have a whole word
|
// Forward to . so we have a whole word
|
||||||
string suffix = *bpost ? string(bpost+1) : "";
|
std::string suffix = *bpost ? std::string(bpost+1) : "";
|
||||||
|
|
||||||
string out = prefix+"*"+suffix;
|
std::string out = prefix+"*"+suffix;
|
||||||
|
|
||||||
//cout << "\nch pre="<<prefix<<" s="<<suffix<<"\nch a="<<old<<"\nch b="<<add<<"\nch o="<<out<<endl;
|
//cout << "\nch pre="<<prefix<<" s="<<suffix<<"\nch a="<<old<<"\nch b="<<add<<"\nch o="<<out<<endl;
|
||||||
return out;
|
return out;
|
||||||
}
|
}
|
||||||
bool itemMatchesString(VerilatedCovImpItem* itemp, const string& match) {
|
bool itemMatchesString(VerilatedCovImpItem* itemp, const std::string& match) {
|
||||||
for (int i=0; i<MAX_KEYS; ++i) {
|
for (int i=0; i<MAX_KEYS; ++i) {
|
||||||
if (itemp->m_keys[i] != KEY_UNDEF) {
|
if (itemp->m_keys[i] != KEY_UNDEF) {
|
||||||
// We don't compare keys, only values
|
// We don't compare keys, only values
|
||||||
string val = m_indexValues[itemp->m_vals[i]];
|
std::string val = m_indexValues[itemp->m_vals[i]];
|
||||||
if (string::npos != val.find(match)) { // Found
|
if (std::string::npos != val.find(match)) { // Found
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
@ -263,18 +263,18 @@ public:
|
||||||
assert(m_insertp);
|
assert(m_insertp);
|
||||||
// First two key/vals are filename
|
// First two key/vals are filename
|
||||||
ckeyps[0]="filename"; valps[0]=m_insertFilenamep;
|
ckeyps[0]="filename"; valps[0]=m_insertFilenamep;
|
||||||
string linestr = vlCovCvtToStr(m_insertLineno);
|
std::string linestr = vlCovCvtToStr(m_insertLineno);
|
||||||
ckeyps[1]="lineno"; valps[1]=linestr.c_str();
|
ckeyps[1]="lineno"; valps[1]=linestr.c_str();
|
||||||
// Default page if not specified
|
// Default page if not specified
|
||||||
const char* fnstartp = m_insertFilenamep;
|
const char* fnstartp = m_insertFilenamep;
|
||||||
while (const char* foundp = strchr(fnstartp,'/')) fnstartp=foundp+1;
|
while (const char* foundp = strchr(fnstartp,'/')) fnstartp=foundp+1;
|
||||||
const char* fnendp = fnstartp;
|
const char* fnendp = fnstartp;
|
||||||
while (*fnendp && *fnendp!='.') fnendp++;
|
while (*fnendp && *fnendp!='.') fnendp++;
|
||||||
string page_default = "sp_user/"+string(fnstartp,fnendp-fnstartp);
|
std::string page_default = "sp_user/"+std::string(fnstartp,fnendp-fnstartp);
|
||||||
ckeyps[2]="page"; valps[2]=page_default.c_str();
|
ckeyps[2]="page"; valps[2]=page_default.c_str();
|
||||||
|
|
||||||
// Keys -> strings
|
// Keys -> strings
|
||||||
string keys[MAX_KEYS];
|
std::string keys[MAX_KEYS];
|
||||||
for (int i=0; i<MAX_KEYS; ++i) {
|
for (int i=0; i<MAX_KEYS; ++i) {
|
||||||
if (ckeyps[i] && ckeyps[i][0]) {
|
if (ckeyps[i] && ckeyps[i][0]) {
|
||||||
keys[i] = ckeyps[i];
|
keys[i] = ckeyps[i];
|
||||||
|
|
@ -294,15 +294,15 @@ public:
|
||||||
// Insert the values
|
// Insert the values
|
||||||
int addKeynum=0;
|
int addKeynum=0;
|
||||||
for (int i=0; i<MAX_KEYS; ++i) {
|
for (int i=0; i<MAX_KEYS; ++i) {
|
||||||
const string key = keys[i];
|
const std::string key = keys[i];
|
||||||
if (keys[i]!="") {
|
if (keys[i]!="") {
|
||||||
const string val = valps[i];
|
const std::string val = valps[i];
|
||||||
//cout<<" "<<__FUNCTION__<<" "<<key<<" = "<<val<<endl;
|
//cout<<" "<<__FUNCTION__<<" "<<key<<" = "<<val<<endl;
|
||||||
m_insertp->m_keys[addKeynum] = valueIndex(key);
|
m_insertp->m_keys[addKeynum] = valueIndex(key);
|
||||||
m_insertp->m_vals[addKeynum] = valueIndex(val);
|
m_insertp->m_vals[addKeynum] = valueIndex(val);
|
||||||
addKeynum++;
|
addKeynum++;
|
||||||
if (!legalKey(key)) {
|
if (!legalKey(key)) {
|
||||||
string msg = "%Error: Coverage keys of one character, or letter+digit are illegal: "+key;
|
std::string msg = "%Error: Coverage keys of one character, or letter+digit are illegal: "+key;
|
||||||
vl_fatal("",0,"",msg.c_str());
|
vl_fatal("",0,"",msg.c_str());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
@ -318,27 +318,27 @@ public:
|
||||||
#endif
|
#endif
|
||||||
selftest();
|
selftest();
|
||||||
|
|
||||||
ofstream os (filename);
|
std::ofstream os (filename);
|
||||||
if (os.fail()) {
|
if (os.fail()) {
|
||||||
string msg = (string)"%Error: Can't write '"+filename+"'";
|
std::string msg = (std::string)"%Error: Can't write '"+filename+"'";
|
||||||
vl_fatal("",0,"",msg.c_str());
|
vl_fatal("",0,"",msg.c_str());
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
os << "# SystemC::Coverage-3\n";
|
os << "# SystemC::Coverage-3\n";
|
||||||
|
|
||||||
// Build list of events; totalize if collapsing hierarchy
|
// Build list of events; totalize if collapsing hierarchy
|
||||||
typedef map<string,pair<string,vluint64_t> > EventMap;
|
typedef std::map<std::string,std::pair<std::string,vluint64_t> > EventMap;
|
||||||
EventMap eventCounts;
|
EventMap eventCounts;
|
||||||
for (ItemList::iterator it=m_items.begin(); it!=m_items.end(); ++it) {
|
for (ItemList::iterator it=m_items.begin(); it!=m_items.end(); ++it) {
|
||||||
VerilatedCovImpItem* itemp = *(it);
|
VerilatedCovImpItem* itemp = *(it);
|
||||||
string name;
|
std::string name;
|
||||||
string hier;
|
std::string hier;
|
||||||
bool per_instance = false;
|
bool per_instance = false;
|
||||||
|
|
||||||
for (int i=0; i<MAX_KEYS; ++i) {
|
for (int i=0; i<MAX_KEYS; ++i) {
|
||||||
if (itemp->m_keys[i] != KEY_UNDEF) {
|
if (itemp->m_keys[i] != KEY_UNDEF) {
|
||||||
string key = VerilatedCovKey::shortKey(m_indexValues[itemp->m_keys[i]]);
|
std::string key = VerilatedCovKey::shortKey(m_indexValues[itemp->m_keys[i]]);
|
||||||
string val = m_indexValues[itemp->m_vals[i]];
|
std::string val = m_indexValues[itemp->m_vals[i]];
|
||||||
if (key == VL_CIK_PER_INSTANCE) {
|
if (key == VL_CIK_PER_INSTANCE) {
|
||||||
if (val != "0") per_instance = true;
|
if (val != "0") per_instance = true;
|
||||||
}
|
}
|
||||||
|
|
@ -363,21 +363,21 @@ public:
|
||||||
// Find or insert the named event
|
// Find or insert the named event
|
||||||
EventMap::iterator cit = eventCounts.find(name);
|
EventMap::iterator cit = eventCounts.find(name);
|
||||||
if (cit != eventCounts.end()) {
|
if (cit != eventCounts.end()) {
|
||||||
const string& oldhier = cit->second.first;
|
const std::string& oldhier = cit->second.first;
|
||||||
cit->second.second += itemp->count();
|
cit->second.second += itemp->count();
|
||||||
cit->second.first = combineHier(oldhier, hier);
|
cit->second.first = combineHier(oldhier, hier);
|
||||||
} else {
|
} else {
|
||||||
eventCounts.insert(make_pair(name, make_pair(hier,itemp->count())));
|
eventCounts.insert(std::make_pair(name, make_pair(hier,itemp->count())));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// Output body
|
// Output body
|
||||||
for (EventMap::iterator it=eventCounts.begin(); it!=eventCounts.end(); ++it) {
|
for (EventMap::iterator it=eventCounts.begin(); it!=eventCounts.end(); ++it) {
|
||||||
os<<"C '"<<dec;
|
os<<"C '"<<std::dec;
|
||||||
os<<it->first;
|
os<<it->first;
|
||||||
if (it->second.first != "") os<<keyValueFormatter(VL_CIK_HIER,it->second.first);
|
if (it->second.first != "") os<<keyValueFormatter(VL_CIK_HIER,it->second.first);
|
||||||
os<<"' "<<it->second.second;
|
os<<"' "<<it->second.second;
|
||||||
os<<endl;
|
os<<std::endl;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
@ -441,9 +441,9 @@ void VerilatedCov::_insertp (A(0),A(1),A(2),A(3),A(4),A(5),A(6),A(7),A(8),A(9),
|
||||||
}
|
}
|
||||||
// Backward compatibility for Verilator
|
// Backward compatibility for Verilator
|
||||||
void VerilatedCov::_insertp (A(0), A(1), K(2),int val2, K(3),int val3,
|
void VerilatedCov::_insertp (A(0), A(1), K(2),int val2, K(3),int val3,
|
||||||
K(4),const string& val4, A(5),A(6)) {
|
K(4),const std::string& val4, A(5),A(6)) {
|
||||||
string val2str = vlCovCvtToStr(val2);
|
std::string val2str = vlCovCvtToStr(val2);
|
||||||
string val3str = vlCovCvtToStr(val3);
|
std::string val3str = vlCovCvtToStr(val3);
|
||||||
_insertp(C(0),C(1),
|
_insertp(C(0),C(1),
|
||||||
key2,val2str.c_str(), key3,val3str.c_str(), key4, val4.c_str(),
|
key2,val2str.c_str(), key3,val3str.c_str(), key4, val4.c_str(),
|
||||||
C(5),C(6),N(7),N(8),N(9),
|
C(5),C(6),N(7),N(8),N(9),
|
||||||
|
|
|
||||||
|
|
@ -27,7 +27,6 @@
|
||||||
#include <iostream>
|
#include <iostream>
|
||||||
#include <sstream>
|
#include <sstream>
|
||||||
#include <string>
|
#include <string>
|
||||||
using namespace std;
|
|
||||||
|
|
||||||
//=============================================================================
|
//=============================================================================
|
||||||
/// Conditionally compile coverage code
|
/// Conditionally compile coverage code
|
||||||
|
|
@ -75,7 +74,7 @@ using namespace std;
|
||||||
/// Convert VL_COVER_INSERT value arguments to strings
|
/// Convert VL_COVER_INSERT value arguments to strings
|
||||||
|
|
||||||
template< class T> std::string vlCovCvtToStr (const T& t) {
|
template< class T> std::string vlCovCvtToStr (const T& t) {
|
||||||
ostringstream os; os<<t; return os.str();
|
std::ostringstream os; os<<t; return os.str();
|
||||||
}
|
}
|
||||||
|
|
||||||
//=============================================================================
|
//=============================================================================
|
||||||
|
|
@ -115,7 +114,7 @@ public:
|
||||||
,A(20),D(21),D(22),D(23),D(24),D(25),D(26),D(27),D(28),D(29));
|
,A(20),D(21),D(22),D(23),D(24),D(25),D(26),D(27),D(28),D(29));
|
||||||
// Backward compatibility for Verilator
|
// Backward compatibility for Verilator
|
||||||
static void _insertp (A(0), A(1), K(2),int val2, K(3),int val3,
|
static void _insertp (A(0), A(1), K(2),int val2, K(3),int val3,
|
||||||
K(4),const string& val4, A(5),A(6));
|
K(4),const std::string& val4, A(5),A(6));
|
||||||
|
|
||||||
#undef K
|
#undef K
|
||||||
#undef A
|
#undef A
|
||||||
|
|
|
||||||
|
|
@ -25,7 +25,6 @@
|
||||||
#include "verilatedos.h"
|
#include "verilatedos.h"
|
||||||
|
|
||||||
#include <string>
|
#include <string>
|
||||||
using namespace std;
|
|
||||||
|
|
||||||
//=============================================================================
|
//=============================================================================
|
||||||
// Data used to edit below file, using vlcovgen
|
// Data used to edit below file, using vlcovgen
|
||||||
|
|
@ -105,7 +104,7 @@ VLCOVGEN_ITEM("name=>'weight', short=>'w', group=>0, default=>undef, descr
|
||||||
|
|
||||||
class VerilatedCovKey {
|
class VerilatedCovKey {
|
||||||
public:
|
public:
|
||||||
static string shortKey(const string& key) {
|
static std::string shortKey(const std::string& key) {
|
||||||
// VLCOVGEN_SHORT_AUTO_EDIT_BEGIN
|
// VLCOVGEN_SHORT_AUTO_EDIT_BEGIN
|
||||||
if (key == "col0") return VL_CIK_COL0;
|
if (key == "col0") return VL_CIK_COL0;
|
||||||
if (key == "col0_name") return VL_CIK_COL0_NAME;
|
if (key == "col0_name") return VL_CIK_COL0_NAME;
|
||||||
|
|
|
||||||
|
|
@ -40,7 +40,7 @@
|
||||||
|
|
||||||
// Not supported yet
|
// Not supported yet
|
||||||
#define _VL_SVDPI_UNIMP() \
|
#define _VL_SVDPI_UNIMP() \
|
||||||
vl_fatal(__FILE__,__LINE__,"",(string("%%Error: Unsupported DPI function: ")+VL_FUNC).c_str())
|
vl_fatal(__FILE__,__LINE__,"",(std::string("%%Error: Unsupported DPI function: ")+VL_FUNC).c_str())
|
||||||
|
|
||||||
// Function requires a "context" in the import declaration
|
// Function requires a "context" in the import declaration
|
||||||
#define _VL_SVDPI_CONTEXT_WARN() \
|
#define _VL_SVDPI_CONTEXT_WARN() \
|
||||||
|
|
|
||||||
|
|
@ -36,49 +36,49 @@
|
||||||
//======================================================================
|
//======================================================================
|
||||||
// Conversion functions
|
// Conversion functions
|
||||||
|
|
||||||
extern string VL_CVT_PACK_STR_NW(int lwords, WDataInP lwp);
|
extern std::string VL_CVT_PACK_STR_NW(int lwords, WDataInP lwp);
|
||||||
inline string VL_CVT_PACK_STR_NQ(QData lhs) {
|
inline std::string VL_CVT_PACK_STR_NQ(QData lhs) {
|
||||||
WData lw[2]; VL_SET_WQ(lw, lhs);
|
WData lw[2]; VL_SET_WQ(lw, lhs);
|
||||||
return VL_CVT_PACK_STR_NW(2, lw);
|
return VL_CVT_PACK_STR_NW(2, lw);
|
||||||
}
|
}
|
||||||
inline string VL_CVT_PACK_STR_NN(const string& lhs) {
|
inline std::string VL_CVT_PACK_STR_NN(const std::string& lhs) {
|
||||||
return lhs;
|
return lhs;
|
||||||
}
|
}
|
||||||
inline string VL_CVT_PACK_STR_NI(IData lhs) {
|
inline std::string VL_CVT_PACK_STR_NI(IData lhs) {
|
||||||
WData lw[1]; lw[0] = lhs;
|
WData lw[1]; lw[0] = lhs;
|
||||||
return VL_CVT_PACK_STR_NW(1, lw);
|
return VL_CVT_PACK_STR_NW(1, lw);
|
||||||
}
|
}
|
||||||
inline string VL_CONCATN_NNN(const string& lhs, const string& rhs) {
|
inline std::string VL_CONCATN_NNN(const std::string& lhs, const std::string& rhs) {
|
||||||
return lhs+rhs;
|
return lhs+rhs;
|
||||||
}
|
}
|
||||||
inline string VL_REPLICATEN_NNQ(int,int,int, const string& lhs, IData rep) {
|
inline std::string VL_REPLICATEN_NNQ(int,int,int, const std::string& lhs, IData rep) {
|
||||||
string out; out.reserve(lhs.length() * rep);
|
std::string out; out.reserve(lhs.length() * rep);
|
||||||
for (unsigned times=0; times<rep; ++times) out += lhs;
|
for (unsigned times=0; times<rep; ++times) out += lhs;
|
||||||
return out;
|
return out;
|
||||||
}
|
}
|
||||||
inline string VL_REPLICATEN_NNI(int obits,int lbits,int rbits, const string& lhs, IData rep) {
|
inline std::string VL_REPLICATEN_NNI(int obits,int lbits,int rbits, const std::string& lhs, IData rep) {
|
||||||
return VL_REPLICATEN_NNQ(obits,lbits,rbits,lhs,rep);
|
return VL_REPLICATEN_NNQ(obits,lbits,rbits,lhs,rep);
|
||||||
}
|
}
|
||||||
|
|
||||||
extern IData VL_FOPEN_NI(const string& filename, IData mode);
|
extern IData VL_FOPEN_NI(const std::string& filename, IData mode);
|
||||||
extern void VL_READMEM_N(bool hex, int width, int depth, int array_lsb, int fnwords,
|
extern void VL_READMEM_N(bool hex, int width, int depth, int array_lsb, int fnwords,
|
||||||
const string& ofilename, void* memp, IData start, IData end);
|
const std::string& ofilename, void* memp, IData start, IData end);
|
||||||
extern IData VL_SSCANF_INX(int lbits, const string& ld, const char* formatp, ...);
|
extern IData VL_SSCANF_INX(int lbits, const std::string& ld, const char* formatp, ...);
|
||||||
extern void VL_SFORMAT_X(int obits_ignored, string &output, const char* formatp, ...);
|
extern void VL_SFORMAT_X(int obits_ignored, std::string &output, const char* formatp, ...);
|
||||||
extern string VL_SFORMATF_NX(const char* formatp, ...);
|
extern std::string VL_SFORMATF_NX(const char* formatp, ...);
|
||||||
extern IData VL_VALUEPLUSARGS_INW(int rbits, const string& ld, WDataOutP rdp);
|
extern IData VL_VALUEPLUSARGS_INW(int rbits, const std::string& ld, WDataOutP rdp);
|
||||||
inline IData VL_VALUEPLUSARGS_INI(int rbits, const string& ld, IData& rdr) {
|
inline IData VL_VALUEPLUSARGS_INI(int rbits, const std::string& ld, IData& rdr) {
|
||||||
WData rwp[2]; // WData must always be at least 2
|
WData rwp[2]; // WData must always be at least 2
|
||||||
IData got = VL_VALUEPLUSARGS_INW(rbits,ld,rwp);
|
IData got = VL_VALUEPLUSARGS_INW(rbits,ld,rwp);
|
||||||
if (got) rdr = rwp[0];
|
if (got) rdr = rwp[0];
|
||||||
return got;
|
return got;
|
||||||
}
|
}
|
||||||
inline IData VL_VALUEPLUSARGS_INQ(int rbits, const string& ld, QData& rdr) {
|
inline IData VL_VALUEPLUSARGS_INQ(int rbits, const std::string& ld, QData& rdr) {
|
||||||
WData rwp[2];
|
WData rwp[2];
|
||||||
IData got = VL_VALUEPLUSARGS_INW(rbits,ld,rwp);
|
IData got = VL_VALUEPLUSARGS_INW(rbits,ld,rwp);
|
||||||
if (got) rdr = VL_SET_QW(rwp);
|
if (got) rdr = VL_SET_QW(rwp);
|
||||||
return got;
|
return got;
|
||||||
}
|
}
|
||||||
extern IData VL_VALUEPLUSARGS_INN(int, const string& ld, string& rdr);
|
extern IData VL_VALUEPLUSARGS_INN(int, const std::string& ld, std::string& rdr);
|
||||||
|
|
||||||
#endif // Guard
|
#endif // Guard
|
||||||
|
|
|
||||||
|
|
@ -47,9 +47,9 @@ class VerilatedImp {
|
||||||
// Whole class is internal use only - Global information shared between verilated*.cpp files.
|
// Whole class is internal use only - Global information shared between verilated*.cpp files.
|
||||||
|
|
||||||
// TYPES
|
// TYPES
|
||||||
typedef vector<string> ArgVec;
|
typedef std::vector<std::string> ArgVec;
|
||||||
typedef map<pair<const void*,void*>,void*> UserMap;
|
typedef std::map<std::pair<const void*,void*>,void*> UserMap;
|
||||||
typedef map<const char*, int, VerilatedCStrCmp> ExportNameMap;
|
typedef std::map<const char*, int, VerilatedCStrCmp> ExportNameMap;
|
||||||
|
|
||||||
// MEMBERS
|
// MEMBERS
|
||||||
static VerilatedImp s_s; ///< Static Singleton; One and only static this
|
static VerilatedImp s_s; ///< Static Singleton; One and only static this
|
||||||
|
|
@ -65,8 +65,8 @@ class VerilatedImp {
|
||||||
int m_exportNext; ///< Next export funcnum
|
int m_exportNext; ///< Next export funcnum
|
||||||
|
|
||||||
// File I/O
|
// File I/O
|
||||||
vector<FILE*> m_fdps; ///< File descriptors
|
std::vector<FILE*> m_fdps; ///< File descriptors
|
||||||
deque<IData> m_fdFree; ///< List of free descriptors (SLOW - FOPEN/CLOSE only)
|
std::deque<IData> m_fdFree; ///< List of free descriptors (SLOW - FOPEN/CLOSE only)
|
||||||
|
|
||||||
public: // But only for verilated*.cpp
|
public: // But only for verilated*.cpp
|
||||||
// CONSTRUCTORS
|
// CONSTRUCTORS
|
||||||
|
|
@ -100,7 +100,7 @@ public: // But only for verilated*.cpp
|
||||||
for (int i=0; i<argc; ++i) s_s.m_argVec.push_back(argv[i]);
|
for (int i=0; i<argc; ++i) s_s.m_argVec.push_back(argv[i]);
|
||||||
s_s.m_argVecLoaded = true; // Can't just test later for empty vector, no arguments is ok
|
s_s.m_argVecLoaded = true; // Can't just test later for empty vector, no arguments is ok
|
||||||
}
|
}
|
||||||
static string argPlusMatch(const char* prefixp) {
|
static std::string argPlusMatch(const char* prefixp) {
|
||||||
// Note prefixp does not include the leading "+"
|
// Note prefixp does not include the leading "+"
|
||||||
size_t len = strlen(prefixp);
|
size_t len = strlen(prefixp);
|
||||||
if (VL_UNLIKELY(!s_s.m_argVecLoaded)) {
|
if (VL_UNLIKELY(!s_s.m_argVecLoaded)) {
|
||||||
|
|
@ -122,13 +122,13 @@ public: // But only for verilated*.cpp
|
||||||
// There's often many more scopes than userdata's and thus having a ~48byte
|
// There's often many more scopes than userdata's and thus having a ~48byte
|
||||||
// per map overhead * N scopes would take much more space and cache thrashing.
|
// per map overhead * N scopes would take much more space and cache thrashing.
|
||||||
static inline void userInsert(const void* scopep, void* userKey, void* userData) {
|
static inline void userInsert(const void* scopep, void* userKey, void* userData) {
|
||||||
UserMap::iterator it=s_s.m_userMap.find(make_pair(scopep,userKey));
|
UserMap::iterator it=s_s.m_userMap.find(std::make_pair(scopep,userKey));
|
||||||
if (it != s_s.m_userMap.end()) it->second = userData;
|
if (it != s_s.m_userMap.end()) it->second = userData;
|
||||||
// When we support VL_THREADs, we need a lock around this insert, as it's runtime
|
// When we support VL_THREADs, we need a lock around this insert, as it's runtime
|
||||||
else s_s.m_userMap.insert(it, make_pair(make_pair(scopep,userKey),userData));
|
else s_s.m_userMap.insert(it, std::make_pair(std::make_pair(scopep,userKey),userData));
|
||||||
}
|
}
|
||||||
static inline void* userFind(const void* scopep, void* userKey) {
|
static inline void* userFind(const void* scopep, void* userKey) {
|
||||||
UserMap::iterator it=s_s.m_userMap.find(make_pair(scopep,userKey));
|
UserMap::iterator it=s_s.m_userMap.find(std::make_pair(scopep,userKey));
|
||||||
if (VL_LIKELY(it != s_s.m_userMap.end())) return it->second;
|
if (VL_LIKELY(it != s_s.m_userMap.end())) return it->second;
|
||||||
else return NULL;
|
else return NULL;
|
||||||
}
|
}
|
||||||
|
|
@ -159,7 +159,7 @@ public: // But only for verilated*.cpp
|
||||||
// Slow ok - called once/scope at construction
|
// Slow ok - called once/scope at construction
|
||||||
VerilatedScopeNameMap::iterator it=s_s.m_nameMap.find(scopep->name());
|
VerilatedScopeNameMap::iterator it=s_s.m_nameMap.find(scopep->name());
|
||||||
if (it == s_s.m_nameMap.end()) {
|
if (it == s_s.m_nameMap.end()) {
|
||||||
s_s.m_nameMap.insert(it, make_pair(scopep->name(),scopep));
|
s_s.m_nameMap.insert(it, std::make_pair(scopep->name(),scopep));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
static inline const VerilatedScope* scopeFind(const char* namep) {
|
static inline const VerilatedScope* scopeFind(const char* namep) {
|
||||||
|
|
@ -198,7 +198,7 @@ public: // But only for verilated*.cpp
|
||||||
// Slow ok - called once/function at creation
|
// Slow ok - called once/function at creation
|
||||||
ExportNameMap::iterator it=s_s.m_exportMap.find(namep);
|
ExportNameMap::iterator it=s_s.m_exportMap.find(namep);
|
||||||
if (it == s_s.m_exportMap.end()) {
|
if (it == s_s.m_exportMap.end()) {
|
||||||
s_s.m_exportMap.insert(it, make_pair(namep, s_s.m_exportNext++));
|
s_s.m_exportMap.insert(it, std::make_pair(namep, s_s.m_exportNext++));
|
||||||
return s_s.m_exportNext++;
|
return s_s.m_exportNext++;
|
||||||
} else {
|
} else {
|
||||||
return it->second;
|
return it->second;
|
||||||
|
|
@ -207,8 +207,8 @@ public: // But only for verilated*.cpp
|
||||||
static int exportFind(const char* namep) {
|
static int exportFind(const char* namep) {
|
||||||
ExportNameMap::iterator it=s_s.m_exportMap.find(namep);
|
ExportNameMap::iterator it=s_s.m_exportMap.find(namep);
|
||||||
if (VL_LIKELY(it != s_s.m_exportMap.end())) return it->second;
|
if (VL_LIKELY(it != s_s.m_exportMap.end())) return it->second;
|
||||||
string msg = (string("%Error: Testbench C called ")+namep
|
std::string msg = (std::string("%Error: Testbench C called ")+namep
|
||||||
+" but no such DPI export function name exists in ANY model");
|
+" but no such DPI export function name exists in ANY model");
|
||||||
vl_fatal("unknown",0,"", msg.c_str());
|
vl_fatal("unknown",0,"", msg.c_str());
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -60,8 +60,8 @@ bool VerilatedDeserialize::readDiffers (const void* __restrict datap, size_t siz
|
||||||
|
|
||||||
VerilatedDeserialize& VerilatedDeserialize::readAssert (const void* __restrict datap, size_t size) {
|
VerilatedDeserialize& VerilatedDeserialize::readAssert (const void* __restrict datap, size_t size) {
|
||||||
if (VL_UNLIKELY(readDiffers(datap,size))) {
|
if (VL_UNLIKELY(readDiffers(datap,size))) {
|
||||||
string fn = filename();
|
std::string fn = filename();
|
||||||
string msg = (string)"Can't deserialize save-restore file as was made from different model";
|
std::string msg = (std::string)"Can't deserialize save-restore file as was made from different model";
|
||||||
vl_fatal(fn.c_str(), 0, "", msg.c_str());
|
vl_fatal(fn.c_str(), 0, "", msg.c_str());
|
||||||
close();
|
close();
|
||||||
}
|
}
|
||||||
|
|
@ -81,8 +81,8 @@ void VerilatedSerialize::header() {
|
||||||
void VerilatedDeserialize::header() {
|
void VerilatedDeserialize::header() {
|
||||||
VerilatedDeserialize& os = *this; // So can cut and paste standard >> code below
|
VerilatedDeserialize& os = *this; // So can cut and paste standard >> code below
|
||||||
if (VL_UNLIKELY(os.readDiffers(VLTSAVE_HEADER_STR, strlen(VLTSAVE_HEADER_STR)))) {
|
if (VL_UNLIKELY(os.readDiffers(VLTSAVE_HEADER_STR, strlen(VLTSAVE_HEADER_STR)))) {
|
||||||
string fn = filename();
|
std::string fn = filename();
|
||||||
string msg = (string)"Can't deserialize; file has wrong header signature";
|
std::string msg = (std::string)"Can't deserialize; file has wrong header signature";
|
||||||
vl_fatal(fn.c_str(), 0, "", msg.c_str());
|
vl_fatal(fn.c_str(), 0, "", msg.c_str());
|
||||||
close();
|
close();
|
||||||
}
|
}
|
||||||
|
|
@ -98,8 +98,8 @@ void VerilatedSerialize::trailer() {
|
||||||
void VerilatedDeserialize::trailer() {
|
void VerilatedDeserialize::trailer() {
|
||||||
VerilatedDeserialize& os = *this; // So can cut and paste standard >> code below
|
VerilatedDeserialize& os = *this; // So can cut and paste standard >> code below
|
||||||
if (VL_UNLIKELY(os.readDiffers(VLTSAVE_TRAILER_STR, strlen(VLTSAVE_TRAILER_STR)))) {
|
if (VL_UNLIKELY(os.readDiffers(VLTSAVE_TRAILER_STR, strlen(VLTSAVE_TRAILER_STR)))) {
|
||||||
string fn = filename();
|
std::string fn = filename();
|
||||||
string msg = (string)"Can't deserialize; file has wrong end-of-file signature";
|
std::string msg = (std::string)"Can't deserialize; file has wrong end-of-file signature";
|
||||||
vl_fatal(fn.c_str(), 0, "", msg.c_str());
|
vl_fatal(fn.c_str(), 0, "", msg.c_str());
|
||||||
close();
|
close();
|
||||||
}
|
}
|
||||||
|
|
@ -187,7 +187,7 @@ void VerilatedSave::flush() {
|
||||||
} else if (got < 0) {
|
} else if (got < 0) {
|
||||||
if (errno != EAGAIN && errno != EINTR) {
|
if (errno != EAGAIN && errno != EINTR) {
|
||||||
// write failed, presume error (perhaps out of disk space)
|
// write failed, presume error (perhaps out of disk space)
|
||||||
string msg = string(__FUNCTION__)+": "+strerror(errno);
|
std::string msg = std::string(__FUNCTION__)+": "+strerror(errno);
|
||||||
vl_fatal("",0,"",msg.c_str());
|
vl_fatal("",0,"",msg.c_str());
|
||||||
close();
|
close();
|
||||||
break;
|
break;
|
||||||
|
|
@ -215,7 +215,7 @@ void VerilatedRestore::fill() {
|
||||||
} else if (got < 0) {
|
} else if (got < 0) {
|
||||||
if (errno != EAGAIN && errno != EINTR) {
|
if (errno != EAGAIN && errno != EINTR) {
|
||||||
// write failed, presume error (perhaps out of disk space)
|
// write failed, presume error (perhaps out of disk space)
|
||||||
string msg = string(__FUNCTION__)+": "+strerror(errno);
|
std::string msg = std::string(__FUNCTION__)+": "+strerror(errno);
|
||||||
vl_fatal("",0,"",msg.c_str());
|
vl_fatal("",0,"",msg.c_str());
|
||||||
close();
|
close();
|
||||||
break;
|
break;
|
||||||
|
|
|
||||||
|
|
@ -25,7 +25,6 @@
|
||||||
#include "verilatedos.h"
|
#include "verilatedos.h"
|
||||||
|
|
||||||
#include <string>
|
#include <string>
|
||||||
using namespace std;
|
|
||||||
|
|
||||||
//=============================================================================
|
//=============================================================================
|
||||||
// VerilatedSerialBase - internal base class for common code between VerilatedSerialize and VerilatedDeserialize
|
// VerilatedSerialBase - internal base class for common code between VerilatedSerialize and VerilatedDeserialize
|
||||||
|
|
@ -37,7 +36,7 @@ protected:
|
||||||
vluint8_t* m_cp; ///< Current pointer into m_bufp buffer
|
vluint8_t* m_cp; ///< Current pointer into m_bufp buffer
|
||||||
vluint8_t* m_bufp; ///< Output buffer
|
vluint8_t* m_bufp; ///< Output buffer
|
||||||
bool m_isOpen; ///< True indicates open file/stream
|
bool m_isOpen; ///< True indicates open file/stream
|
||||||
string m_filename;
|
std::string m_filename;
|
||||||
|
|
||||||
inline static size_t bufferSize() { return 256*1024; } // See below for slack calculation
|
inline static size_t bufferSize() { return 256*1024; } // See below for slack calculation
|
||||||
inline static size_t bufferInsertSize() { return 16*1024; }
|
inline static size_t bufferInsertSize() { return 16*1024; }
|
||||||
|
|
@ -58,7 +57,7 @@ public:
|
||||||
}
|
}
|
||||||
// METHODS
|
// METHODS
|
||||||
bool isOpen() const { return m_isOpen; }
|
bool isOpen() const { return m_isOpen; }
|
||||||
string filename() const { return m_filename; }
|
std::string filename() const { return m_filename; }
|
||||||
virtual void close() { flush(); }
|
virtual void close() { flush(); }
|
||||||
virtual void flush() {}
|
virtual void flush() {}
|
||||||
};
|
};
|
||||||
|
|
@ -150,7 +149,7 @@ public:
|
||||||
virtual ~VerilatedSave() { close(); }
|
virtual ~VerilatedSave() { close(); }
|
||||||
// METHODS
|
// METHODS
|
||||||
void open(const char* filenamep); ///< Open the file; call isOpen() to see if errors
|
void open(const char* filenamep); ///< Open the file; call isOpen() to see if errors
|
||||||
void open(const string& filename) { open(filename.c_str()); }
|
void open(const std::string& filename) { open(filename.c_str()); }
|
||||||
virtual void close();
|
virtual void close();
|
||||||
virtual void flush();
|
virtual void flush();
|
||||||
};
|
};
|
||||||
|
|
@ -169,7 +168,7 @@ public:
|
||||||
|
|
||||||
// METHODS
|
// METHODS
|
||||||
void open(const char* filenamep); ///< Open the file; call isOpen() to see if errors
|
void open(const char* filenamep); ///< Open the file; call isOpen() to see if errors
|
||||||
void open(const string& filename) { open(filename.c_str()); }
|
void open(const std::string& filename) { open(filename.c_str()); }
|
||||||
virtual void close();
|
virtual void close();
|
||||||
virtual void flush() {}
|
virtual void flush() {}
|
||||||
virtual void fill();
|
virtual void fill();
|
||||||
|
|
@ -219,12 +218,12 @@ inline VerilatedSerialize& operator<<(VerilatedSerialize& os, float& rhs) {
|
||||||
inline VerilatedDeserialize& operator>>(VerilatedDeserialize& os, float& rhs) {
|
inline VerilatedDeserialize& operator>>(VerilatedDeserialize& os, float& rhs) {
|
||||||
return os.read(&rhs, sizeof(rhs));
|
return os.read(&rhs, sizeof(rhs));
|
||||||
}
|
}
|
||||||
inline VerilatedSerialize& operator<<(VerilatedSerialize& os, string& rhs) {
|
inline VerilatedSerialize& operator<<(VerilatedSerialize& os, std::string& rhs) {
|
||||||
vluint32_t len=rhs.length();
|
vluint32_t len=rhs.length();
|
||||||
os<<len;
|
os<<len;
|
||||||
return os.write(rhs.data(), len);
|
return os.write(rhs.data(), len);
|
||||||
}
|
}
|
||||||
inline VerilatedDeserialize& operator>>(VerilatedDeserialize& os, string& rhs) {
|
inline VerilatedDeserialize& operator>>(VerilatedDeserialize& os, std::string& rhs) {
|
||||||
vluint32_t len=0;
|
vluint32_t len=0;
|
||||||
os>>len;
|
os>>len;
|
||||||
rhs.resize(len);
|
rhs.resize(len);
|
||||||
|
|
|
||||||
|
|
@ -91,13 +91,14 @@ struct VerilatedCStrCmp {
|
||||||
};
|
};
|
||||||
|
|
||||||
class VerilatedScopeNameMap
|
class VerilatedScopeNameMap
|
||||||
: public map<const char*, const VerilatedScope*, VerilatedCStrCmp> {
|
: public std::map<const char*, const VerilatedScope*, VerilatedCStrCmp> {
|
||||||
public:
|
public:
|
||||||
VerilatedScopeNameMap() {}
|
VerilatedScopeNameMap() {}
|
||||||
~VerilatedScopeNameMap() {}
|
~VerilatedScopeNameMap() {}
|
||||||
};
|
};
|
||||||
|
|
||||||
class VerilatedVarNameMap : public map<const char*, VerilatedVar, VerilatedCStrCmp> {
|
class VerilatedVarNameMap
|
||||||
|
: public std::map<const char*, VerilatedVar, VerilatedCStrCmp> {
|
||||||
public:
|
public:
|
||||||
VerilatedVarNameMap() {}
|
VerilatedVarNameMap() {}
|
||||||
~VerilatedVarNameMap() {}
|
~VerilatedVarNameMap() {}
|
||||||
|
|
|
||||||
|
|
@ -49,7 +49,7 @@
|
||||||
//=============================================================================
|
//=============================================================================
|
||||||
// Global
|
// Global
|
||||||
|
|
||||||
vector<VerilatedVcd*> VerilatedVcd::s_vcdVecp; ///< List of all created traces
|
VerilatedVcd::VcdVec VerilatedVcd::s_vcdVecp; ///< List of all created traces
|
||||||
|
|
||||||
//=============================================================================
|
//=============================================================================
|
||||||
// VerilatedVcdCallInfo
|
// VerilatedVcdCallInfo
|
||||||
|
|
@ -79,7 +79,7 @@ protected:
|
||||||
//=============================================================================
|
//=============================================================================
|
||||||
// VerilatedVcdFile
|
// VerilatedVcdFile
|
||||||
|
|
||||||
bool VerilatedVcdFile::open(const string& name) {
|
bool VerilatedVcdFile::open(const std::string& name) {
|
||||||
m_fd = ::open(name.c_str(), O_CREAT|O_WRONLY|O_TRUNC|O_LARGEFILE|O_NONBLOCK, 0666);
|
m_fd = ::open(name.c_str(), O_CREAT|O_WRONLY|O_TRUNC|O_LARGEFILE|O_NONBLOCK, 0666);
|
||||||
return (m_fd>=0);
|
return (m_fd>=0);
|
||||||
}
|
}
|
||||||
|
|
@ -150,7 +150,7 @@ void VerilatedVcd::openNext (bool incFilename) {
|
||||||
closePrev(); // Close existing
|
closePrev(); // Close existing
|
||||||
if (incFilename) {
|
if (incFilename) {
|
||||||
// Find _0000.{ext} in filename
|
// Find _0000.{ext} in filename
|
||||||
string name = m_filename;
|
std::string name = m_filename;
|
||||||
size_t pos=name.rfind(".");
|
size_t pos=name.rfind(".");
|
||||||
if (pos>8 && 0==strncmp("_cat",name.c_str()+pos-8,4)
|
if (pos>8 && 0==strncmp("_cat",name.c_str()+pos-8,4)
|
||||||
&& isdigit(name.c_str()[pos-4])
|
&& isdigit(name.c_str()[pos-4])
|
||||||
|
|
@ -205,18 +205,18 @@ void VerilatedVcd::makeNameMap() {
|
||||||
// This comes from user instantiations with no name - IE Vtop("").
|
// This comes from user instantiations with no name - IE Vtop("").
|
||||||
bool nullScope = false;
|
bool nullScope = false;
|
||||||
for (NameMap::iterator it=m_namemapp->begin(); it!=m_namemapp->end(); ++it) {
|
for (NameMap::iterator it=m_namemapp->begin(); it!=m_namemapp->end(); ++it) {
|
||||||
const string& hiername = it->first;
|
const std::string& hiername = it->first;
|
||||||
if (hiername.size() >= 1 && hiername[0] == '\t') nullScope=true;
|
if (hiername.size() >= 1 && hiername[0] == '\t') nullScope=true;
|
||||||
}
|
}
|
||||||
if (nullScope) {
|
if (nullScope) {
|
||||||
NameMap* newmapp = new NameMap;
|
NameMap* newmapp = new NameMap;
|
||||||
for (NameMap::iterator it=m_namemapp->begin(); it!=m_namemapp->end(); ++it) {
|
for (NameMap::iterator it=m_namemapp->begin(); it!=m_namemapp->end(); ++it) {
|
||||||
const string& hiername = it->first;
|
const std::string& hiername = it->first;
|
||||||
const string& decl = it->second;
|
const std::string& decl = it->second;
|
||||||
string newname = string("top");
|
std::string newname = std::string("top");
|
||||||
if (hiername[0] != '\t') newname += ' ';
|
if (hiername[0] != '\t') newname += ' ';
|
||||||
newname += hiername;
|
newname += hiername;
|
||||||
newmapp->insert(make_pair(newname,decl));
|
newmapp->insert(std::make_pair(newname,decl));
|
||||||
}
|
}
|
||||||
deleteNameMap();
|
deleteNameMap();
|
||||||
m_namemapp = newmapp;
|
m_namemapp = newmapp;
|
||||||
|
|
@ -234,7 +234,7 @@ VerilatedVcd::~VerilatedVcd() {
|
||||||
deleteNameMap();
|
deleteNameMap();
|
||||||
if (m_filep && m_fileNewed) { delete m_filep; m_filep = NULL; }
|
if (m_filep && m_fileNewed) { delete m_filep; m_filep = NULL; }
|
||||||
// Remove from list of traces
|
// Remove from list of traces
|
||||||
vector<VerilatedVcd*>::iterator pos = find(s_vcdVecp.begin(), s_vcdVecp.end(), this);
|
VcdVec::iterator pos = find(s_vcdVecp.begin(), s_vcdVecp.end(), this);
|
||||||
if (pos != s_vcdVecp.end()) { s_vcdVecp.erase(pos); }
|
if (pos != s_vcdVecp.end()) { s_vcdVecp.erase(pos); }
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -326,7 +326,7 @@ void VerilatedVcd::bufferFlush () {
|
||||||
} else if (got < 0) {
|
} else if (got < 0) {
|
||||||
if (errno != EAGAIN && errno != EINTR) {
|
if (errno != EAGAIN && errno != EINTR) {
|
||||||
// write failed, presume error (perhaps out of disk space)
|
// write failed, presume error (perhaps out of disk space)
|
||||||
string msg = (string)"VerilatedVcd::bufferFlush: "+strerror(errno);
|
std::string msg = (std::string)"VerilatedVcd::bufferFlush: "+strerror(errno);
|
||||||
vl_fatal("",0,"",msg.c_str());
|
vl_fatal("",0,"",msg.c_str());
|
||||||
closeErr();
|
closeErr();
|
||||||
break;
|
break;
|
||||||
|
|
@ -369,7 +369,7 @@ double VerilatedVcd::timescaleToDouble (const char* unitp) {
|
||||||
return value;
|
return value;
|
||||||
}
|
}
|
||||||
|
|
||||||
string VerilatedVcd::doubleToTimescale (double value) {
|
std::string VerilatedVcd::doubleToTimescale (double value) {
|
||||||
const char* suffixp = "s";
|
const char* suffixp = "s";
|
||||||
if (value>=1e0) { suffixp="s"; value *= 1e0; }
|
if (value>=1e0) { suffixp="s"; value *= 1e0; }
|
||||||
else if (value>=1e-3 ) { suffixp="ms"; value *= 1e3; }
|
else if (value>=1e-3 ) { suffixp="ms"; value *= 1e3; }
|
||||||
|
|
@ -398,7 +398,7 @@ void VerilatedVcd::dumpHeader () {
|
||||||
printStr("$date "); printStr(ctime(&time_str)); printStr(" $end\n");
|
printStr("$date "); printStr(ctime(&time_str)); printStr(" $end\n");
|
||||||
|
|
||||||
printStr("$timescale ");
|
printStr("$timescale ");
|
||||||
const string& timeResStr = doubleToTimescale(m_timeRes);
|
const std::string& timeResStr = doubleToTimescale(m_timeRes);
|
||||||
printStr(timeResStr.c_str());
|
printStr(timeResStr.c_str());
|
||||||
printStr(" $end\n");
|
printStr(" $end\n");
|
||||||
|
|
||||||
|
|
@ -417,8 +417,8 @@ void VerilatedVcd::dumpHeader () {
|
||||||
// Print the signal names
|
// Print the signal names
|
||||||
const char* lastName = "";
|
const char* lastName = "";
|
||||||
for (NameMap::iterator it=m_namemapp->begin(); it!=m_namemapp->end(); ++it) {
|
for (NameMap::iterator it=m_namemapp->begin(); it!=m_namemapp->end(); ++it) {
|
||||||
const string& hiernamestr = it->first;
|
const std::string& hiernamestr = it->first;
|
||||||
const string& decl = it->second;
|
const std::string& decl = it->second;
|
||||||
|
|
||||||
// Determine difference between the old and new names
|
// Determine difference between the old and new names
|
||||||
const char* hiername = hiernamestr.c_str();
|
const char* hiername = hiernamestr.c_str();
|
||||||
|
|
@ -472,7 +472,7 @@ void VerilatedVcd::dumpHeader () {
|
||||||
deleteNameMap();
|
deleteNameMap();
|
||||||
}
|
}
|
||||||
|
|
||||||
void VerilatedVcd::module (const string& name) {
|
void VerilatedVcd::module (const std::string& name) {
|
||||||
m_modName = name;
|
m_modName = name;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -485,7 +485,7 @@ void VerilatedVcd::declare (vluint32_t code, const char* name, const char* wirep
|
||||||
if (tri) codesNeeded *= 2; // Space in change array for __en signals
|
if (tri) codesNeeded *= 2; // Space in change array for __en signals
|
||||||
|
|
||||||
// Make sure array is large enough
|
// Make sure array is large enough
|
||||||
m_nextCode = max(nextCode(), code+codesNeeded);
|
m_nextCode = std::max(nextCode(), code+codesNeeded);
|
||||||
if (m_sigs.capacity() <= m_nextCode) {
|
if (m_sigs.capacity() <= m_nextCode) {
|
||||||
m_sigs.reserve(m_nextCode*2); // Power-of-2 allocation speeds things up
|
m_sigs.reserve(m_nextCode*2); // Power-of-2 allocation speeds things up
|
||||||
}
|
}
|
||||||
|
|
@ -503,10 +503,10 @@ void VerilatedVcd::declare (vluint32_t code, const char* name, const char* wirep
|
||||||
// Tab separates final scope from signal name
|
// Tab separates final scope from signal name
|
||||||
// Tab sorts before spaces, so signals nicely will print before scopes
|
// Tab sorts before spaces, so signals nicely will print before scopes
|
||||||
// Note the hiername may be nothing, if so we'll add "\t{name}"
|
// Note the hiername may be nothing, if so we'll add "\t{name}"
|
||||||
string nameasstr = name;
|
std::string nameasstr = name;
|
||||||
if (m_modName!="") { nameasstr = m_modName+m_scopeEscape+nameasstr; } // Optional ->module prefix
|
if (m_modName!="") { nameasstr = m_modName+m_scopeEscape+nameasstr; } // Optional ->module prefix
|
||||||
string hiername;
|
std::string hiername;
|
||||||
string basename;
|
std::string basename;
|
||||||
for (const char* cp=nameasstr.c_str(); *cp; cp++) {
|
for (const char* cp=nameasstr.c_str(); *cp; cp++) {
|
||||||
if (isScopeEscape(*cp)) {
|
if (isScopeEscape(*cp)) {
|
||||||
// Ahh, we've just read a scope, not a basename
|
// Ahh, we've just read a scope, not a basename
|
||||||
|
|
@ -520,7 +520,7 @@ void VerilatedVcd::declare (vluint32_t code, const char* name, const char* wirep
|
||||||
hiername += "\t"+basename;
|
hiername += "\t"+basename;
|
||||||
|
|
||||||
// Print reference
|
// Print reference
|
||||||
string decl = "$var ";
|
std::string decl = "$var ";
|
||||||
if (m_evcd) decl += "port"; else decl += wirep; // usually "wire"
|
if (m_evcd) decl += "port"; else decl += wirep; // usually "wire"
|
||||||
char buf [1000];
|
char buf [1000];
|
||||||
sprintf(buf, " %2d ", bits);
|
sprintf(buf, " %2d ", bits);
|
||||||
|
|
@ -543,7 +543,7 @@ void VerilatedVcd::declare (vluint32_t code, const char* name, const char* wirep
|
||||||
decl += buf;
|
decl += buf;
|
||||||
}
|
}
|
||||||
decl += " $end\n";
|
decl += " $end\n";
|
||||||
m_namemapp->insert(make_pair(hiername,decl));
|
m_namemapp->insert(std::make_pair(hiername,decl));
|
||||||
}
|
}
|
||||||
|
|
||||||
void VerilatedVcd::declBit (vluint32_t code, const char* name, int arraynum)
|
void VerilatedVcd::declBit (vluint32_t code, const char* name, int arraynum)
|
||||||
|
|
@ -596,7 +596,7 @@ void VerilatedVcd::addCallback (
|
||||||
void* userthis)
|
void* userthis)
|
||||||
{
|
{
|
||||||
if (VL_UNLIKELY(isOpen())) {
|
if (VL_UNLIKELY(isOpen())) {
|
||||||
string msg = (string)"Internal: "+__FILE__+"::"+__FUNCTION__+" called with already open file";
|
std::string msg = (std::string)"Internal: "+__FILE__+"::"+__FUNCTION__+" called with already open file";
|
||||||
vl_fatal(__FILE__,__LINE__,"",msg.c_str());
|
vl_fatal(__FILE__,__LINE__,"",msg.c_str());
|
||||||
}
|
}
|
||||||
VerilatedVcdCallInfo* vci = new VerilatedVcdCallInfo(initcb, fullcb, changecb, userthis, nextCode());
|
VerilatedVcdCallInfo* vci = new VerilatedVcdCallInfo(initcb, fullcb, changecb, userthis, nextCode());
|
||||||
|
|
|
||||||
|
|
@ -28,7 +28,6 @@
|
||||||
#include <string>
|
#include <string>
|
||||||
#include <vector>
|
#include <vector>
|
||||||
#include <map>
|
#include <map>
|
||||||
using namespace std;
|
|
||||||
|
|
||||||
class VerilatedVcd;
|
class VerilatedVcd;
|
||||||
class VerilatedVcdCallInfo;
|
class VerilatedVcdCallInfo;
|
||||||
|
|
@ -45,7 +44,7 @@ public:
|
||||||
// METHODS
|
// METHODS
|
||||||
VerilatedVcdFile() : m_fd(0) {}
|
VerilatedVcdFile() : m_fd(0) {}
|
||||||
virtual ~VerilatedVcdFile() {}
|
virtual ~VerilatedVcdFile() {}
|
||||||
virtual bool open(const string& name);
|
virtual bool open(const std::string& name);
|
||||||
virtual void close();
|
virtual void close();
|
||||||
virtual ssize_t write(const char* bufp, ssize_t len);
|
virtual ssize_t write(const char* bufp, ssize_t len);
|
||||||
};
|
};
|
||||||
|
|
@ -80,13 +79,13 @@ private:
|
||||||
bool m_fileNewed; ///< m_filep needs destruction
|
bool m_fileNewed; ///< m_filep needs destruction
|
||||||
bool m_isOpen; ///< True indicates open file
|
bool m_isOpen; ///< True indicates open file
|
||||||
bool m_evcd; ///< True for evcd format
|
bool m_evcd; ///< True for evcd format
|
||||||
string m_filename; ///< Filename we're writing to (if open)
|
std::string m_filename; ///< Filename we're writing to (if open)
|
||||||
vluint64_t m_rolloverMB; ///< MB of file size to rollover at
|
vluint64_t m_rolloverMB; ///< MB of file size to rollover at
|
||||||
char m_scopeEscape; ///< Character to separate scope components
|
char m_scopeEscape; ///< Character to separate scope components
|
||||||
int m_modDepth; ///< Depth of module hierarchy
|
int m_modDepth; ///< Depth of module hierarchy
|
||||||
bool m_fullDump; ///< True indicates dump ignoring if changed
|
bool m_fullDump; ///< True indicates dump ignoring if changed
|
||||||
vluint32_t m_nextCode; ///< Next code number to assign
|
vluint32_t m_nextCode; ///< Next code number to assign
|
||||||
string m_modName; ///< Module name being traced now
|
std::string m_modName; ///< Module name being traced now
|
||||||
double m_timeRes; ///< Time resolution (ns/ms etc)
|
double m_timeRes; ///< Time resolution (ns/ms etc)
|
||||||
double m_timeUnit; ///< Time units (ns/ms etc)
|
double m_timeUnit; ///< Time units (ns/ms etc)
|
||||||
vluint64_t m_timeLastDump; ///< Last time we did a dump
|
vluint64_t m_timeLastDump; ///< Last time we did a dump
|
||||||
|
|
@ -98,11 +97,12 @@ private:
|
||||||
vluint64_t m_wroteBytes; ///< Number of bytes written to this file
|
vluint64_t m_wroteBytes; ///< Number of bytes written to this file
|
||||||
|
|
||||||
vluint32_t* m_sigs_oldvalp; ///< Pointer to old signal values
|
vluint32_t* m_sigs_oldvalp; ///< Pointer to old signal values
|
||||||
vector<VerilatedVcdSig> m_sigs; ///< Pointer to signal information
|
std::vector<VerilatedVcdSig> m_sigs; ///< Pointer to signal information
|
||||||
vector<VerilatedVcdCallInfo*> m_callbacks; ///< Routines to perform dumping
|
std::vector<VerilatedVcdCallInfo*> m_callbacks; ///< Routines to perform dumping
|
||||||
typedef map<string,string> NameMap;
|
typedef std::map<std::string,std::string> NameMap;
|
||||||
NameMap* m_namemapp; ///< List of names for the header
|
NameMap* m_namemapp; ///< List of names for the header
|
||||||
static vector<VerilatedVcd*> s_vcdVecp; ///< List of all created traces
|
typedef std::vector<VerilatedVcd*> VcdVec;
|
||||||
|
static VcdVec s_vcdVecp; ///< List of all created traces
|
||||||
|
|
||||||
void bufferResize(vluint64_t minsize);
|
void bufferResize(vluint64_t minsize);
|
||||||
void bufferFlush();
|
void bufferFlush();
|
||||||
|
|
@ -136,8 +136,8 @@ private:
|
||||||
if (code>=(94)) *m_writep++ = ((char)((code/94)%94+33));
|
if (code>=(94)) *m_writep++ = ((char)((code/94)%94+33));
|
||||||
*m_writep++ = ((char)((code)%94+33));
|
*m_writep++ = ((char)((code)%94+33));
|
||||||
}
|
}
|
||||||
static string stringCode (vluint32_t code) {
|
static std::string stringCode (vluint32_t code) {
|
||||||
string out;
|
std::string out;
|
||||||
if (code>=(94*94*94)) out += ((char)((code/94/94/94)%94+33));
|
if (code>=(94*94*94)) out += ((char)((code/94/94/94)%94+33));
|
||||||
if (code>=(94*94)) out += ((char)((code/94/94)%94+33));
|
if (code>=(94*94)) out += ((char)((code/94/94)%94+33));
|
||||||
if (code>=(94)) out += ((char)((code/94)%94+33));
|
if (code>=(94)) out += ((char)((code/94)%94+33));
|
||||||
|
|
@ -175,13 +175,13 @@ public:
|
||||||
void close (); ///< Close the file
|
void close (); ///< Close the file
|
||||||
|
|
||||||
void set_time_unit (const char* unit); ///< Set time units (s/ms, defaults to ns)
|
void set_time_unit (const char* unit); ///< Set time units (s/ms, defaults to ns)
|
||||||
void set_time_unit (const string& unit) { set_time_unit(unit.c_str()); }
|
void set_time_unit (const std::string& unit) { set_time_unit(unit.c_str()); }
|
||||||
|
|
||||||
void set_time_resolution (const char* unit); ///< Set time resolution (s/ms, defaults to ns)
|
void set_time_resolution (const char* unit); ///< Set time resolution (s/ms, defaults to ns)
|
||||||
void set_time_resolution (const string& unit) { set_time_resolution(unit.c_str()); }
|
void set_time_resolution (const std::string& unit) { set_time_resolution(unit.c_str()); }
|
||||||
|
|
||||||
double timescaleToDouble (const char* unitp);
|
double timescaleToDouble (const char* unitp);
|
||||||
string doubleToTimescale (double value);
|
std::string doubleToTimescale (double value);
|
||||||
|
|
||||||
/// Inside dumping routines, called each cycle to make the dump
|
/// Inside dumping routines, called each cycle to make the dump
|
||||||
void dump (vluint64_t timeui);
|
void dump (vluint64_t timeui);
|
||||||
|
|
@ -194,7 +194,7 @@ public:
|
||||||
void* userthis);
|
void* userthis);
|
||||||
|
|
||||||
/// Inside dumping routines, declare a module
|
/// Inside dumping routines, declare a module
|
||||||
void module (const string& name);
|
void module (const std::string& name);
|
||||||
/// Inside dumping routines, declare a signal
|
/// Inside dumping routines, declare a signal
|
||||||
void declBit (vluint32_t code, const char* name, int arraynum);
|
void declBit (vluint32_t code, const char* name, int arraynum);
|
||||||
void declBus (vluint32_t code, const char* name, int arraynum, int msb, int lsb);
|
void declBus (vluint32_t code, const char* name, int arraynum, int msb, int lsb);
|
||||||
|
|
@ -433,11 +433,11 @@ public:
|
||||||
/// Set time units (s/ms, defaults to ns)
|
/// Set time units (s/ms, defaults to ns)
|
||||||
/// See also VL_TIME_PRECISION, and VL_TIME_MULTIPLIER in verilated.h
|
/// See also VL_TIME_PRECISION, and VL_TIME_MULTIPLIER in verilated.h
|
||||||
void set_time_unit (const char* unit) { m_sptrace.set_time_unit(unit); }
|
void set_time_unit (const char* unit) { m_sptrace.set_time_unit(unit); }
|
||||||
void set_time_unit (const string& unit) { set_time_unit(unit.c_str()); }
|
void set_time_unit (const std::string& unit) { set_time_unit(unit.c_str()); }
|
||||||
/// Set time resolution (s/ms, defaults to ns)
|
/// Set time resolution (s/ms, defaults to ns)
|
||||||
/// See also VL_TIME_PRECISION, and VL_TIME_MULTIPLIER in verilated.h
|
/// See also VL_TIME_PRECISION, and VL_TIME_MULTIPLIER in verilated.h
|
||||||
void set_time_resolution (const char* unit) { m_sptrace.set_time_resolution(unit); }
|
void set_time_resolution (const char* unit) { m_sptrace.set_time_resolution(unit); }
|
||||||
void set_time_resolution (const string& unit) { set_time_resolution(unit.c_str()); }
|
void set_time_resolution (const std::string& unit) { set_time_resolution(unit.c_str()); }
|
||||||
|
|
||||||
/// Internal class access
|
/// Internal class access
|
||||||
inline VerilatedVcd* spTrace () { return &m_sptrace; };
|
inline VerilatedVcd* spTrace () { return &m_sptrace; };
|
||||||
|
|
|
||||||
|
|
@ -386,7 +386,7 @@ const char* VerilatedVpiError::strFromVpiProp(PLI_INT32 vpiVal) {
|
||||||
|
|
||||||
#define CHECK_RESULT_CSTR(got, exp) \
|
#define CHECK_RESULT_CSTR(got, exp) \
|
||||||
if (strcmp((got),(exp))) { \
|
if (strcmp((got),(exp))) { \
|
||||||
string msg = string("%Error: ") \
|
std::string msg = std::string("%Error: ") \
|
||||||
+ "GOT = '"+((got)?(got):"<null>")+"'" \
|
+ "GOT = '"+((got)?(got):"<null>")+"'" \
|
||||||
+ " EXP = '"+((exp)?(exp):"<null>")+"'"; \
|
+ " EXP = '"+((exp)?(exp):"<null>")+"'"; \
|
||||||
vl_fatal(__FILE__,__LINE__,"",msg.c_str()); \
|
vl_fatal(__FILE__,__LINE__,"",msg.c_str()); \
|
||||||
|
|
@ -502,9 +502,9 @@ vpiHandle vpi_handle_by_name(PLI_BYTE8* namep, vpiHandle scope) {
|
||||||
VerilatedVpioScope* voScopep = VerilatedVpioScope::castp(scope);
|
VerilatedVpioScope* voScopep = VerilatedVpioScope::castp(scope);
|
||||||
const VerilatedVar* varp;
|
const VerilatedVar* varp;
|
||||||
const VerilatedScope* scopep;
|
const VerilatedScope* scopep;
|
||||||
string scopeAndName = namep;
|
std::string scopeAndName = namep;
|
||||||
if (voScopep) {
|
if (voScopep) {
|
||||||
scopeAndName = string(voScopep->fullname()) + "." + namep;
|
scopeAndName = std::string(voScopep->fullname()) + "." + namep;
|
||||||
namep = (PLI_BYTE8*)scopeAndName.c_str();
|
namep = (PLI_BYTE8*)scopeAndName.c_str();
|
||||||
}
|
}
|
||||||
{
|
{
|
||||||
|
|
@ -514,11 +514,11 @@ vpiHandle vpi_handle_by_name(PLI_BYTE8* namep, vpiHandle scope) {
|
||||||
return (new VerilatedVpioScope(scopep))->castVpiHandle();
|
return (new VerilatedVpioScope(scopep))->castVpiHandle();
|
||||||
}
|
}
|
||||||
const char* baseNamep = scopeAndName.c_str();
|
const char* baseNamep = scopeAndName.c_str();
|
||||||
string scopename;
|
std::string scopename;
|
||||||
const char* dotp = strrchr(namep, '.');
|
const char* dotp = strrchr(namep, '.');
|
||||||
if (VL_LIKELY(dotp)) {
|
if (VL_LIKELY(dotp)) {
|
||||||
baseNamep = dotp+1;
|
baseNamep = dotp+1;
|
||||||
scopename = string(namep,dotp-namep);
|
scopename = std::string(namep,dotp-namep);
|
||||||
}
|
}
|
||||||
scopep = Verilated::scopeFind(scopename.c_str());
|
scopep = Verilated::scopeFind(scopename.c_str());
|
||||||
if (!scopep) return NULL;
|
if (!scopep) return NULL;
|
||||||
|
|
|
||||||
|
|
@ -215,8 +215,8 @@ public:
|
||||||
virtual const VerilatedRange* rangep() const { return &get_range(); }
|
virtual const VerilatedRange* rangep() const { return &get_range(); }
|
||||||
virtual const char* name() { return m_varp->name(); }
|
virtual const char* name() { return m_varp->name(); }
|
||||||
virtual const char* fullname() {
|
virtual const char* fullname() {
|
||||||
VL_STATIC_OR_THREAD string out;
|
VL_STATIC_OR_THREAD std::string out;
|
||||||
out = string(m_scopep->name())+"."+name();
|
out = std::string(m_scopep->name())+"."+name();
|
||||||
return out.c_str();
|
return out.c_str();
|
||||||
}
|
}
|
||||||
void* prevDatap() const { return m_prevDatap; }
|
void* prevDatap() const { return m_prevDatap; }
|
||||||
|
|
@ -243,9 +243,9 @@ public:
|
||||||
virtual vluint32_t size() const { return varp()->range().elements(); }
|
virtual vluint32_t size() const { return varp()->range().elements(); }
|
||||||
virtual const VerilatedRange* rangep() const { return &(varp()->range()); }
|
virtual const VerilatedRange* rangep() const { return &(varp()->range()); }
|
||||||
virtual const char* fullname() {
|
virtual const char* fullname() {
|
||||||
VL_STATIC_OR_THREAD string out;
|
VL_STATIC_OR_THREAD std::string out;
|
||||||
char num[20]; sprintf(num,"%d",m_index);
|
char num[20]; sprintf(num,"%d",m_index);
|
||||||
out = string(scopep()->name())+"."+name()+"["+num+"]";
|
out = std::string(scopep()->name())+"."+name()+"["+num+"]";
|
||||||
return out.c_str();
|
return out.c_str();
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
@ -301,8 +301,8 @@ public:
|
||||||
|
|
||||||
struct VerilatedVpiTimedCbsCmp {
|
struct VerilatedVpiTimedCbsCmp {
|
||||||
/// Ordering sets keyed by time, then callback descriptor
|
/// Ordering sets keyed by time, then callback descriptor
|
||||||
bool operator() (const pair<QData,VerilatedVpioCb*>& a,
|
bool operator() (const std::pair<QData,VerilatedVpioCb*>& a,
|
||||||
const pair<QData,VerilatedVpioCb*>& b) const {
|
const std::pair<QData,VerilatedVpioCb*>& b) const {
|
||||||
if (a.first < b.first) return 1;
|
if (a.first < b.first) return 1;
|
||||||
if (a.first > b.first) return 0;
|
if (a.first > b.first) return 0;
|
||||||
return a.second < b.second;
|
return a.second < b.second;
|
||||||
|
|
@ -313,8 +313,8 @@ class VerilatedVpiError;
|
||||||
|
|
||||||
class VerilatedVpi {
|
class VerilatedVpi {
|
||||||
enum { CB_ENUM_MAX_VALUE = cbAtEndOfSimTime+1 }; // Maxium callback reason
|
enum { CB_ENUM_MAX_VALUE = cbAtEndOfSimTime+1 }; // Maxium callback reason
|
||||||
typedef list<VerilatedVpioCb*> VpioCbList;
|
typedef std::list<VerilatedVpioCb*> VpioCbList;
|
||||||
typedef set<pair<QData,VerilatedVpioCb*>,VerilatedVpiTimedCbsCmp > VpioTimedCbs;
|
typedef std::set<std::pair<QData,VerilatedVpioCb*>,VerilatedVpiTimedCbsCmp > VpioTimedCbs;
|
||||||
|
|
||||||
struct product_info {
|
struct product_info {
|
||||||
PLI_BYTE8* product;
|
PLI_BYTE8* product;
|
||||||
|
|
@ -339,7 +339,7 @@ public:
|
||||||
s_s.m_cbObjLists[vop->reason()].push_back(vop);
|
s_s.m_cbObjLists[vop->reason()].push_back(vop);
|
||||||
}
|
}
|
||||||
static void cbTimedAdd(VerilatedVpioCb* vop) {
|
static void cbTimedAdd(VerilatedVpioCb* vop) {
|
||||||
s_s.m_timedCbs.insert(make_pair(vop->time(), vop));
|
s_s.m_timedCbs.insert(std::make_pair(vop->time(), vop));
|
||||||
}
|
}
|
||||||
static void cbReasonRemove(VerilatedVpioCb* cbp) {
|
static void cbReasonRemove(VerilatedVpioCb* cbp) {
|
||||||
VpioCbList& cbObjList = s_s.m_cbObjLists[cbp->reason()];
|
VpioCbList& cbObjList = s_s.m_cbObjLists[cbp->reason()];
|
||||||
|
|
@ -350,7 +350,7 @@ public:
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
static void cbTimedRemove(VerilatedVpioCb* cbp) {
|
static void cbTimedRemove(VerilatedVpioCb* cbp) {
|
||||||
VpioTimedCbs::iterator it=s_s.m_timedCbs.find(make_pair(cbp->time(),cbp));
|
VpioTimedCbs::iterator it=s_s.m_timedCbs.find(std::make_pair(cbp->time(),cbp));
|
||||||
if (VL_LIKELY(it != s_s.m_timedCbs.end())) {
|
if (VL_LIKELY(it != s_s.m_timedCbs.end())) {
|
||||||
s_s.m_timedCbs.erase(it);
|
s_s.m_timedCbs.erase(it);
|
||||||
}
|
}
|
||||||
|
|
@ -389,7 +389,8 @@ public:
|
||||||
}
|
}
|
||||||
static void callValueCbs() {
|
static void callValueCbs() {
|
||||||
VpioCbList& cbObjList = s_s.m_cbObjLists[cbValueChange];
|
VpioCbList& cbObjList = s_s.m_cbObjLists[cbValueChange];
|
||||||
set<VerilatedVpioVar*> update; // set of objects to update after callbacks
|
typedef std::set<VerilatedVpioVar*> VpioVarSet;
|
||||||
|
VpioVarSet update; // set of objects to update after callbacks
|
||||||
for (VpioCbList::iterator it=cbObjList.begin(); it!=cbObjList.end();) {
|
for (VpioCbList::iterator it=cbObjList.begin(); it!=cbObjList.end();) {
|
||||||
if (VL_UNLIKELY(!*it)) { // Deleted earlier, cleanup
|
if (VL_UNLIKELY(!*it)) { // Deleted earlier, cleanup
|
||||||
it = cbObjList.erase(it);
|
it = cbObjList.erase(it);
|
||||||
|
|
@ -411,7 +412,7 @@ public:
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
for (set<VerilatedVpioVar*>::iterator it=update.begin(); it!=update.end(); ++it) {
|
for (VpioVarSet::iterator it=update.begin(); it!=update.end(); ++it) {
|
||||||
memcpy((*it)->prevDatap(), (*it)->varDatap(), (*it)->entSize());
|
memcpy((*it)->prevDatap(), (*it)->varDatap(), (*it)->entSize());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
@ -462,8 +463,8 @@ public:
|
||||||
m_errorInfo.level = level;
|
m_errorInfo.level = level;
|
||||||
return this;
|
return this;
|
||||||
}
|
}
|
||||||
void setMessage(string file, PLI_INT32 line, string message, ...) {
|
void setMessage(std::string file, PLI_INT32 line, std::string message, ...) {
|
||||||
static VL_THREAD string filehold;
|
static VL_THREAD std::string filehold;
|
||||||
_VL_VPI_ERROR_SET;
|
_VL_VPI_ERROR_SET;
|
||||||
m_errorInfo.state = vpiPLI;
|
m_errorInfo.state = vpiPLI;
|
||||||
filehold = file;
|
filehold = file;
|
||||||
|
|
|
||||||
|
|
@ -226,7 +226,7 @@ string AstVar::vlArgType(bool named, bool forReturn, bool forFunc) const {
|
||||||
arg += "float";
|
arg += "float";
|
||||||
} else if (strtype) {
|
} else if (strtype) {
|
||||||
if (isInOnly()) arg += "const ";
|
if (isInOnly()) arg += "const ";
|
||||||
arg += "string";
|
arg += "std::string";
|
||||||
} else if (widthMin() <= 8) {
|
} else if (widthMin() <= 8) {
|
||||||
arg += "CData";
|
arg += "CData";
|
||||||
} else if (widthMin() <= 16) {
|
} else if (widthMin() <= 16) {
|
||||||
|
|
|
||||||
|
|
@ -607,7 +607,7 @@ public:
|
||||||
}
|
}
|
||||||
void emitCvtPackStr(AstNode* nodep) {
|
void emitCvtPackStr(AstNode* nodep) {
|
||||||
if (AstConst* constp = nodep->castConst()) {
|
if (AstConst* constp = nodep->castConst()) {
|
||||||
putbs("string(");
|
putbs("std::string(");
|
||||||
putsQuoted(constp->num().toString());
|
putsQuoted(constp->num().toString());
|
||||||
puts(")");
|
puts(")");
|
||||||
} else {
|
} else {
|
||||||
|
|
@ -627,7 +627,7 @@ public:
|
||||||
if (nodep->num().isFourState()) {
|
if (nodep->num().isFourState()) {
|
||||||
nodep->v3error("Unsupported: 4-state numbers in this context");
|
nodep->v3error("Unsupported: 4-state numbers in this context");
|
||||||
} else if (nodep->num().isString()) {
|
} else if (nodep->num().isString()) {
|
||||||
putbs("string(");
|
putbs("std::string(");
|
||||||
putsQuoted(nodep->num().toString());
|
putsQuoted(nodep->num().toString());
|
||||||
puts(")");
|
puts(")");
|
||||||
} else if (nodep->isWide()) {
|
} else if (nodep->isWide()) {
|
||||||
|
|
@ -1558,8 +1558,8 @@ void EmitCImp::emitCoverageImp(AstNodeModule* modp) {
|
||||||
puts( " \"filename\",filenamep,");
|
puts( " \"filename\",filenamep,");
|
||||||
puts( " \"lineno\",lineno,");
|
puts( " \"lineno\",lineno,");
|
||||||
puts( " \"column\",column,\n");
|
puts( " \"column\",column,\n");
|
||||||
//puts( "\"hier\",string(__VlSymsp->name())+hierp,"); // Need to move hier into scopes and back out if do this
|
//puts( "\"hier\",std::string(__VlSymsp->name())+hierp,"); // Need to move hier into scopes and back out if do this
|
||||||
puts( "\"hier\",string(name())+hierp,");
|
puts( "\"hier\",std::string(name())+hierp,");
|
||||||
puts( " \"page\",pagep,");
|
puts( " \"page\",pagep,");
|
||||||
puts( " \"comment\",commentp);\n");
|
puts( " \"comment\",commentp);\n");
|
||||||
puts("}\n");
|
puts("}\n");
|
||||||
|
|
|
||||||
|
|
@ -51,7 +51,7 @@ void mon_class_name(const char* namep) {
|
||||||
VL_PRINTF("- mon_class_name(\"%s\");\n", namep);
|
VL_PRINTF("- mon_class_name(\"%s\");\n", namep);
|
||||||
#endif
|
#endif
|
||||||
// Check the C's calling name of "" doesn't lead to extra dots in the name()
|
// Check the C's calling name of "" doesn't lead to extra dots in the name()
|
||||||
if (namep && namep[0]=='.') vl_fatal(__FILE__,__LINE__,"", (string("Unexp class name ")+namep).c_str());
|
if (namep && namep[0]=='.') vl_fatal(__FILE__,__LINE__,"", (std::string("Unexp class name ")+namep).c_str());
|
||||||
}
|
}
|
||||||
|
|
||||||
extern "C" void mon_scope_name(const char* namep);
|
extern "C" void mon_scope_name(const char* namep);
|
||||||
|
|
@ -60,8 +60,8 @@ void mon_scope_name(const char* namep) {
|
||||||
#ifdef TEST_VERBOSE
|
#ifdef TEST_VERBOSE
|
||||||
VL_PRINTF("- mon_scope_name('%s', \"%s\");\n", modp, namep);
|
VL_PRINTF("- mon_scope_name('%s', \"%s\");\n", modp, namep);
|
||||||
#endif
|
#endif
|
||||||
if (strcmp(namep,"t.sub")) vl_fatal(__FILE__,__LINE__,"", (string("Unexp scope name ")+namep).c_str());
|
if (strcmp(namep,"t.sub")) vl_fatal(__FILE__,__LINE__,"", (std::string("Unexp scope name ")+namep).c_str());
|
||||||
if (strcmp(modp,"t.sub")) vl_fatal(__FILE__,__LINE__,"", (string("Unexp dpiscope name ")+modp).c_str());
|
if (strcmp(modp,"t.sub")) vl_fatal(__FILE__,__LINE__,"", (std::string("Unexp dpiscope name ")+modp).c_str());
|
||||||
}
|
}
|
||||||
|
|
||||||
extern "C" void mon_register_b(const char* namep, int isOut);
|
extern "C" void mon_register_b(const char* namep, int isOut);
|
||||||
|
|
|
||||||
|
|
@ -52,15 +52,15 @@ unsigned int callback_count = false;
|
||||||
// Use cout to avoid issues with %d/%lx etc
|
// Use cout to avoid issues with %d/%lx etc
|
||||||
#define CHECK_RESULT(got, exp) \
|
#define CHECK_RESULT(got, exp) \
|
||||||
if ((got != exp)) { \
|
if ((got != exp)) { \
|
||||||
cout<<dec<<"%Error: "<<FILENM<<":"<<__LINE__ \
|
std::cout<<std::dec<<"%Error: "<<FILENM<<":"<<__LINE__ \
|
||||||
<<": GOT = "<<(got)<<" EXP = "<<(exp)<<endl; \
|
<<": GOT = "<<(got)<<" EXP = "<<(exp)<<std::endl; \
|
||||||
return __LINE__; \
|
return __LINE__; \
|
||||||
}
|
}
|
||||||
|
|
||||||
#define CHECK_RESULT_HEX(got, exp) \
|
#define CHECK_RESULT_HEX(got, exp) \
|
||||||
if ((got != exp)) { \
|
if ((got != exp)) { \
|
||||||
cout<<dec<<"%Error: "<<FILENM<<":"<<__LINE__<<hex \
|
std::cout<<std::dec<<"%Error: "<<FILENM<<":"<<__LINE__<<std::hex \
|
||||||
<<": GOT = "<<(got)<<" EXP = "<<(exp)<<endl; \
|
<<": GOT = "<<(got)<<" EXP = "<<(exp)<<std::endl; \
|
||||||
return __LINE__; \
|
return __LINE__; \
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue