mirror of
https://github.com/verilator/verilator.git
synced 2025-01-01 04:07:34 +00:00
Internals: Add some std::'s. No functional change intended.
This commit is contained in:
parent
ee25114a00
commit
ca01d6f18d
@ -105,7 +105,7 @@ void vl_finish(const char* filename, int linenum, const char* hier) VL_MT_UNSAFE
|
||||
"- %s:%d: Second verilog $finish, exiting\n", filename, linenum);
|
||||
Verilated::runFlushCallbacks();
|
||||
Verilated::runExitCallbacks();
|
||||
exit(0);
|
||||
std::exit(0);
|
||||
}
|
||||
Verilated::threadContextp()->gotFinish(true);
|
||||
}
|
||||
@ -150,7 +150,7 @@ void vl_fatal(const char* filename, int linenum, const char* hier, const char* m
|
||||
|
||||
// Callbacks prior to termination
|
||||
Verilated::runExitCallbacks();
|
||||
abort();
|
||||
std::abort();
|
||||
}
|
||||
#endif
|
||||
|
||||
@ -279,7 +279,7 @@ static vluint32_t vl_sys_rand32() VL_MT_UNSAFE {
|
||||
const VerilatedLockGuard lock(s_mutex); // Otherwise rand is unsafe
|
||||
#if defined(_WIN32) && !defined(__CYGWIN__)
|
||||
// Windows doesn't have lrand48(), although Cygwin does.
|
||||
return (rand() << 16) ^ rand();
|
||||
return (std::rand() << 16) ^ std::rand();
|
||||
#else
|
||||
return (lrand48() << 16) ^ lrand48();
|
||||
#endif
|
||||
@ -581,10 +581,10 @@ double VL_ITOR_D_W(int lbits, WDataInP lwp) VL_PURE {
|
||||
EData ihi = lwp[ms_word];
|
||||
EData imid = lwp[ms_word - 1];
|
||||
EData ilo = lwp[ms_word - 2];
|
||||
double hi = static_cast<double>(ihi) * exp2(2 * VL_EDATASIZE);
|
||||
double mid = static_cast<double>(imid) * exp2(VL_EDATASIZE);
|
||||
double hi = static_cast<double>(ihi) * std::exp2(2 * VL_EDATASIZE);
|
||||
double mid = static_cast<double>(imid) * std::exp2(VL_EDATASIZE);
|
||||
double lo = static_cast<double>(ilo);
|
||||
double d = (hi + mid + lo) * exp2(VL_EDATASIZE * (ms_word - 2));
|
||||
double d = (hi + mid + lo) * std::exp2(VL_EDATASIZE * (ms_word - 2));
|
||||
return d;
|
||||
}
|
||||
double VL_ISTOR_D_W(int lbits, WDataInP lwp) VL_PURE {
|
||||
@ -915,14 +915,14 @@ void _vl_vsformat(std::string& output, const char* formatp, va_list ap) VL_MT_SA
|
||||
|
||||
static inline bool _vl_vsss_eof(FILE* fp, int floc) VL_MT_SAFE {
|
||||
if (fp) {
|
||||
return feof(fp) ? true : false; // true : false to prevent MSVC++ warning
|
||||
return std::feof(fp) ? true : false; // true : false to prevent MSVC++ warning
|
||||
} else {
|
||||
return floc < 0;
|
||||
}
|
||||
}
|
||||
static inline void _vl_vsss_advance(FILE* fp, int& floc) VL_MT_SAFE {
|
||||
if (fp) {
|
||||
fgetc(fp);
|
||||
std::fgetc(fp);
|
||||
} else {
|
||||
floc -= 8;
|
||||
}
|
||||
@ -931,7 +931,7 @@ static inline int _vl_vsss_peek(FILE* fp, int& floc, WDataInP fromp,
|
||||
const std::string& fstr) VL_MT_SAFE {
|
||||
// Get a character without advancing
|
||||
if (fp) {
|
||||
int data = fgetc(fp);
|
||||
int data = std::fgetc(fp);
|
||||
if (data == EOF) return EOF;
|
||||
ungetc(data, fp);
|
||||
return data;
|
||||
@ -949,7 +949,7 @@ static inline void _vl_vsss_skipspace(FILE* fp, int& floc, WDataInP fromp,
|
||||
const std::string& fstr) VL_MT_SAFE {
|
||||
while (true) {
|
||||
int c = _vl_vsss_peek(fp, floc, fromp, fstr);
|
||||
if (c == EOF || !isspace(c)) return;
|
||||
if (c == EOF || !std::isspace(c)) return;
|
||||
_vl_vsss_advance(fp, floc);
|
||||
}
|
||||
}
|
||||
@ -959,9 +959,9 @@ static inline void _vl_vsss_read_str(FILE* fp, int& floc, WDataInP fromp, const
|
||||
char* cp = tmpp;
|
||||
while (true) {
|
||||
int c = _vl_vsss_peek(fp, floc, fromp, fstr);
|
||||
if (c == EOF || isspace(c)) break;
|
||||
if (acceptp && nullptr == strchr(acceptp, c)) break; // String - allow anything
|
||||
if (acceptp) c = tolower(c); // Non-strings we'll simplify
|
||||
if (c == EOF || std::isspace(c)) break;
|
||||
if (acceptp && nullptr == std::strchr(acceptp, c)) break; // String - allow anything
|
||||
if (acceptp) c = std::tolower(c); // Non-strings we'll simplify
|
||||
*cp++ = c;
|
||||
_vl_vsss_advance(fp, floc);
|
||||
}
|
||||
@ -1037,8 +1037,8 @@ IData _vl_vsscanf(FILE* fp, // If a fscanf
|
||||
if (!inPct && pos[0] == '%') {
|
||||
inPct = true;
|
||||
inIgnore = false;
|
||||
} else if (!inPct && isspace(pos[0])) { // Format spaces
|
||||
while (isspace(pos[1])) pos++;
|
||||
} else if (!inPct && std::isspace(pos[0])) { // Format spaces
|
||||
while (std::isspace(pos[1])) pos++;
|
||||
_vl_vsss_skipspace(fp, floc, fromp, fstr);
|
||||
} else if (!inPct) { // Expected Format
|
||||
_vl_vsss_skipspace(fp, floc, fromp, fstr);
|
||||
@ -1092,7 +1092,7 @@ IData _vl_vsscanf(FILE* fp, // If a fscanf
|
||||
_vl_vsss_read_str(fp, floc, fromp, fstr, t_tmp, nullptr);
|
||||
if (!t_tmp[0]) goto done;
|
||||
if (owp) {
|
||||
int lpos = (static_cast<int>(strlen(t_tmp))) - 1;
|
||||
int lpos = (static_cast<int>(std::strlen(t_tmp))) - 1;
|
||||
int lsb = 0;
|
||||
for (int i = 0; i < obits && lpos >= 0; --lpos) {
|
||||
_vl_vsss_setbit(owp, obits, lsb, 8, t_tmp[lpos]);
|
||||
@ -1106,7 +1106,7 @@ IData _vl_vsscanf(FILE* fp, // If a fscanf
|
||||
_vl_vsss_read_str(fp, floc, fromp, fstr, t_tmp, "0123456789+-xXzZ?_");
|
||||
if (!t_tmp[0]) goto done;
|
||||
vlsint64_t ld = 0;
|
||||
sscanf(t_tmp, "%30" VL_PRI64 "d", &ld);
|
||||
std::sscanf(t_tmp, "%30" VL_PRI64 "d", &ld);
|
||||
VL_SET_WQ(owp, ld);
|
||||
break;
|
||||
}
|
||||
@ -1121,7 +1121,7 @@ IData _vl_vsscanf(FILE* fp, // If a fscanf
|
||||
double r;
|
||||
vlsint64_t ld;
|
||||
} u;
|
||||
u.r = strtod(t_tmp, nullptr);
|
||||
u.r = std::strtod(t_tmp, nullptr);
|
||||
VL_SET_WQ(owp, u.ld);
|
||||
break;
|
||||
}
|
||||
@ -1131,7 +1131,7 @@ IData _vl_vsscanf(FILE* fp, // If a fscanf
|
||||
_vl_vsss_read_str(fp, floc, fromp, fstr, t_tmp, "0123456789+-xXzZ?_");
|
||||
if (!t_tmp[0]) goto done;
|
||||
QData ld = 0;
|
||||
sscanf(t_tmp, "%30" VL_PRI64 "u", &ld);
|
||||
std::sscanf(t_tmp, "%30" VL_PRI64 "u", &ld);
|
||||
VL_SET_WQ(owp, ld);
|
||||
break;
|
||||
}
|
||||
@ -1139,14 +1139,14 @@ IData _vl_vsscanf(FILE* fp, // If a fscanf
|
||||
_vl_vsss_skipspace(fp, floc, fromp, fstr);
|
||||
_vl_vsss_read_str(fp, floc, fromp, fstr, t_tmp, "01xXzZ?_");
|
||||
if (!t_tmp[0]) goto done;
|
||||
_vl_vsss_based(owp, obits, 1, t_tmp, 0, strlen(t_tmp));
|
||||
_vl_vsss_based(owp, obits, 1, t_tmp, 0, std::strlen(t_tmp));
|
||||
break;
|
||||
}
|
||||
case 'o': {
|
||||
_vl_vsss_skipspace(fp, floc, fromp, fstr);
|
||||
_vl_vsss_read_str(fp, floc, fromp, fstr, t_tmp, "01234567xXzZ?_");
|
||||
if (!t_tmp[0]) goto done;
|
||||
_vl_vsss_based(owp, obits, 3, t_tmp, 0, strlen(t_tmp));
|
||||
_vl_vsss_based(owp, obits, 3, t_tmp, 0, std::strlen(t_tmp));
|
||||
break;
|
||||
}
|
||||
case 'x': {
|
||||
@ -1154,7 +1154,7 @@ IData _vl_vsscanf(FILE* fp, // If a fscanf
|
||||
_vl_vsss_read_str(fp, floc, fromp, fstr, t_tmp,
|
||||
"0123456789abcdefABCDEFxXzZ?_");
|
||||
if (!t_tmp[0]) goto done;
|
||||
_vl_vsss_based(owp, obits, 4, t_tmp, 0, strlen(t_tmp));
|
||||
_vl_vsss_based(owp, obits, 4, t_tmp, 0, std::strlen(t_tmp));
|
||||
break;
|
||||
}
|
||||
case 'u': {
|
||||
@ -1242,7 +1242,7 @@ void _vl_vint_to_string(int obits, char* destoutp, WDataInP sourcep) VL_MT_SAFE
|
||||
}
|
||||
*destp = '\0'; // Terminate
|
||||
if (!start) { // Drop trailing spaces
|
||||
while (isspace(*(destp - 1)) && destp > destoutp) *--destp = '\0';
|
||||
while (std::isspace(*(destp - 1)) && destp > destoutp) *--destp = '\0';
|
||||
}
|
||||
}
|
||||
|
||||
@ -1297,7 +1297,7 @@ IData VL_FGETS_NI(std::string& dest, IData fpi) VL_MT_SAFE {
|
||||
IData VL_FERROR_IN(IData, std::string& outputr) VL_MT_SAFE {
|
||||
// We ignore lhs/fpi - IEEE says "most recent error" so probably good enough
|
||||
IData ret = errno;
|
||||
outputr = std::string(::strerror(ret));
|
||||
outputr = std::string(::std::strerror(ret));
|
||||
return ret;
|
||||
}
|
||||
|
||||
@ -1479,7 +1479,7 @@ IData VL_FREAD_I(int width, int array_lsb, int array_size, void* memp, IData fpi
|
||||
// We process a character at a time, as then we don't need to deal
|
||||
// with changing buffer sizes dynamically, etc.
|
||||
while (true) {
|
||||
int c = fgetc(fp);
|
||||
int c = std::fgetc(fp);
|
||||
if (VL_UNLIKELY(c == EOF)) break;
|
||||
// Shift value in
|
||||
IData entry = read_elements + start - array_lsb;
|
||||
@ -1524,7 +1524,7 @@ IData VL_SYSTEM_IQ(QData lhs) VL_MT_SAFE {
|
||||
IData VL_SYSTEM_IW(int lhswords, WDataInP lhsp) VL_MT_SAFE {
|
||||
char filenamez[VL_TO_STRING_MAX_WORDS * VL_EDATASIZE + 1];
|
||||
_vl_vint_to_string(lhswords * VL_EDATASIZE, filenamez, lhsp);
|
||||
int code = system(filenamez); // Yes, system() is threadsafe
|
||||
int code = std::system(filenamez); // Yes, std::system() is threadsafe
|
||||
return code >> 8; // Want exit status
|
||||
}
|
||||
|
||||
@ -1544,7 +1544,7 @@ IData VL_VALUEPLUSARGS_INW(int rbits, const std::string& ld, WDataOutP rwp) VL_M
|
||||
} else if (!inPct) { // Normal text
|
||||
prefix += *posp;
|
||||
} else { // Format character
|
||||
switch (tolower(*posp)) {
|
||||
switch (std::tolower(*posp)) {
|
||||
case '%':
|
||||
prefix += *posp;
|
||||
inPct = false;
|
||||
@ -1562,20 +1562,20 @@ IData VL_VALUEPLUSARGS_INW(int rbits, const std::string& ld, WDataOutP rwp) VL_M
|
||||
if (match.empty()) return 0;
|
||||
|
||||
VL_ZERO_RESET_W(rbits, rwp);
|
||||
switch (tolower(fmt)) {
|
||||
switch (std::tolower(fmt)) {
|
||||
case 'd': {
|
||||
vlsint64_t lld = 0;
|
||||
sscanf(dp, "%30" VL_PRI64 "d", &lld);
|
||||
std::sscanf(dp, "%30" VL_PRI64 "d", &lld);
|
||||
VL_SET_WQ(rwp, lld);
|
||||
break;
|
||||
}
|
||||
case 'b': _vl_vsss_based(rwp, rbits, 1, dp, 0, strlen(dp)); break;
|
||||
case 'o': _vl_vsss_based(rwp, rbits, 3, dp, 0, strlen(dp)); break;
|
||||
case 'b': _vl_vsss_based(rwp, rbits, 1, dp, 0, std::strlen(dp)); break;
|
||||
case 'o': _vl_vsss_based(rwp, rbits, 3, dp, 0, std::strlen(dp)); break;
|
||||
case 'h': // FALLTHRU
|
||||
case 'x': _vl_vsss_based(rwp, rbits, 4, dp, 0, strlen(dp)); break;
|
||||
case 'x': _vl_vsss_based(rwp, rbits, 4, dp, 0, std::strlen(dp)); break;
|
||||
case 's': { // string/no conversion
|
||||
for (int i = 0, lsb = 0, posp = static_cast<int>(strlen(dp)) - 1; i < rbits && posp >= 0;
|
||||
--posp) {
|
||||
for (int i = 0, lsb = 0, posp = static_cast<int>(std::strlen(dp)) - 1;
|
||||
i < rbits && posp >= 0; --posp) {
|
||||
_vl_vsss_setbit(rwp, rbits, lsb, 8, dp[posp]);
|
||||
lsb += 8;
|
||||
}
|
||||
@ -1583,19 +1583,19 @@ IData VL_VALUEPLUSARGS_INW(int rbits, const std::string& ld, WDataOutP rwp) VL_M
|
||||
}
|
||||
case 'e': {
|
||||
double temp = 0.F;
|
||||
sscanf(dp, "%le", &temp);
|
||||
std::sscanf(dp, "%le", &temp);
|
||||
VL_SET_WQ(rwp, VL_CVT_Q_D(temp));
|
||||
break;
|
||||
}
|
||||
case 'f': {
|
||||
double temp = 0.F;
|
||||
sscanf(dp, "%lf", &temp);
|
||||
std::sscanf(dp, "%lf", &temp);
|
||||
VL_SET_WQ(rwp, VL_CVT_Q_D(temp));
|
||||
break;
|
||||
}
|
||||
case 'g': {
|
||||
double temp = 0.F;
|
||||
sscanf(dp, "%lg", &temp);
|
||||
std::sscanf(dp, "%lg", &temp);
|
||||
VL_SET_WQ(rwp, VL_CVT_Q_D(temp));
|
||||
break;
|
||||
}
|
||||
@ -1615,7 +1615,7 @@ IData VL_VALUEPLUSARGS_INN(int, const std::string& ld, std::string& rdr) VL_MT_S
|
||||
} else if (!inPct) { // Normal text
|
||||
prefix += *posp;
|
||||
} else { // Format character
|
||||
switch (tolower(*posp)) {
|
||||
switch (std::tolower(*posp)) {
|
||||
case '%':
|
||||
prefix += *posp;
|
||||
inPct = false;
|
||||
@ -1638,7 +1638,7 @@ const char* vl_mc_scan_plusargs(const char* prefixp) VL_MT_SAFE {
|
||||
static VL_THREAD_LOCAL char t_outstr[VL_VALUE_STRING_MAX_WIDTH];
|
||||
if (match.empty()) return nullptr;
|
||||
char* dp = t_outstr;
|
||||
for (const char* sp = match.c_str() + strlen(prefixp) + 1; // +1 to skip the "+"
|
||||
for (const char* sp = match.c_str() + std::strlen(prefixp) + 1; // +1 to skip the "+"
|
||||
*sp && (dp - t_outstr) < (VL_VALUE_STRING_MAX_WIDTH - 2);)
|
||||
*dp++ = *sp++;
|
||||
*dp++ = '\0';
|
||||
@ -1658,12 +1658,12 @@ std::string VL_TO_STRING_W(int words, WDataInP obj) {
|
||||
|
||||
std::string VL_TOLOWER_NN(const std::string& ld) VL_MT_SAFE {
|
||||
std::string out = ld;
|
||||
for (auto& cr : out) cr = tolower(cr);
|
||||
for (auto& cr : out) cr = std::tolower(cr);
|
||||
return out;
|
||||
}
|
||||
std::string VL_TOUPPER_NN(const std::string& ld) VL_MT_SAFE {
|
||||
std::string out = ld;
|
||||
for (auto& cr : out) cr = toupper(cr);
|
||||
for (auto& cr : out) cr = std::toupper(cr);
|
||||
return out;
|
||||
}
|
||||
|
||||
@ -1763,7 +1763,7 @@ VlReadMem::VlReadMem(bool hex, int bits, const std::string& filename, QData star
|
||||
, m_end{end}
|
||||
, m_addr{start}
|
||||
, m_linenum{0} {
|
||||
m_fp = fopen(filename.c_str(), "r");
|
||||
m_fp = std::fopen(filename.c_str(), "r");
|
||||
if (VL_UNLIKELY(!m_fp)) {
|
||||
// We don't report the Verilog source filename as it slow to have to pass it down
|
||||
VL_FATAL_MT(filename.c_str(), 0, "", "$readmem file not found");
|
||||
@ -1773,7 +1773,7 @@ VlReadMem::VlReadMem(bool hex, int bits, const std::string& filename, QData star
|
||||
}
|
||||
VlReadMem::~VlReadMem() {
|
||||
if (m_fp) {
|
||||
fclose(m_fp);
|
||||
std::fclose(m_fp);
|
||||
m_fp = nullptr;
|
||||
}
|
||||
}
|
||||
@ -1790,13 +1790,13 @@ bool VlReadMem::get(QData& addrr, std::string& valuer) {
|
||||
// We process a character at a time, as then we don't need to deal
|
||||
// with changing buffer sizes dynamically, etc.
|
||||
while (true) {
|
||||
int c = fgetc(m_fp);
|
||||
int c = std::fgetc(m_fp);
|
||||
if (VL_UNLIKELY(c == EOF)) break;
|
||||
// printf("%d: Got '%c' Addr%lx IN%d IgE%d IgC%d\n",
|
||||
// m_linenum, c, m_addr, indata, ignore_to_eol, ignore_to_cmt);
|
||||
// See if previous data value has completed, and if so return
|
||||
if (c == '_') continue; // Ignore _ e.g. inside a number
|
||||
if (indata && !isxdigit(c) && c != 'x' && c != 'X') {
|
||||
if (indata && !std::isxdigit(c) && c != 'x' && c != 'X') {
|
||||
// printf("Got data @%lx = %s\n", m_addr, valuer.c_str());
|
||||
ungetc(c, m_fp);
|
||||
addrr = m_addr;
|
||||
@ -1828,8 +1828,8 @@ bool VlReadMem::get(QData& addrr, std::string& valuer) {
|
||||
m_addr = 0;
|
||||
}
|
||||
// Check for hex or binary digits as file format requests
|
||||
else if (isxdigit(c) || (!reading_addr && (c == 'x' || c == 'X'))) {
|
||||
c = tolower(c);
|
||||
else if (std::isxdigit(c) || (!reading_addr && (c == 'x' || c == 'X'))) {
|
||||
c = std::tolower(c);
|
||||
int value
|
||||
= (c >= 'a' ? (c == 'x' ? VL_RAND_RESET_I(4) : (c - 'a' + 10)) : (c - '0'));
|
||||
if (reading_addr) {
|
||||
@ -1863,7 +1863,7 @@ void VlReadMem::setData(void* valuep, const std::string& rhs) {
|
||||
bool innum = false;
|
||||
// Shift value in
|
||||
for (const auto& i : rhs) {
|
||||
char c = tolower(i);
|
||||
char c = std::tolower(i);
|
||||
int value = (c >= 'a' ? (c == 'x' ? VL_RAND_RESET_I(4) : (c - 'a' + 10)) : (c - '0'));
|
||||
if (m_bits <= 8) {
|
||||
CData* datap = reinterpret_cast<CData*>(valuep);
|
||||
@ -1901,7 +1901,7 @@ VlWriteMem::VlWriteMem(bool hex, int bits, const std::string& filename, QData st
|
||||
return;
|
||||
}
|
||||
|
||||
m_fp = fopen(filename.c_str(), "w");
|
||||
m_fp = std::fopen(filename.c_str(), "w");
|
||||
if (VL_UNLIKELY(!m_fp)) {
|
||||
VL_FATAL_MT(filename.c_str(), 0, "", "$writemem file not found");
|
||||
// cppcheck-suppress resourceLeak // m_fp is nullptr - bug in cppcheck
|
||||
@ -1910,7 +1910,7 @@ VlWriteMem::VlWriteMem(bool hex, int bits, const std::string& filename, QData st
|
||||
}
|
||||
VlWriteMem::~VlWriteMem() {
|
||||
if (m_fp) {
|
||||
fclose(m_fp);
|
||||
std::fclose(m_fp);
|
||||
m_fp = nullptr;
|
||||
}
|
||||
}
|
||||
@ -2355,7 +2355,7 @@ std::string VerilatedContextImp::argPlusMatch(const char* prefixp)
|
||||
VL_MT_SAFE_EXCLUDES(m_argMutex) {
|
||||
const VerilatedLockGuard lock(m_argMutex);
|
||||
// Note prefixp does not include the leading "+"
|
||||
size_t len = strlen(prefixp);
|
||||
size_t len = std::strlen(prefixp);
|
||||
if (VL_UNLIKELY(!m_args.m_argVecLoaded)) {
|
||||
m_args.m_argVecLoaded = true; // Complain only once
|
||||
VL_FATAL_MT("unknown", 0, "",
|
||||
@ -2364,7 +2364,7 @@ std::string VerilatedContextImp::argPlusMatch(const char* prefixp)
|
||||
}
|
||||
for (const auto& i : m_args.m_argVec) {
|
||||
if (i[0] == '+') {
|
||||
if (0 == strncmp(prefixp, i.c_str() + 1, len)) return i;
|
||||
if (0 == std::strncmp(prefixp, i.c_str() + 1, len)) return i;
|
||||
}
|
||||
}
|
||||
return "";
|
||||
@ -2383,7 +2383,7 @@ std::pair<int, char**> VerilatedContextImp::argc_argv() VL_MT_SAFE_EXCLUDES(m_ar
|
||||
int in = 0;
|
||||
for (const auto& i : m_args.m_argVec) {
|
||||
s_argvp[in] = new char[i.length() + 1];
|
||||
strcpy(s_argvp[in], i.c_str());
|
||||
std::strcpy(s_argvp[in], i.c_str());
|
||||
++in;
|
||||
}
|
||||
s_argvp[s_argc] = nullptr;
|
||||
@ -2392,14 +2392,14 @@ std::pair<int, char**> VerilatedContextImp::argc_argv() VL_MT_SAFE_EXCLUDES(m_ar
|
||||
}
|
||||
|
||||
void VerilatedContextImp::commandArgVl(const std::string& arg) {
|
||||
if (0 == strncmp(arg.c_str(), "+verilator+", strlen("+verilator+"))) {
|
||||
if (0 == std::strncmp(arg.c_str(), "+verilator+", std::strlen("+verilator+"))) {
|
||||
std::string value;
|
||||
if (arg == "+verilator+debug") {
|
||||
Verilated::debug(4);
|
||||
} else if (commandArgVlValue(arg, "+verilator+debugi+", value /*ref*/)) {
|
||||
Verilated::debug(atoi(value.c_str()));
|
||||
Verilated::debug(std::atoi(value.c_str()));
|
||||
} else if (commandArgVlValue(arg, "+verilator+error+limit+", value /*ref*/)) {
|
||||
errorLimit(atoi(value.c_str()));
|
||||
errorLimit(std::atoi(value.c_str()));
|
||||
} else if (arg == "+verilator+help") {
|
||||
VerilatedImp::versionDump();
|
||||
VL_PRINTF_MT("For help, please see 'verilator --help'\n");
|
||||
@ -2408,15 +2408,15 @@ void VerilatedContextImp::commandArgVl(const std::string& arg) {
|
||||
} else if (arg == "+verilator+noassert") {
|
||||
assertOn(false);
|
||||
} else if (commandArgVlValue(arg, "+verilator+prof+threads+start+", value /*ref*/)) {
|
||||
profThreadsStart(atoll(value.c_str()));
|
||||
profThreadsStart(std::atoll(value.c_str()));
|
||||
} else if (commandArgVlValue(arg, "+verilator+prof+threads+window+", value /*ref*/)) {
|
||||
profThreadsWindow(atol(value.c_str()));
|
||||
profThreadsWindow(std::atol(value.c_str()));
|
||||
} else if (commandArgVlValue(arg, "+verilator+prof+threads+file+", value /*ref*/)) {
|
||||
profThreadsFilename(value);
|
||||
} else if (commandArgVlValue(arg, "+verilator+rand+reset+", value /*ref*/)) {
|
||||
randReset(atoi(value.c_str()));
|
||||
randReset(std::atoi(value.c_str()));
|
||||
} else if (commandArgVlValue(arg, "+verilator+seed+", value /*ref*/)) {
|
||||
randSeed(atoi(value.c_str()));
|
||||
randSeed(std::atoi(value.c_str()));
|
||||
} else if (arg == "+verilator+V") {
|
||||
VerilatedImp::versionDump(); // Someday more info too
|
||||
VL_FATAL_MT("COMMAND_LINE", 0, "",
|
||||
@ -2433,7 +2433,7 @@ void VerilatedContextImp::commandArgVl(const std::string& arg) {
|
||||
bool VerilatedContextImp::commandArgVlValue(const std::string& arg, const std::string& prefix,
|
||||
std::string& valuer) {
|
||||
size_t len = prefix.length();
|
||||
if (0 == strncmp(prefix.c_str(), arg.c_str(), len)) {
|
||||
if (0 == std::strncmp(prefix.c_str(), arg.c_str(), len)) {
|
||||
valuer = arg.substr(len);
|
||||
return true;
|
||||
} else {
|
||||
@ -2543,7 +2543,7 @@ const char* Verilated::catName(const char* n1, const char* n2, const char* delim
|
||||
// Used by symbol table creation to make module names
|
||||
static VL_THREAD_LOCAL char* t_strp = nullptr;
|
||||
static VL_THREAD_LOCAL size_t t_len = 0;
|
||||
size_t newlen = strlen(n1) + strlen(n2) + strlen(delimiter) + 1;
|
||||
size_t newlen = std::strlen(n1) + std::strlen(n2) + std::strlen(delimiter) + 1;
|
||||
if (VL_UNLIKELY(!t_strp || newlen > t_len)) {
|
||||
if (t_strp) delete[] t_strp;
|
||||
t_strp = new char[newlen];
|
||||
@ -2603,8 +2603,8 @@ void Verilated::runFlushCallbacks() VL_MT_SAFE {
|
||||
runCallbacks(VlCbStatic.s_flushCbs);
|
||||
}
|
||||
--s_recursing;
|
||||
fflush(stderr);
|
||||
fflush(stdout);
|
||||
std::fflush(stderr);
|
||||
std::fflush(stdout);
|
||||
// When running internal code coverage (gcc --coverage, as opposed to
|
||||
// verilator --coverage), dump coverage data to properly cover failing
|
||||
// tests.
|
||||
@ -2760,7 +2760,7 @@ void VerilatedScope::configure(VerilatedSyms* symsp, const char* prefixp, const
|
||||
m_type = type;
|
||||
m_timeunit = timeunit;
|
||||
{
|
||||
char* namep = new char[strlen(prefixp) + strlen(suffixp) + 2];
|
||||
char* namep = new char[std::strlen(prefixp) + std::strlen(suffixp) + 2];
|
||||
char* dp = namep;
|
||||
for (const char* sp = prefixp; *sp;) *dp++ = *sp++;
|
||||
if (*prefixp && *suffixp) *dp++ = '.';
|
||||
@ -2787,7 +2787,7 @@ void VerilatedScope::exportInsert(int finalize, const char* namep, void* cb) VL_
|
||||
}
|
||||
if (VL_UNLIKELY(!m_callbacksp)) { // First allocation
|
||||
m_callbacksp = new void*[m_funcnumMax];
|
||||
memset(m_callbacksp, 0, m_funcnumMax * sizeof(void*));
|
||||
std::memset(m_callbacksp, 0, m_funcnumMax * sizeof(void*));
|
||||
}
|
||||
m_callbacksp[funcnum] = cb;
|
||||
}
|
||||
|
@ -142,7 +142,7 @@ private:
|
||||
// Quote any special characters
|
||||
std::string rtn;
|
||||
for (const char* pos = text.c_str(); *pos; ++pos) {
|
||||
if (!isprint(*pos) || *pos == '%' || *pos == '"') {
|
||||
if (!std::isprint(*pos) || *pos == '%' || *pos == '"') {
|
||||
char hex[10];
|
||||
VL_SNPRINTF(hex, 10, "%%%02X", pos[0]);
|
||||
rtn += hex;
|
||||
@ -158,13 +158,13 @@ private:
|
||||
// a letter differently, nor want them to rely on our compression...
|
||||
// (Considered using numeric keys, but will remain back compatible.)
|
||||
if (key.length() < 2) return false;
|
||||
if (key.length() == 2 && isdigit(key[1])) return false;
|
||||
if (key.length() == 2 && std::isdigit(key[1])) return false;
|
||||
return true;
|
||||
}
|
||||
static std::string keyValueFormatter(const std::string& key,
|
||||
const std::string& value) VL_PURE {
|
||||
std::string name;
|
||||
if (key.length() == 1 && isalpha(key[0])) {
|
||||
if (key.length() == 1 && std::isalpha(key[0])) {
|
||||
name += std::string("\001") + key;
|
||||
} else {
|
||||
name += std::string("\001") + dequote(key);
|
||||
@ -196,8 +196,8 @@ private:
|
||||
std::string prefix = std::string(a, apre - a);
|
||||
|
||||
// Scan backward to last mismatch
|
||||
const char* apost = a + strlen(a) - 1;
|
||||
const char* bpost = b + strlen(b) - 1;
|
||||
const char* apost = a + std::strlen(a) - 1;
|
||||
const char* bpost = b + std::strlen(b) - 1;
|
||||
while (*apost == *bpost && apost > apre && bpost > bpre) {
|
||||
apost--;
|
||||
bpost--;
|
||||
@ -305,7 +305,7 @@ public:
|
||||
valps[1] = linestr.c_str();
|
||||
// Default page if not specified
|
||||
const char* fnstartp = m_insertFilenamep;
|
||||
while (const char* foundp = strchr(fnstartp, '/')) fnstartp = foundp + 1;
|
||||
while (const char* foundp = std::strchr(fnstartp, '/')) fnstartp = foundp + 1;
|
||||
const char* fnendp = fnstartp;
|
||||
for (; *fnendp && *fnendp != '.'; fnendp++) {}
|
||||
std::string page_default = "sp_user/" + std::string(fnstartp, fnendp - fnstartp);
|
||||
|
@ -280,12 +280,12 @@ public: // But only for verilated*.cpp
|
||||
if (m_fdFreeMct.empty()) return 0;
|
||||
IData idx = m_fdFreeMct.back();
|
||||
m_fdFreeMct.pop_back();
|
||||
m_fdps[idx] = fopen(filenamep, "w");
|
||||
m_fdps[idx] = std::fopen(filenamep, "w");
|
||||
if (VL_UNLIKELY(!m_fdps[idx])) return 0;
|
||||
return (1 << idx);
|
||||
}
|
||||
IData fdNew(const char* filenamep, const char* modep) VL_MT_SAFE_EXCLUDES(m_fdMutex) {
|
||||
FILE* fp = fopen(filenamep, modep);
|
||||
FILE* fp = std::fopen(filenamep, modep);
|
||||
if (VL_UNLIKELY(!fp)) return 0;
|
||||
// Bit 31 indicates it's a descriptor not a MCD
|
||||
const VerilatedLockGuard lock(m_fdMutex);
|
||||
@ -308,20 +308,20 @@ public: // But only for verilated*.cpp
|
||||
void fdFlush(IData fdi) VL_MT_SAFE_EXCLUDES(m_fdMutex) {
|
||||
const VerilatedLockGuard lock(m_fdMutex);
|
||||
const VerilatedFpList fdlist = fdToFpList(fdi);
|
||||
for (const auto& i : fdlist) fflush(i);
|
||||
for (const auto& i : fdlist) std::fflush(i);
|
||||
}
|
||||
IData fdSeek(IData fdi, IData offset, IData origin) VL_MT_SAFE_EXCLUDES(m_fdMutex) {
|
||||
const VerilatedLockGuard lock(m_fdMutex);
|
||||
const VerilatedFpList fdlist = fdToFpList(fdi);
|
||||
if (VL_UNLIKELY(fdlist.size() != 1)) return 0;
|
||||
return static_cast<IData>(
|
||||
fseek(*fdlist.begin(), static_cast<long>(offset), static_cast<int>(origin)));
|
||||
std::fseek(*fdlist.begin(), static_cast<long>(offset), static_cast<int>(origin)));
|
||||
}
|
||||
IData fdTell(IData fdi) VL_MT_SAFE_EXCLUDES(m_fdMutex) {
|
||||
const VerilatedLockGuard lock(m_fdMutex);
|
||||
const VerilatedFpList fdlist = fdToFpList(fdi);
|
||||
if (VL_UNLIKELY(fdlist.size() != 1)) return 0;
|
||||
return static_cast<IData>(ftell(*fdlist.begin()));
|
||||
return static_cast<IData>(std::ftell(*fdlist.begin()));
|
||||
}
|
||||
void fdWrite(IData fdi, const std::string& output) VL_MT_SAFE_EXCLUDES(m_fdMutex) {
|
||||
const VerilatedLockGuard lock(m_fdMutex);
|
||||
@ -338,14 +338,14 @@ public: // But only for verilated*.cpp
|
||||
IData idx = VL_MASK_I(31) & fdi;
|
||||
if (VL_UNLIKELY(idx >= m_fdps.size())) return;
|
||||
if (VL_UNLIKELY(!m_fdps[idx])) return; // Already free
|
||||
fclose(m_fdps[idx]);
|
||||
std::fclose(m_fdps[idx]);
|
||||
m_fdps[idx] = (FILE*)0;
|
||||
m_fdFree.push_back(idx);
|
||||
} else {
|
||||
// MCD case
|
||||
for (int i = 0; (fdi != 0) && (i < 31); i++, fdi >>= 1) {
|
||||
if (fdi & VL_MASK_I(1)) {
|
||||
fclose(m_fdps[i]);
|
||||
std::fclose(m_fdps[i]);
|
||||
m_fdps[i] = nullptr;
|
||||
m_fdFreeMct.push_back(i);
|
||||
}
|
||||
|
@ -83,13 +83,13 @@ VerilatedDeserialize& VerilatedDeserialize::readAssert(const void* __restrict da
|
||||
|
||||
void VerilatedSerialize::header() VL_MT_UNSAFE_ONE {
|
||||
VerilatedSerialize& os = *this; // So can cut and paste standard << code below
|
||||
assert((strlen(VLTSAVE_HEADER_STR) & 7) == 0); // Keep aligned
|
||||
os.write(VLTSAVE_HEADER_STR, strlen(VLTSAVE_HEADER_STR));
|
||||
assert((std::strlen(VLTSAVE_HEADER_STR) & 7) == 0); // Keep aligned
|
||||
os.write(VLTSAVE_HEADER_STR, std::strlen(VLTSAVE_HEADER_STR));
|
||||
}
|
||||
|
||||
void VerilatedDeserialize::header() VL_MT_UNSAFE_ONE {
|
||||
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, std::strlen(VLTSAVE_HEADER_STR)))) {
|
||||
std::string fn = filename();
|
||||
std::string msg
|
||||
= std::string(
|
||||
@ -102,13 +102,13 @@ void VerilatedDeserialize::header() VL_MT_UNSAFE_ONE {
|
||||
|
||||
void VerilatedSerialize::trailer() VL_MT_UNSAFE_ONE {
|
||||
VerilatedSerialize& os = *this; // So can cut and paste standard << code below
|
||||
assert((strlen(VLTSAVE_TRAILER_STR) & 7) == 0); // Keep aligned
|
||||
os.write(VLTSAVE_TRAILER_STR, strlen(VLTSAVE_TRAILER_STR));
|
||||
assert((std::strlen(VLTSAVE_TRAILER_STR) & 7) == 0); // Keep aligned
|
||||
os.write(VLTSAVE_TRAILER_STR, std::strlen(VLTSAVE_TRAILER_STR));
|
||||
}
|
||||
|
||||
void VerilatedDeserialize::trailer() VL_MT_UNSAFE_ONE {
|
||||
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, std::strlen(VLTSAVE_TRAILER_STR)))) {
|
||||
std::string fn = filename();
|
||||
std::string msg = std::string("Can't deserialize; file has wrong end-of-file signature: ")
|
||||
+ filename();
|
||||
@ -202,7 +202,7 @@ void VerilatedSave::flush() VL_MT_UNSAFE_ONE {
|
||||
if (VL_UNCOVERABLE(errno != EAGAIN && errno != EINTR)) {
|
||||
// LCOV_EXCL_START
|
||||
// write failed, presume error (perhaps out of disk space)
|
||||
std::string msg = std::string(__FUNCTION__) + ": " + strerror(errno);
|
||||
std::string msg = std::string(__FUNCTION__) + ": " + std::strerror(errno);
|
||||
VL_FATAL_MT("", 0, "", msg.c_str());
|
||||
close();
|
||||
break;
|
||||
@ -233,7 +233,7 @@ void VerilatedRestore::fill() VL_MT_UNSAFE_ONE {
|
||||
if (VL_UNCOVERABLE(errno != EAGAIN && errno != EINTR)) {
|
||||
// LCOV_EXCL_START
|
||||
// write failed, presume error (perhaps out of disk space)
|
||||
std::string msg = std::string(__FUNCTION__) + ": " + strerror(errno);
|
||||
std::string msg = std::string(__FUNCTION__) + ": " + std::strerror(errno);
|
||||
VL_FATAL_MT("", 0, "", msg.c_str());
|
||||
close();
|
||||
break;
|
||||
|
@ -149,7 +149,7 @@ void VlThreadPool::profileDump(const char* filenamep, vluint64_t ticksElapsed)
|
||||
const VerilatedLockGuard lk(m_mutex);
|
||||
VL_DEBUG_IF(VL_DBG_MSGF("+prof+threads writing to '%s'\n", filenamep););
|
||||
|
||||
FILE* fp = fopen(filenamep, "w");
|
||||
FILE* fp = std::fopen(filenamep, "w");
|
||||
if (VL_UNLIKELY(!fp)) {
|
||||
VL_FATAL_MT(filenamep, 0, "", "+prof+threads+file file not writable");
|
||||
// cppcheck-suppress resourceLeak // bug, doesn't realize fp is nullptr
|
||||
@ -191,5 +191,5 @@ void VlThreadPool::profileDump(const char* filenamep, vluint64_t ticksElapsed)
|
||||
}
|
||||
fprintf(fp, "VLPROF stat ticks %" VL_PRI64 "u\n", ticksElapsed);
|
||||
|
||||
fclose(fp);
|
||||
std::fclose(fp);
|
||||
}
|
||||
|
@ -225,7 +225,7 @@ protected:
|
||||
void declCode(vluint32_t code, vluint32_t bits, bool tri);
|
||||
|
||||
// Is this an escape?
|
||||
bool isScopeEscape(char c) { return c != '\f' && (isspace(c) || c == m_scopeEscape); }
|
||||
bool isScopeEscape(char c) { return c != '\f' && (std::isspace(c) || c == m_scopeEscape); }
|
||||
// Character that splits scopes. Note whitespace are ALWAYS escapes.
|
||||
char scopeEscape() { return m_scopeEscape; }
|
||||
|
||||
|
@ -45,11 +45,11 @@
|
||||
|
||||
static double timescaleToDouble(const char* unitp) {
|
||||
char* endp = nullptr;
|
||||
double value = strtod(unitp, &endp);
|
||||
double value = std::strtod(unitp, &endp);
|
||||
// On error so we allow just "ns" to return 1e-9.
|
||||
if (value == 0.0 && endp == unitp) value = 1;
|
||||
unitp = endp;
|
||||
for (; *unitp && isspace(*unitp); unitp++) {}
|
||||
for (; *unitp && std::isspace(*unitp); unitp++) {}
|
||||
switch (*unitp) {
|
||||
case 's': value *= 1e0; break;
|
||||
case 'm': value *= 1e-3; break;
|
||||
|
@ -52,7 +52,7 @@
|
||||
|
||||
// This size comes form VCD allowing use of printable ASCII characters between
|
||||
// '!' and '~' inclusive, which are a total of 94 different values. Encoding a
|
||||
// 32 bit code hence needs a maximum of ceil(log94(2**32-1)) == 5 bytes.
|
||||
// 32 bit code hence needs a maximum of std::ceil(log94(2**32-1)) == 5 bytes.
|
||||
constexpr unsigned VL_TRACE_MAX_VCD_CODE_SIZE = 5; // Maximum length of a VCD string code
|
||||
|
||||
// We use 8 bytes per code in a suffix buffer array.
|
||||
@ -134,9 +134,9 @@ void VerilatedVcd::openNextImp(bool incFilename) {
|
||||
// Find _0000.{ext} in filename
|
||||
std::string name = m_filename;
|
||||
size_t pos = name.rfind('.');
|
||||
if (pos > 8 && 0 == strncmp("_cat", name.c_str() + pos - 8, 4)
|
||||
&& isdigit(name.c_str()[pos - 4]) && isdigit(name.c_str()[pos - 3])
|
||||
&& isdigit(name.c_str()[pos - 2]) && isdigit(name.c_str()[pos - 1])) {
|
||||
if (pos > 8 && 0 == std::strncmp("_cat", name.c_str() + pos - 8, 4)
|
||||
&& std::isdigit(name.c_str()[pos - 4]) && std::isdigit(name.c_str()[pos - 3])
|
||||
&& std::isdigit(name.c_str()[pos - 2]) && std::isdigit(name.c_str()[pos - 1])) {
|
||||
// Increment code.
|
||||
if ((++(name[pos - 1])) > '9') {
|
||||
name[pos - 1] = '0';
|
||||
@ -287,7 +287,7 @@ void VerilatedVcd::bufferResize(vluint64_t minsize) {
|
||||
char* oldbufp = m_wrBufp;
|
||||
m_wrChunkSize = minsize * 2;
|
||||
m_wrBufp = new char[m_wrChunkSize * 8];
|
||||
memcpy(m_wrBufp, oldbufp, m_writep - oldbufp);
|
||||
std::memcpy(m_wrBufp, oldbufp, m_writep - oldbufp);
|
||||
m_writep = m_wrBufp + (m_writep - oldbufp);
|
||||
m_wrFlushp = m_wrBufp + m_wrChunkSize * 6;
|
||||
VL_DO_CLEAR(delete[] oldbufp, oldbufp = nullptr);
|
||||
@ -314,7 +314,8 @@ void VerilatedVcd::bufferFlush() VL_MT_UNSAFE_ONE {
|
||||
if (VL_UNCOVERABLE(errno != EAGAIN && errno != EINTR)) {
|
||||
// LCOV_EXCL_START
|
||||
// write failed, presume error (perhaps out of disk space)
|
||||
std::string msg = std::string("VerilatedVcd::bufferFlush: ") + strerror(errno);
|
||||
std::string msg
|
||||
= std::string("VerilatedVcd::bufferFlush: ") + std::strerror(errno);
|
||||
VL_FATAL_MT("", 0, "", msg.c_str());
|
||||
closeErr();
|
||||
break;
|
||||
@ -360,7 +361,7 @@ void VerilatedVcd::dumpHeader() {
|
||||
VL_LOCALTIME_R(&tick, &ticktm);
|
||||
constexpr int bufsize = 50;
|
||||
char buf[bufsize];
|
||||
strftime(buf, bufsize, "%c", &ticktm);
|
||||
std::strftime(buf, bufsize, "%c", &ticktm);
|
||||
printStr(buf);
|
||||
}
|
||||
printStr(" $end\n");
|
||||
@ -520,7 +521,8 @@ void VerilatedVcd::declare(vluint32_t code, const char* name, const char* wirep,
|
||||
const bool isBit = bits == 1;
|
||||
entryp[0] = ' '; // Separator
|
||||
// Use memcpy as we checked size above, and strcpy is flagged unsafe
|
||||
std::memcpy(entryp + !isBit, buf, strlen(buf)); // Code (overwrite separator if isBit)
|
||||
std::memcpy(entryp + !isBit, buf,
|
||||
std::strlen(buf)); // Code (overwrite separator if isBit)
|
||||
entryp[length + !isBit] = '\n'; // Replace '\0' with line termination '\n'
|
||||
// Set length of suffix (used to increment write pointer)
|
||||
entryp[VL_TRACE_SUFFIX_ENTRY_SIZE - 1] = !isBit + length + 1;
|
||||
@ -673,7 +675,7 @@ void VerilatedVcd::emitDouble(vluint32_t code, double newval) {
|
||||
char* wp = m_writep;
|
||||
// Buffer can't overflow before VL_SNPRINTF; we sized during declaration
|
||||
VL_SNPRINTF(wp, m_wrChunkSize, "r%.16g", newval);
|
||||
wp += strlen(wp);
|
||||
wp += std::strlen(wp);
|
||||
finishLine(code, wp);
|
||||
}
|
||||
|
||||
@ -787,7 +789,7 @@ void VerilatedVcd::fullDouble(vluint32_t code, const double newval) {
|
||||
(*(reinterpret_cast<double*>(oldp(code)))) = newval;
|
||||
// Buffer can't overflow before VL_SNPRINTF; we sized during declaration
|
||||
VL_SNPRINTF(m_writep, m_wrChunkSize, "r%.16g", newval);
|
||||
m_writep += strlen(m_writep);
|
||||
m_writep += std::strlen(m_writep);
|
||||
*m_writep++ = ' ';
|
||||
m_writep = writeCode(m_writep, code);
|
||||
*m_writep++ = '\n';
|
||||
|
@ -317,7 +317,7 @@ public:
|
||||
void createPrevDatap() {
|
||||
if (VL_UNLIKELY(!m_prevDatap)) {
|
||||
m_prevDatap = new vluint8_t[entSize()];
|
||||
memcpy(prevDatap(), varp()->datap(), entSize());
|
||||
std::memcpy(prevDatap(), varp()->datap(), entSize());
|
||||
}
|
||||
}
|
||||
};
|
||||
@ -422,7 +422,7 @@ public:
|
||||
explicit VerilatedVpioModule(const VerilatedScope* modulep)
|
||||
: VerilatedVpioScope{modulep} {
|
||||
m_fullname = m_scopep->name();
|
||||
if (strncmp(m_fullname, "TOP.", 4) == 0) m_fullname += 4;
|
||||
if (std::strncmp(m_fullname, "TOP.", 4) == 0) m_fullname += 4;
|
||||
m_name = m_scopep->identifier();
|
||||
}
|
||||
static VerilatedVpioModule* castp(vpiHandle h) {
|
||||
@ -628,7 +628,7 @@ public:
|
||||
VL_DEBUG_IF_PLI(VL_DBG_MSGF("- vpi: value_test %s v[0]=%d/%d %p %p\n",
|
||||
varop->fullname(), *((CData*)newDatap),
|
||||
*((CData*)prevDatap), newDatap, prevDatap););
|
||||
if (memcmp(prevDatap, newDatap, varop->entSize()) != 0) {
|
||||
if (std::memcmp(prevDatap, newDatap, varop->entSize()) != 0) {
|
||||
VL_DEBUG_IF_PLI(VL_DBG_MSGF("- vpi: value_callback %" VL_PRI64
|
||||
"d %s v[0]=%d\n",
|
||||
ho.id(), varop->fullname(), *((CData*)newDatap)););
|
||||
@ -640,7 +640,9 @@ public:
|
||||
}
|
||||
if (was_last) break;
|
||||
}
|
||||
for (const auto& ip : update) { memcpy(ip->prevDatap(), ip->varDatap(), ip->entSize()); }
|
||||
for (const auto& ip : update) {
|
||||
std::memcpy(ip->prevDatap(), ip->varDatap(), ip->entSize());
|
||||
}
|
||||
return called;
|
||||
}
|
||||
|
||||
@ -1099,7 +1101,7 @@ const char* VerilatedVpiError::strFromVpiProp(PLI_INT32 vpiVal) VL_MT_SAFE {
|
||||
}
|
||||
|
||||
#define SELF_CHECK_RESULT_CSTR(got, exp) \
|
||||
if (0 != strcmp((got), (exp))) { \
|
||||
if (0 != std::strcmp((got), (exp))) { \
|
||||
std::string msg \
|
||||
= std::string("%Error: ") + "GOT = '" + got + "'" + " EXP = '" + exp + "'"; \
|
||||
VL_FATAL_MT(__FILE__, __LINE__, "", msg.c_str()); \
|
||||
@ -1236,7 +1238,7 @@ vpiHandle vpi_handle_by_name(PLI_BYTE8* namep, vpiHandle scope) {
|
||||
}
|
||||
const char* baseNamep = scopeAndName.c_str();
|
||||
std::string scopename;
|
||||
const char* dotp = strrchr(namep, '.');
|
||||
const char* dotp = std::strrchr(namep, '.');
|
||||
if (VL_LIKELY(dotp)) {
|
||||
baseNamep = dotp + 1;
|
||||
scopename = std::string(namep, dotp - namep);
|
||||
@ -1826,7 +1828,7 @@ vpiHandle vpi_put_value(vpiHandle object, p_vpi_value valuep, p_vpi_time /*time_
|
||||
}
|
||||
} else if (valuep->format == vpiBinStrVal) {
|
||||
int bits = vop->varp()->packed().elements();
|
||||
int len = strlen(valuep->value.str);
|
||||
int len = std::strlen(valuep->value.str);
|
||||
CData* datap = (reinterpret_cast<CData*>(vop->varDatap()));
|
||||
for (int i = 0; i < bits; ++i) {
|
||||
char set = (i < len) ? (valuep->value.str[len - i - 1] == '1') : 0;
|
||||
@ -1842,7 +1844,7 @@ vpiHandle vpi_put_value(vpiHandle object, p_vpi_value valuep, p_vpi_time /*time_
|
||||
} else if (valuep->format == vpiOctStrVal) {
|
||||
int chars = (vop->varp()->packed().elements() + 2) / 3;
|
||||
int bytes = VL_BYTES_I(vop->varp()->packed().elements());
|
||||
int len = strlen(valuep->value.str);
|
||||
int len = std::strlen(valuep->value.str);
|
||||
CData* datap = (reinterpret_cast<CData*>(vop->varDatap()));
|
||||
div_t idx;
|
||||
datap[0] = 0; // reset zero'th byte
|
||||
@ -1892,7 +1894,7 @@ vpiHandle vpi_put_value(vpiHandle object, p_vpi_value valuep, p_vpi_time /*time_
|
||||
} else if (valuep->format == vpiDecStrVal) {
|
||||
char remainder[16];
|
||||
unsigned long long val;
|
||||
int success = sscanf(valuep->value.str, "%30llu%15s", &val, remainder);
|
||||
int success = std::sscanf(valuep->value.str, "%30llu%15s", &val, remainder);
|
||||
if (success < 1) {
|
||||
VL_VPI_ERROR_(__FILE__, __LINE__, "%s: Parsing failed for '%s' as value %s for %s",
|
||||
VL_FUNC, valuep->value.str,
|
||||
@ -1925,7 +1927,7 @@ vpiHandle vpi_put_value(vpiHandle object, p_vpi_value valuep, p_vpi_time /*time_
|
||||
char* val = valuep->value.str;
|
||||
// skip hex ident if one is detected at the start of the string
|
||||
if (val[0] == '0' && (val[1] == 'x' || val[1] == 'X')) val += 2;
|
||||
int len = strlen(val);
|
||||
int len = std::strlen(val);
|
||||
for (int i = 0; i < chars; ++i) {
|
||||
char hex;
|
||||
// compute hex digit value
|
||||
@ -1961,7 +1963,7 @@ vpiHandle vpi_put_value(vpiHandle object, p_vpi_value valuep, p_vpi_time /*time_
|
||||
return object;
|
||||
} else if (valuep->format == vpiStringVal) {
|
||||
int bytes = VL_BYTES_I(vop->varp()->packed().elements());
|
||||
int len = strlen(valuep->value.str);
|
||||
int len = std::strlen(valuep->value.str);
|
||||
CData* datap = (reinterpret_cast<CData*>(vop->varDatap()));
|
||||
for (int i = 0; i < bytes; ++i) {
|
||||
// prepend with 0 values before placing string the least significant bytes
|
||||
@ -2104,7 +2106,7 @@ PLI_INT32 vpi_mcd_flush(PLI_UINT32 mcd) {
|
||||
FILE* fp = VL_CVT_I_FP(mcd);
|
||||
VL_VPI_ERROR_RESET_();
|
||||
if (VL_UNLIKELY(!fp)) return 1;
|
||||
fflush(fp);
|
||||
std::fflush(fp);
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
@ -240,7 +240,7 @@
|
||||
extern "C" {
|
||||
void __gcov_flush(); // gcc sources gcc/gcov-io.h has the prototype
|
||||
}
|
||||
/// Flush internal code coverage data before e.g. abort()
|
||||
/// Flush internal code coverage data before e.g. std::abort()
|
||||
# define VL_GCOV_FLUSH() \
|
||||
__gcov_flush()
|
||||
#else
|
||||
@ -446,11 +446,11 @@ typedef unsigned long long vluint64_t; ///< 64-bit unsigned type
|
||||
// #defines, to avoid requiring math.h on all compile runs
|
||||
|
||||
#ifdef _MSC_VER
|
||||
# define VL_TRUNC(n) (((n) < 0) ? ceil((n)) : floor((n)))
|
||||
# define VL_ROUND(n) (((n) < 0) ? ceil((n)-0.5) : floor((n) + 0.5))
|
||||
# define VL_TRUNC(n) (((n) < 0) ? std::ceil((n)) : std::floor((n)))
|
||||
# define VL_ROUND(n) (((n) < 0) ? std::ceil((n)-0.5) : std::floor((n) + 0.5))
|
||||
#else
|
||||
# define VL_TRUNC(n) trunc(n)
|
||||
# define VL_ROUND(n) round(n)
|
||||
# define VL_TRUNC(n) std::trunc(n)
|
||||
# define VL_ROUND(n) std::round(n)
|
||||
#endif
|
||||
|
||||
//=========================================================================
|
||||
|
@ -6315,7 +6315,7 @@ public:
|
||||
: ASTGEN_SUPER(fl, lhsp) {}
|
||||
ASTNODE_NODE_FUNCS(LogD)
|
||||
virtual void numberOperate(V3Number& out, const V3Number& lhs) override {
|
||||
out.setDouble(log(lhs.toDouble()));
|
||||
out.setDouble(std::log(lhs.toDouble()));
|
||||
}
|
||||
virtual string emitVerilog() override { return "%f$ln(%l)"; }
|
||||
virtual string emitC() override { return "log(%li)"; }
|
||||
@ -6326,7 +6326,7 @@ public:
|
||||
: ASTGEN_SUPER(fl, lhsp) {}
|
||||
ASTNODE_NODE_FUNCS(Log10D)
|
||||
virtual void numberOperate(V3Number& out, const V3Number& lhs) override {
|
||||
out.setDouble(log10(lhs.toDouble()));
|
||||
out.setDouble(std::log10(lhs.toDouble()));
|
||||
}
|
||||
virtual string emitVerilog() override { return "%f$log10(%l)"; }
|
||||
virtual string emitC() override { return "log10(%li)"; }
|
||||
@ -6338,7 +6338,7 @@ public:
|
||||
: ASTGEN_SUPER(fl, lhsp) {}
|
||||
ASTNODE_NODE_FUNCS(ExpD)
|
||||
virtual void numberOperate(V3Number& out, const V3Number& lhs) override {
|
||||
out.setDouble(exp(lhs.toDouble()));
|
||||
out.setDouble(std::exp(lhs.toDouble()));
|
||||
}
|
||||
virtual string emitVerilog() override { return "%f$exp(%l)"; }
|
||||
virtual string emitC() override { return "exp(%li)"; }
|
||||
@ -6350,7 +6350,7 @@ public:
|
||||
: ASTGEN_SUPER(fl, lhsp) {}
|
||||
ASTNODE_NODE_FUNCS(SqrtD)
|
||||
virtual void numberOperate(V3Number& out, const V3Number& lhs) override {
|
||||
out.setDouble(sqrt(lhs.toDouble()));
|
||||
out.setDouble(std::sqrt(lhs.toDouble()));
|
||||
}
|
||||
virtual string emitVerilog() override { return "%f$sqrt(%l)"; }
|
||||
virtual string emitC() override { return "sqrt(%li)"; }
|
||||
@ -6362,7 +6362,7 @@ public:
|
||||
: ASTGEN_SUPER(fl, lhsp) {}
|
||||
ASTNODE_NODE_FUNCS(FloorD)
|
||||
virtual void numberOperate(V3Number& out, const V3Number& lhs) override {
|
||||
out.setDouble(floor(lhs.toDouble()));
|
||||
out.setDouble(std::floor(lhs.toDouble()));
|
||||
}
|
||||
virtual string emitVerilog() override { return "%f$floor(%l)"; }
|
||||
virtual string emitC() override { return "floor(%li)"; }
|
||||
@ -6374,7 +6374,7 @@ public:
|
||||
: ASTGEN_SUPER(fl, lhsp) {}
|
||||
ASTNODE_NODE_FUNCS(CeilD)
|
||||
virtual void numberOperate(V3Number& out, const V3Number& lhs) override {
|
||||
out.setDouble(ceil(lhs.toDouble()));
|
||||
out.setDouble(std::ceil(lhs.toDouble()));
|
||||
}
|
||||
virtual string emitVerilog() override { return "%f$ceil(%l)"; }
|
||||
virtual string emitC() override { return "ceil(%li)"; }
|
||||
@ -6386,7 +6386,7 @@ public:
|
||||
: ASTGEN_SUPER(fl, lhsp) {}
|
||||
ASTNODE_NODE_FUNCS(SinD)
|
||||
virtual void numberOperate(V3Number& out, const V3Number& lhs) override {
|
||||
out.setDouble(sin(lhs.toDouble()));
|
||||
out.setDouble(std::sin(lhs.toDouble()));
|
||||
}
|
||||
virtual string emitVerilog() override { return "%f$sin(%l)"; }
|
||||
virtual string emitC() override { return "sin(%li)"; }
|
||||
@ -6398,7 +6398,7 @@ public:
|
||||
: ASTGEN_SUPER(fl, lhsp) {}
|
||||
ASTNODE_NODE_FUNCS(CosD)
|
||||
virtual void numberOperate(V3Number& out, const V3Number& lhs) override {
|
||||
out.setDouble(cos(lhs.toDouble()));
|
||||
out.setDouble(std::cos(lhs.toDouble()));
|
||||
}
|
||||
virtual string emitVerilog() override { return "%f$cos(%l)"; }
|
||||
virtual string emitC() override { return "cos(%li)"; }
|
||||
@ -6410,7 +6410,7 @@ public:
|
||||
: ASTGEN_SUPER(fl, lhsp) {}
|
||||
ASTNODE_NODE_FUNCS(TanD)
|
||||
virtual void numberOperate(V3Number& out, const V3Number& lhs) override {
|
||||
out.setDouble(tan(lhs.toDouble()));
|
||||
out.setDouble(std::tan(lhs.toDouble()));
|
||||
}
|
||||
virtual string emitVerilog() override { return "%f$tan(%l)"; }
|
||||
virtual string emitC() override { return "tan(%li)"; }
|
||||
@ -6422,7 +6422,7 @@ public:
|
||||
: ASTGEN_SUPER(fl, lhsp) {}
|
||||
ASTNODE_NODE_FUNCS(AsinD)
|
||||
virtual void numberOperate(V3Number& out, const V3Number& lhs) override {
|
||||
out.setDouble(asin(lhs.toDouble()));
|
||||
out.setDouble(std::asin(lhs.toDouble()));
|
||||
}
|
||||
virtual string emitVerilog() override { return "%f$asin(%l)"; }
|
||||
virtual string emitC() override { return "asin(%li)"; }
|
||||
@ -6434,7 +6434,7 @@ public:
|
||||
: ASTGEN_SUPER(fl, lhsp) {}
|
||||
ASTNODE_NODE_FUNCS(AcosD)
|
||||
virtual void numberOperate(V3Number& out, const V3Number& lhs) override {
|
||||
out.setDouble(acos(lhs.toDouble()));
|
||||
out.setDouble(std::acos(lhs.toDouble()));
|
||||
}
|
||||
virtual string emitVerilog() override { return "%f$acos(%l)"; }
|
||||
virtual string emitC() override { return "acos(%li)"; }
|
||||
@ -6446,7 +6446,7 @@ public:
|
||||
: ASTGEN_SUPER(fl, lhsp) {}
|
||||
ASTNODE_NODE_FUNCS(AtanD)
|
||||
virtual void numberOperate(V3Number& out, const V3Number& lhs) override {
|
||||
out.setDouble(atan(lhs.toDouble()));
|
||||
out.setDouble(std::atan(lhs.toDouble()));
|
||||
}
|
||||
virtual string emitVerilog() override { return "%f$atan(%l)"; }
|
||||
virtual string emitC() override { return "atan(%li)"; }
|
||||
@ -6458,7 +6458,7 @@ public:
|
||||
: ASTGEN_SUPER(fl, lhsp) {}
|
||||
ASTNODE_NODE_FUNCS(SinhD)
|
||||
virtual void numberOperate(V3Number& out, const V3Number& lhs) override {
|
||||
out.setDouble(sinh(lhs.toDouble()));
|
||||
out.setDouble(std::sinh(lhs.toDouble()));
|
||||
}
|
||||
virtual string emitVerilog() override { return "%f$sinh(%l)"; }
|
||||
virtual string emitC() override { return "sinh(%li)"; }
|
||||
@ -6470,7 +6470,7 @@ public:
|
||||
: ASTGEN_SUPER(fl, lhsp) {}
|
||||
ASTNODE_NODE_FUNCS(CoshD)
|
||||
virtual void numberOperate(V3Number& out, const V3Number& lhs) override {
|
||||
out.setDouble(cosh(lhs.toDouble()));
|
||||
out.setDouble(std::cosh(lhs.toDouble()));
|
||||
}
|
||||
virtual string emitVerilog() override { return "%f$cosh(%l)"; }
|
||||
virtual string emitC() override { return "cosh(%li)"; }
|
||||
@ -6482,7 +6482,7 @@ public:
|
||||
: ASTGEN_SUPER(fl, lhsp) {}
|
||||
ASTNODE_NODE_FUNCS(TanhD)
|
||||
virtual void numberOperate(V3Number& out, const V3Number& lhs) override {
|
||||
out.setDouble(tanh(lhs.toDouble()));
|
||||
out.setDouble(std::tanh(lhs.toDouble()));
|
||||
}
|
||||
virtual string emitVerilog() override { return "%f$tanh(%l)"; }
|
||||
virtual string emitC() override { return "tanh(%li)"; }
|
||||
@ -6494,7 +6494,7 @@ public:
|
||||
: ASTGEN_SUPER(fl, lhsp) {}
|
||||
ASTNODE_NODE_FUNCS(AsinhD)
|
||||
virtual void numberOperate(V3Number& out, const V3Number& lhs) override {
|
||||
out.setDouble(asinh(lhs.toDouble()));
|
||||
out.setDouble(std::asinh(lhs.toDouble()));
|
||||
}
|
||||
virtual string emitVerilog() override { return "%f$asinh(%l)"; }
|
||||
virtual string emitC() override { return "asinh(%li)"; }
|
||||
@ -6506,7 +6506,7 @@ public:
|
||||
: ASTGEN_SUPER(fl, lhsp) {}
|
||||
ASTNODE_NODE_FUNCS(AcoshD)
|
||||
virtual void numberOperate(V3Number& out, const V3Number& lhs) override {
|
||||
out.setDouble(acosh(lhs.toDouble()));
|
||||
out.setDouble(std::acosh(lhs.toDouble()));
|
||||
}
|
||||
virtual string emitVerilog() override { return "%f$acosh(%l)"; }
|
||||
virtual string emitC() override { return "acosh(%li)"; }
|
||||
@ -6518,7 +6518,7 @@ public:
|
||||
: ASTGEN_SUPER(fl, lhsp) {}
|
||||
ASTNODE_NODE_FUNCS(AtanhD)
|
||||
virtual void numberOperate(V3Number& out, const V3Number& lhs) override {
|
||||
out.setDouble(atanh(lhs.toDouble()));
|
||||
out.setDouble(std::atanh(lhs.toDouble()));
|
||||
}
|
||||
virtual string emitVerilog() override { return "%f$atanh(%l)"; }
|
||||
virtual string emitC() override { return "atanh(%li)"; }
|
||||
@ -8190,7 +8190,7 @@ public:
|
||||
return new AstAtan2D(this->fileline(), lhsp, rhsp);
|
||||
}
|
||||
virtual void numberOperate(V3Number& out, const V3Number& lhs, const V3Number& rhs) override {
|
||||
out.setDouble(atan2(lhs.toDouble(), rhs.toDouble()));
|
||||
out.setDouble(std::atan2(lhs.toDouble(), rhs.toDouble()));
|
||||
}
|
||||
virtual string emitVerilog() override { return "%f$atan2(%l,%r)"; }
|
||||
virtual string emitC() override { return "atan2(%li,%ri)"; }
|
||||
@ -8205,7 +8205,7 @@ public:
|
||||
return new AstHypotD(this->fileline(), lhsp, rhsp);
|
||||
}
|
||||
virtual void numberOperate(V3Number& out, const V3Number& lhs, const V3Number& rhs) override {
|
||||
out.setDouble(hypot(lhs.toDouble(), rhs.toDouble()));
|
||||
out.setDouble(std::hypot(lhs.toDouble(), rhs.toDouble()));
|
||||
}
|
||||
virtual string emitVerilog() override { return "%f$hypot(%l,%r)"; }
|
||||
virtual string emitC() override { return "hypot(%li,%ri)"; }
|
||||
|
@ -161,7 +161,7 @@ void V3Error::vlAbortOrExit() {
|
||||
std::cerr << msgPrefix() << "Aborting since under --debug" << endl;
|
||||
V3Error::vlAbort();
|
||||
} else {
|
||||
exit(1);
|
||||
std::exit(1);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -1295,11 +1295,11 @@ void V3Options::parseOptsList(FileLine* fl, const string& optdir, int argc, char
|
||||
DECL_OPTION("-gdbbt", CbCall, []() {}); // Processed only in bin/verilator shell
|
||||
DECL_OPTION("-generate-key", CbCall, [this]() {
|
||||
cout << protectKeyDefaulted() << endl;
|
||||
exit(0);
|
||||
std::exit(0);
|
||||
});
|
||||
DECL_OPTION("-getenv", CbVal, [](const char* valp) {
|
||||
cout << V3Options::getenvBuiltins(valp) << endl;
|
||||
exit(0);
|
||||
std::exit(0);
|
||||
});
|
||||
|
||||
DECL_OPTION("-hierarchical", OnOff, &m_hierarchical);
|
||||
@ -1562,7 +1562,7 @@ void V3Options::parseOptsList(FileLine* fl, const string& optdir, int argc, char
|
||||
|
||||
DECL_OPTION("-V", CbCall, [this]() {
|
||||
showVersion(true);
|
||||
exit(0);
|
||||
std::exit(0);
|
||||
});
|
||||
DECL_OPTION("-v", CbVal, [this, &optdir](const char* valp) {
|
||||
V3Options::addLibraryFile(parseFileArg(optdir, valp));
|
||||
@ -1570,7 +1570,7 @@ void V3Options::parseOptsList(FileLine* fl, const string& optdir, int argc, char
|
||||
DECL_OPTION("-verilate", OnOff, &m_verilate);
|
||||
DECL_OPTION("-version", CbCall, [this]() {
|
||||
showVersion(false);
|
||||
exit(0);
|
||||
std::exit(0);
|
||||
});
|
||||
DECL_OPTION("-vpi", OnOff, &m_vpi);
|
||||
|
||||
|
@ -515,7 +515,7 @@ public:
|
||||
unsigned yabs;
|
||||
xabs = diff(otherp->m_xpos, m_xpos);
|
||||
yabs = diff(otherp->m_ypos, m_ypos);
|
||||
return lround(sqrt(xabs * xabs + yabs * yabs));
|
||||
return std::lround(std::sqrt(xabs * xabs + yabs * yabs));
|
||||
}
|
||||
unsigned xpos() const { return m_xpos; }
|
||||
unsigned ypos() const { return m_ypos; }
|
||||
|
@ -3880,7 +3880,7 @@ private:
|
||||
newp = new AstMul(argp->fileline(),
|
||||
new AstConst(argp->fileline(),
|
||||
AstConst::Unsized64(),
|
||||
llround(scale)),
|
||||
std::llround(scale)),
|
||||
argp);
|
||||
}
|
||||
relinkHandle.relink(newp);
|
||||
|
@ -117,7 +117,7 @@ static void process() {
|
||||
V3Error::abortIfErrors();
|
||||
if (v3Global.opt.debugExitParse()) {
|
||||
cout << "--debug-exit-parse: Exiting after parse\n";
|
||||
exit(0);
|
||||
std::exit(0);
|
||||
}
|
||||
|
||||
// Convert parseref's to varrefs, and other directly post parsing fixups
|
||||
@ -125,7 +125,7 @@ static void process() {
|
||||
if (v3Global.opt.debugExitUvm()) {
|
||||
V3Error::abortIfErrors();
|
||||
cout << "--debug-exit-uvm: Exiting after UVM-supported pass\n";
|
||||
exit(0);
|
||||
std::exit(0);
|
||||
}
|
||||
|
||||
// Cross-link signal names
|
||||
@ -664,7 +664,7 @@ static void execBuildJob() {
|
||||
const int exit_code = V3Os::system(cmdStr);
|
||||
if (exit_code != 0) {
|
||||
v3error(cmdStr << " exited with " << exit_code << std::endl);
|
||||
exit(exit_code);
|
||||
std::exit(exit_code);
|
||||
}
|
||||
}
|
||||
|
||||
@ -676,7 +676,7 @@ static void execHierVerilation() {
|
||||
const int exit_code = V3Os::system(cmdStr);
|
||||
if (exit_code != 0) {
|
||||
v3error(cmdStr << " exited with " << exit_code << std::endl);
|
||||
exit(exit_code);
|
||||
std::exit(exit_code);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -101,10 +101,10 @@ void VlcOptions::parseOptsList(int argc, char** argv) {
|
||||
V3Error::debugDefault(atoi(argv[i]));
|
||||
} else if (!strcmp(sw, "-V")) {
|
||||
showVersion(true);
|
||||
exit(0);
|
||||
std::exit(0);
|
||||
} else if (!strcmp(sw, "-version")) {
|
||||
showVersion(false);
|
||||
exit(0);
|
||||
std::exit(0);
|
||||
} else if (!strcmp(sw, "-write") && (i + 1) < argc) {
|
||||
shift;
|
||||
m_writeFile = argv[i];
|
||||
|
Loading…
Reference in New Issue
Block a user