diff --git a/include/verilated.cpp b/include/verilated.cpp index 0386a40b9..0320a8d86 100644 --- a/include/verilated.cpp +++ b/include/verilated.cpp @@ -208,7 +208,7 @@ void VL_FATAL_MT(const char* filename, int linenum, const char* hier, const char std::string _vl_string_vprintf(const char* formatp, va_list ap) VL_MT_SAFE { va_list aq; va_copy(aq, ap); - size_t len = VL_VSNPRINTF(nullptr, 0, formatp, aq); + const size_t len = VL_VSNPRINTF(nullptr, 0, formatp, aq); va_end(aq); if (VL_UNLIKELY(len < 1)) return ""; @@ -387,7 +387,7 @@ WDataOutP _vl_moddiv_w(int lbits, WDataOutP owp, const WDataInP lwp, const WData if (vw == 1) { // Single divisor word breaks rest of algorithm vluint64_t k = 0; for (int j = uw - 1; j >= 0; --j) { - vluint64_t unw64 = ((k << 32ULL) + static_cast(lwp[j])); + const vluint64_t unw64 = ((k << 32ULL) + static_cast(lwp[j])); owp[j] = unw64 / static_cast(rwp[0]); k = unw64 - static_cast(owp[j]) * static_cast(rwp[0]); } @@ -444,7 +444,7 @@ WDataOutP _vl_moddiv_w(int lbits, WDataOutP owp, const WDataInP lwp, const WData vlsint64_t t = 0; // Must be signed vluint64_t k = 0; for (int i = 0; i < vw; ++i) { - vluint64_t p = qhat * vn[i]; // Multiply by estimate + const vluint64_t p = qhat * vn[i]; // Multiply by estimate t = un[i + j] - k - (p & 0xFFFFFFFFULL); // Subtract un[i + j] = t; k = (p >> 32ULL) - (t >> 32ULL); @@ -698,8 +698,8 @@ std::string _vl_vsformat_time(char* tmp, T ld, int timeunit, bool left, size_t w } } } else { - double shiftd = vl_time_multiplier(shift); - double scaled = ld * shiftd; + const double shiftd = vl_time_multiplier(shift); + const double scaled = ld * shiftd; const double fracDiv = vl_time_multiplier(fracDigits); const double whole = scaled / fracDiv; if (!fracDigits) { @@ -749,7 +749,7 @@ void _vl_vsformat(std::string& output, const char* formatp, va_list ap) VL_MT_SA } } else { // Format character inPct = false; - char fmt = pos[0]; + const char fmt = pos[0]; switch (fmt) { case '0': // FALLTHRU case '1': // FALLTHRU @@ -809,7 +809,7 @@ void _vl_vsformat(std::string& output, const char* formatp, va_list ap) VL_MT_SA output += _vl_vsformat_time(t_tmp, d, timeunit, left, width); } else { const size_t len = pos - pctp + 1; - std::string fmts{pctp, len}; + const std::string fmts{pctp, len}; VL_SNPRINTF(t_tmp, VL_VALUE_STRING_MAX_WIDTH, fmts.c_str(), d); output += t_tmp; } @@ -869,7 +869,7 @@ void _vl_vsformat(std::string& output, const char* formatp, va_list ap) VL_MT_SA } digits = append.length(); } - int needmore = width - digits; + const int needmore = width - digits; std::string padding; if (needmore > 0) { if (pctp && pctp[0] && pctp[1] == '0') { // %0 @@ -892,7 +892,7 @@ void _vl_vsformat(std::string& output, const char* formatp, va_list ap) VL_MT_SA append = VL_DECIMAL_NW(lbits, lwp); digits = append.length(); } - int needmore = width - digits; + const int needmore = width - digits; std::string padding; if (needmore > 0) { if (pctp && pctp[0] && pctp[1] == '0') { // %0 @@ -953,7 +953,7 @@ void _vl_vsformat(std::string& output, const char* formatp, va_list ap) VL_MT_SA case 'x': for (; lsb >= 0; --lsb) { lsb = (lsb / 4) * 4; // Next digit - IData charval = VL_BITRSHIFT_W(lwp, lsb) & 0xf; + const IData charval = VL_BITRSHIFT_W(lwp, lsb) & 0xf; output += "0123456789abcdef"[charval]; } break; @@ -1027,7 +1027,7 @@ static inline void _vl_vsss_read_str(FILE* fp, int& floc, const WDataInP fromp, } static inline char* _vl_vsss_read_bin(FILE* fp, int& floc, const WDataInP fromp, const std::string& fstr, char* beginp, std::size_t n, - bool inhibit = false) { + const bool inhibit = false) { // Variant of _vl_vsss_read_str using the same underlying I/O functions but optimized // specifically for block reads of N bytes (read operations are not demarcated by // whitespace). In the fp case, except descriptor to have been opened in binary mode. @@ -1100,16 +1100,16 @@ IData _vl_vsscanf(FILE* fp, // If a fscanf _vl_vsss_skipspace(fp, floc, fromp, fstr); } else if (!inPct) { // Expected Format _vl_vsss_skipspace(fp, floc, fromp, fstr); - int c = _vl_vsss_peek(fp, floc, fromp, fstr); + const int c = _vl_vsss_peek(fp, floc, fromp, fstr); if (c != pos[0]) goto done; _vl_vsss_advance(fp, floc); } else { // Format character // Skip loading spaces inPct = false; - char fmt = pos[0]; + const char fmt = pos[0]; switch (fmt) { case '%': { - int c = _vl_vsss_peek(fp, floc, fromp, fstr); + const int c = _vl_vsss_peek(fp, floc, fromp, fstr); if (c != '%') goto done; _vl_vsss_advance(fp, floc); break; @@ -1139,7 +1139,7 @@ IData _vl_vsscanf(FILE* fp, // If a fscanf for (int i = 0; i < VL_WORDS_I(obits); ++i) owp[i] = 0; switch (fmt) { case 'c': { - int c = _vl_vsss_peek(fp, floc, fromp, fstr); + const int c = _vl_vsss_peek(fp, floc, fromp, fstr); if (c == EOF) goto done; _vl_vsss_advance(fp, floc); owp[0] = c; @@ -1292,7 +1292,7 @@ void _vl_vint_to_string(int obits, char* destoutp, const WDataInP sourcep) VL_MT char* destp = destoutp; for (; lsb >= 0; --lsb) { lsb = (lsb / 8) * 8; // Next digit - IData charval = VL_BITRSHIFT_W(sourcep, lsb) & 0xff; + const IData charval = VL_BITRSHIFT_W(sourcep, lsb) & 0xff; if (!start || charval) { *destp++ = (charval == 0) ? ' ' : charval; start = false; // Drop leading 0s @@ -1530,16 +1530,16 @@ IData VL_FREAD_I(int width, int array_lsb, int array_size, void* memp, IData fpi // Prep for reading IData read_count = 0; IData read_elements = 0; - int start_shift = (width - 1) & ~7; // bit+7:bit gets first character + const int start_shift = (width - 1) & ~7; // bit+7:bit gets first character int shift = start_shift; // Read the data // 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 = std::fgetc(fp); + const int c = std::fgetc(fp); if (VL_UNLIKELY(c == EOF)) break; // Shift value in - IData entry = read_elements + start - array_lsb; + const IData entry = read_elements + start - array_lsb; if (width <= 8) { CData* const datap = &(reinterpret_cast(memp))[entry]; if (shift == start_shift) *datap = 0; @@ -1728,14 +1728,14 @@ std::string VL_TOUPPER_NN(const std::string& ld) VL_MT_SAFE { std::string VL_CVT_PACK_STR_NW(int lwords, const WDataInP lwp) VL_MT_SAFE { // See also _vl_vint_to_string char destout[VL_VALUE_STRING_MAX_CHARS + 1]; - int obits = lwords * VL_EDATASIZE; + const int obits = lwords * VL_EDATASIZE; int lsb = obits - 1; bool start = true; char* destp = destout; size_t len = 0; for (; lsb >= 0; --lsb) { lsb = (lsb / 8) * 8; // Next digit - IData charval = VL_BITRSHIFT_W(lwp, lsb) & 0xff; + const IData charval = VL_BITRSHIFT_W(lwp, lsb) & 0xff; if (!start || charval) { *destp++ = (charval == 0) ? ' ' : charval; ++len; @@ -2069,7 +2069,7 @@ void VL_READMEM_N(bool hex, // Hex format, else binary VL_FATAL_MT(filename.c_str(), rmem.linenum(), "", "$readmem file address beyond bounds of array"); } else { - QData entry = addr - array_lsb; + const QData entry = addr - array_lsb; if (bits <= 8) { CData* const datap = &(reinterpret_cast(memp))[entry]; rmem.setData(datap, value); @@ -2104,7 +2104,7 @@ void VL_WRITEMEM_N(bool hex, // Hex format, else binary QData start, // First array row address to write QData end // Last address to write, or ~0 when not specified ) VL_MT_SAFE { - QData addr_max = array_lsb + depth - 1; + const QData addr_max = array_lsb + depth - 1; if (start < static_cast(array_lsb)) start = array_lsb; if (end > addr_max) end = addr_max; @@ -2828,7 +2828,7 @@ size_t VerilatedVarProps::totalSize() const { void* VerilatedVarProps::datapAdjustIndex(void* datap, int dim, int indx) const { if (VL_UNLIKELY(dim <= 0 || dim > udims())) return nullptr; if (VL_UNLIKELY(indx < low(dim) || indx > high(dim))) return nullptr; - int indxAdj = indx - low(dim); + const int indxAdj = indx - low(dim); vluint8_t* bytep = reinterpret_cast(datap); // If on index 1 of a 2 index array, then each index 1 is index2sz*entsz size_t slicesz = entSize(); @@ -2873,7 +2873,7 @@ void VerilatedScope::configure(VerilatedSyms* symsp, const char* prefixp, const void VerilatedScope::exportInsert(int finalize, const char* namep, void* cb) VL_MT_UNSAFE { // Slowpath - called once/scope*export at construction // Insert a exported function into scope table - int funcnum = VerilatedImp::exportInsert(namep); + const int funcnum = VerilatedImp::exportInsert(namep); if (!finalize) { // Need two passes so we know array size to create // Alternative is to dynamically stretch the array, which is more code, and slower. @@ -2915,7 +2915,7 @@ void VerilatedScope::varInsert(int finalize, const char* namep, void* datap, boo } else { // We could have a linked list of ranges, but really this whole thing needs // to be generalized to support structs and unions, etc. - std::string msg + const std::string msg = std::string{"Unsupported multi-dimensional public varInsert: "} + namep; VL_FATAL_MT(__FILE__, __LINE__, "", msg.c_str()); } @@ -2962,7 +2962,7 @@ void VerilatedScope::scopeDump() const { VerilatedImp::exportName(i)); } } - if (VerilatedVarNameMap* const varsp = this->varsp()) { + if (const VerilatedVarNameMap* const varsp = this->varsp()) { for (const auto& i : *varsp) VL_PRINTF_MT(" VAR %p: %s\n", &(i.second), i.first); } } diff --git a/include/verilated.h b/include/verilated.h index c6d6815c6..8e502fd08 100644 --- a/include/verilated.h +++ b/include/verilated.h @@ -359,7 +359,7 @@ protected: } m_args VL_GUARDED_BY(m_argMutex); // Implementation details - std::unique_ptr m_impdatap; + const std::unique_ptr m_impdatap; // Coverage access std::unique_ptr m_coveragep; // Pointer for coveragep() diff --git a/include/verilated_cov.cpp b/include/verilated_cov.cpp index af6080275..d52ecc8f8 100644 --- a/include/verilated_cov.cpp +++ b/include/verilated_cov.cpp @@ -206,9 +206,9 @@ private: } // Forward to . so we have a whole word - std::string suffix = *bpost ? std::string{bpost + 1} : ""; + const std::string suffix = *bpost ? std::string{bpost + 1} : ""; - std::string out = prefix + "*" + suffix; + const std::string out = prefix + "*" + suffix; // cout << "\nch pre="<m_vals[addKeynum] = valueIndex(val); ++addKeynum; if (VL_UNCOVERABLE(!legalKey(key))) { - std::string msg + const std::string msg = ("%Error: Coverage keys of one character, or letter+digit are illegal: " + key); // LCOV_EXCL_LINE VL_FATAL_MT("", 0, "", msg.c_str()); @@ -380,8 +380,9 @@ public: for (int i = 0; i < VerilatedCovConst::MAX_KEYS; ++i) { if (itemp->m_keys[i] != VerilatedCovConst::KEY_UNDEF) { - std::string key = VerilatedCovKey::shortKey(m_indexValues[itemp->m_keys[i]]); - std::string val = m_indexValues[itemp->m_vals[i]]; + const std::string key + = VerilatedCovKey::shortKey(m_indexValues[itemp->m_keys[i]]); + const std::string val = m_indexValues[itemp->m_vals[i]]; if (key == VL_CIK_PER_INSTANCE) { if (val != "0") per_instance = true; } diff --git a/include/verilated_dpi.cpp b/include/verilated_dpi.cpp index 69fbada12..d9c826481 100644 --- a/include/verilated_dpi.cpp +++ b/include/verilated_dpi.cpp @@ -428,13 +428,13 @@ void* svGetArrElemPtr(const svOpenArrayHandle h, int indx1, ...) { switch (varp->udims()) { case 1: datap = _vl_svGetArrElemPtr(h, 1, indx1, 0, 0); break; case 2: { - int indx2 = va_arg(ap, int); + const int indx2 = va_arg(ap, int); datap = _vl_svGetArrElemPtr(h, 2, indx1, indx2, 0); break; } case 3: { - int indx2 = va_arg(ap, int); - int indx3 = va_arg(ap, int); + const int indx2 = va_arg(ap, int); + const int indx3 = va_arg(ap, int); datap = _vl_svGetArrElemPtr(h, 3, indx1, indx2, indx3); break; } diff --git a/include/verilated_funcs.h b/include/verilated_funcs.h index cddc44842..6aa228ee1 100644 --- a/include/verilated_funcs.h +++ b/include/verilated_funcs.h @@ -80,7 +80,7 @@ extern WDataOutP VL_RANDOM_W(int obits, WDataOutP outwp); #endif extern IData VL_RANDOM_SEEDED_II(int obits, IData seed) VL_MT_SAFE; inline IData VL_URANDOM_RANGE_I(IData hi, IData lo) { - vluint64_t rnd = vl_rand64(); + const vluint64_t rnd = vl_rand64(); if (VL_LIKELY(hi > lo)) { // (hi - lo + 1) can be zero when hi is UINT_MAX and lo is zero if (VL_UNLIKELY(hi - lo + 1 == 0)) return rnd; @@ -410,7 +410,7 @@ static inline void VL_ASSIGNBIT_QI(int, int bit, QData& lhsr, QData rhs) VL_PURE lhsr = ((lhsr & ~(1ULL << VL_BITBIT_Q(bit))) | (static_cast(rhs) << VL_BITBIT_Q(bit))); } static inline void VL_ASSIGNBIT_WI(int, int bit, WDataOutP owp, IData rhs) VL_MT_SAFE { - EData orig = owp[VL_BITWORD_E(bit)]; + const EData orig = owp[VL_BITWORD_E(bit)]; owp[VL_BITWORD_E(bit)] = ((orig & ~(VL_EUL(1) << VL_BITBIT_E(bit))) | (static_cast(rhs) << VL_BITBIT_E(bit))); } @@ -696,11 +696,11 @@ static inline IData VL_COUNTONES_W(int words, WDataInP const lwp) VL_MT_SAFE { // EMIT_RULE: VL_COUNTBITS_II: oclean = false; lhs clean static inline IData VL_COUNTBITS_I(int lbits, IData lhs, IData ctrl0, IData ctrl1, IData ctrl2) VL_PURE { - int ctrlSum = (ctrl0 & 0x1) + (ctrl1 & 0x1) + (ctrl2 & 0x1); + const int ctrlSum = (ctrl0 & 0x1) + (ctrl1 & 0x1) + (ctrl2 & 0x1); if (ctrlSum == 3) { return VL_COUNTONES_I(lhs); } else if (ctrlSum == 0) { - IData mask = (lbits == 32) ? -1 : ((1 << lbits) - 1); + const IData mask = (lbits == 32) ? -1 : ((1 << lbits) - 1); return VL_COUNTONES_I(~lhs & mask); } else { return (lbits == 32) ? 32 : lbits; @@ -771,7 +771,7 @@ static inline IData VL_CLOG2_Q(QData lhs) VL_PURE { return shifts; } static inline IData VL_CLOG2_W(int words, WDataInP const lwp) VL_MT_SAFE { - EData adjust = (VL_COUNTONES_W(words, lwp) == 1) ? 0 : 1; + const EData adjust = (VL_COUNTONES_W(words, lwp) == 1) ? 0 : 1; for (int i = words - 1; i >= 0; --i) { if (VL_UNLIKELY(lwp[i])) { // Shorter worst case if predict not taken for (int bit = VL_EDATASIZE - 1; bit >= 0; --bit) { @@ -943,7 +943,7 @@ static inline WDataOutP VL_NEGATE_W(int words, WDataOutP owp, WDataInP const lwp static inline void VL_NEGATE_INPLACE_W(int words, WDataOutP owp_lwp) VL_MT_SAFE { EData carry = 1; for (int i = 0; i < words; ++i) { - EData word = ~owp_lwp[i] + carry; + const EData word = ~owp_lwp[i] + carry; carry = (word < ~owp_lwp[i]); owp_lwp[i] = word; } @@ -1022,13 +1022,13 @@ static inline WDataOutP VL_MULS_WWW(int, int lbits, int, WDataOutP owp, WDataInP WData rwstore[VL_MULS_MAX_WORDS]; WDataInP lwusp = lwp; WDataInP rwusp = rwp; - EData lneg = VL_SIGN_E(lbits, lwp[words - 1]); + const EData lneg = VL_SIGN_E(lbits, lwp[words - 1]); if (lneg) { // Negate lhs lwusp = lwstore; VL_NEGATE_W(words, lwstore, lwp); lwstore[words - 1] &= VL_MASK_E(lbits); // Clean it } - EData rneg = VL_SIGN_E(lbits, rwp[words - 1]); + const EData rneg = VL_SIGN_E(lbits, rwp[words - 1]); if (rneg) { // Negate rhs rwusp = rwstore; VL_NEGATE_W(words, rwstore, rwp); @@ -1496,7 +1496,8 @@ static inline WDataOutP VL_STREAML_WWI(int, int lbits, int, WDataOutP owp, WData for (int sbit = 0; sbit < ssize && sbit < lbits - istart; ++sbit) { // Extract a single bit from lwp and shift it to the correct // location for owp. - EData bit = (VL_BITRSHIFT_W(lwp, (istart + sbit)) & 1) << VL_BITBIT_E(ostart + sbit); + const EData bit = (VL_BITRSHIFT_W(lwp, (istart + sbit)) & 1) + << VL_BITBIT_E(ostart + sbit); owp[VL_BITWORD_E(ostart + sbit)] |= bit; } } @@ -1766,7 +1767,8 @@ static inline WDataOutP VL_SHIFTRS_WWI(int obits, int lbits, int, WDataOutP owp, owp[lmsw] &= VL_MASK_E(lbits); } else { const int loffset = rd & VL_SIZEBITS_E; - int nbitsonright = VL_EDATASIZE - loffset; // bits that end up in lword (know loffset!=0) + const int nbitsonright + = VL_EDATASIZE - loffset; // bits that end up in lword (know loffset!=0) // Middle words const int words = VL_WORDS_I(obits - rd); for (int i = 0; i < words; ++i) { @@ -1842,7 +1844,7 @@ static inline QData VL_SHIFTRS_QQQ(int obits, int lbits, int rbits, QData lhs, Q static inline IData VL_BITSEL_IWII(int, int lbits, int, int, WDataInP const lwp, IData rd) VL_MT_SAFE { - int word = VL_BITWORD_E(rd); + const int word = VL_BITWORD_E(rd); if (VL_UNLIKELY(rd > static_cast(lbits))) { return ~0; // Spec says you can go outside the range of a array. Don't coredump if so. // We return all 1's as that's more likely to find bugs (?) than 0's. @@ -1860,14 +1862,14 @@ static inline IData VL_BITSEL_IWII(int, int lbits, int, int, WDataInP const lwp, static inline IData VL_SEL_IWII(int, int lbits, int, int, WDataInP const lwp, IData lsb, IData width) VL_MT_SAFE { - int msb = lsb + width - 1; + const int msb = lsb + width - 1; if (VL_UNLIKELY(msb >= lbits)) { return ~0; // Spec says you can go outside the range of a array. Don't coredump if so. } else if (VL_BITWORD_E(msb) == VL_BITWORD_E(static_cast(lsb))) { return VL_BITRSHIFT_W(lwp, lsb); } else { // 32 bit extraction may span two words - int nbitsfromlow = VL_EDATASIZE - VL_BITBIT_E(lsb); // bits that come from low word + const int nbitsfromlow = VL_EDATASIZE - VL_BITBIT_E(lsb); // bits that come from low word return ((lwp[VL_BITWORD_E(msb)] << nbitsfromlow) | VL_BITRSHIFT_W(lwp, lsb)); } } @@ -1886,7 +1888,7 @@ static inline QData VL_SEL_QWII(int, int lbits, int, int, WDataInP const lwp, ID return (hi << nbitsfromlow) | lo; } else { // 64 bit extraction may span three words - int nbitsfromlow = VL_EDATASIZE - VL_BITBIT_E(lsb); + const int nbitsfromlow = VL_EDATASIZE - VL_BITBIT_E(lsb); const QData hi = (lwp[VL_BITWORD_E(msb)]); const QData mid = (lwp[VL_BITWORD_E(lsb) + 1]); const QData lo = VL_BITRSHIFT_W(lwp, lsb); @@ -2220,31 +2222,31 @@ extern void VL_TIMEFORMAT_IINI(int units, int precision, const std::string& suff extern IData VL_VALUEPLUSARGS_INW(int rbits, const std::string& ld, WDataOutP rwp) VL_MT_SAFE; inline IData VL_VALUEPLUSARGS_INI(int rbits, const std::string& ld, CData& rdr) VL_MT_SAFE { VlWide<2> rwp; - IData got = VL_VALUEPLUSARGS_INW(rbits, ld, rwp); + const IData got = VL_VALUEPLUSARGS_INW(rbits, ld, rwp); if (got) rdr = rwp[0]; return got; } inline IData VL_VALUEPLUSARGS_INI(int rbits, const std::string& ld, SData& rdr) VL_MT_SAFE { VlWide<2> rwp; - IData got = VL_VALUEPLUSARGS_INW(rbits, ld, rwp); + const IData got = VL_VALUEPLUSARGS_INW(rbits, ld, rwp); if (got) rdr = rwp[0]; return got; } inline IData VL_VALUEPLUSARGS_INI(int rbits, const std::string& ld, IData& rdr) VL_MT_SAFE { VlWide<2> rwp; - IData got = VL_VALUEPLUSARGS_INW(rbits, ld, rwp); + const IData got = VL_VALUEPLUSARGS_INW(rbits, ld, rwp); if (got) rdr = rwp[0]; return got; } inline IData VL_VALUEPLUSARGS_INQ(int rbits, const std::string& ld, QData& rdr) VL_MT_SAFE { VlWide<2> rwp; - IData got = VL_VALUEPLUSARGS_INW(rbits, ld, rwp); + const IData got = VL_VALUEPLUSARGS_INW(rbits, ld, rwp); if (got) rdr = VL_SET_QW(rwp); return got; } inline IData VL_VALUEPLUSARGS_INQ(int rbits, const std::string& ld, double& rdr) VL_MT_SAFE { VlWide<2> rwp; - IData got = VL_VALUEPLUSARGS_INW(rbits, ld, rwp); + const IData got = VL_VALUEPLUSARGS_INW(rbits, ld, rwp); if (got) rdr = VL_CVT_D_Q(VL_SET_QW(rwp)); return got; } diff --git a/include/verilated_imp.h b/include/verilated_imp.h index f63b158d0..3a3003437 100644 --- a/include/verilated_imp.h +++ b/include/verilated_imp.h @@ -60,8 +60,8 @@ public: private: // MEMBERS - vluint32_t m_mtaskId; // MTask that did enqueue - std::function m_cb; // Lambda to execute when message received + const vluint32_t m_mtaskId; // MTask that did enqueue + const std::function m_cb; // Lambda to execute when message received public: // CONSTRUCTORS explicit VerilatedMsg(const std::function& cb) @@ -277,7 +277,7 @@ public: // But only for verilated*.cpp IData fdNewMcd(const char* filenamep) VL_MT_SAFE_EXCLUDES(m_fdMutex) { const VerilatedLockGuard lock{m_fdMutex}; if (m_fdFreeMct.empty()) return 0; - IData idx = m_fdFreeMct.back(); + const IData idx = m_fdFreeMct.back(); m_fdFreeMct.pop_back(); m_fdps[idx] = std::fopen(filenamep, "w"); if (VL_UNLIKELY(!m_fdps[idx])) return 0; @@ -299,7 +299,7 @@ public: // But only for verilated*.cpp m_fdFree[i] = id; } } - IData idx = m_fdFree.back(); + const IData idx = m_fdFree.back(); m_fdFree.pop_back(); m_fdps[idx] = fp; return (idx | (1UL << 31)); // bit 31 indicates not MCD @@ -334,7 +334,7 @@ public: // But only for verilated*.cpp const VerilatedLockGuard lock{m_fdMutex}; if (VL_BITISSET_I(fdi, 31)) { // Non-MCD case - IData idx = VL_MASK_I(31) & fdi; + const IData idx = VL_MASK_I(31) & fdi; if (VL_UNLIKELY(idx >= m_fdps.size())) return; if (VL_UNLIKELY(idx <= 2)) return; // stdout/stdin/stderr if (VL_UNLIKELY(!m_fdps[idx])) return; // Already free diff --git a/include/verilated_profiler.h b/include/verilated_profiler.h index 129d0870c..9895b6062 100644 --- a/include/verilated_profiler.h +++ b/include/verilated_profiler.h @@ -27,8 +27,8 @@ // Profile record, private class used only by this header class VerilatedProfilerRec final { - std::string m_name; // Hashed name of mtask/etc - size_t m_counterNumber = 0; // Which counter has data + const std::string m_name; // Hashed name of mtask/etc + const size_t m_counterNumber = 0; // Which counter has data public: // METHODS VerilatedProfilerRec(size_t counterNumber, const std::string& name) diff --git a/include/verilated_save.cpp b/include/verilated_save.cpp index eada7a572..0c2d2e3c2 100644 --- a/include/verilated_save.cpp +++ b/include/verilated_save.cpp @@ -192,7 +192,7 @@ void VerilatedRestore::close() VL_MT_UNSAFE_ONE { void VerilatedSave::flush() VL_MT_UNSAFE_ONE { m_assertOne.check(); if (VL_UNLIKELY(!isOpen())) return; - vluint8_t* wp = m_bufp; + const vluint8_t* wp = m_bufp; while (true) { const ssize_t remaining = (m_cp - wp); if (remaining == 0) break; diff --git a/include/verilated_save.h b/include/verilated_save.h index f49c15f91..8f95a85b9 100644 --- a/include/verilated_save.h +++ b/include/verilated_save.h @@ -279,7 +279,7 @@ inline VerilatedDeserialize& operator>>(VerilatedDeserialize& os, float& rhs) { return os.read(&rhs, sizeof(rhs)); } inline VerilatedSerialize& operator<<(VerilatedSerialize& os, const std::string& rhs) { - vluint32_t len = rhs.length(); + const vluint32_t len = rhs.length(); os << len; return os.write(rhs.data(), len); } diff --git a/include/verilated_sym_props.h b/include/verilated_sym_props.h index 2373760e0..990b4564d 100644 --- a/include/verilated_sym_props.h +++ b/include/verilated_sym_props.h @@ -192,8 +192,8 @@ public: class VerilatedDpiOpenVar final { // MEMBERS - const VerilatedVarProps* m_propsp; // Variable properties - void* m_datap; // Location of data (local to thread always, so safe) + const VerilatedVarProps* const m_propsp; // Variable properties + void* const m_datap; // Location of data (local to thread always, so safe) public: // CONSTRUCTORS VerilatedDpiOpenVar(const VerilatedVarProps* propsp, void* datap) @@ -230,10 +230,10 @@ public: class VerilatedVar final : public VerilatedVarProps { // MEMBERS - void* m_datap; // Location of data - const char* m_namep; // Name - slowpath + void* const m_datap; // Location of data + const char* const m_namep; // Name - slowpath protected: - bool m_isParam; + const bool m_isParam; friend class VerilatedScope; // CONSTRUCTORS VerilatedVar(const char* namep, void* datap, VerilatedVarType vltype, diff --git a/include/verilated_threads.h b/include/verilated_threads.h index e07e4418f..c3af2f681 100644 --- a/include/verilated_threads.h +++ b/include/verilated_threads.h @@ -217,12 +217,12 @@ private: // Store the size atomically, so we can spin wait std::atomic m_ready_size; - VlThreadPool* m_poolp; // Our associated thread pool + VlThreadPool* const m_poolp; // Our associated thread pool - bool m_profiling; // Is profiling enabled? + const bool m_profiling; // Is profiling enabled? std::atomic m_exiting; // Worker thread should exit std::thread m_cthread; // Underlying C++ thread record - VerilatedContext* m_contextp; // Context for spawned thread + VerilatedContext* const m_contextp; // Context for spawned thread VL_UNCOPYABLE(VlWorkerThread); @@ -274,7 +274,7 @@ class VlThreadPool final { // MEMBERS std::vector m_workers; // our workers - bool m_profiling; // is profiling enabled? + const bool m_profiling; // is profiling enabled? // Support profiling -- we can append records of profiling events // to this vector with very low overhead, and then dump them out diff --git a/include/verilated_types.h b/include/verilated_types.h index 8a0dde96d..364378080 100644 --- a/include/verilated_types.h +++ b/include/verilated_types.h @@ -79,10 +79,10 @@ public: // Readmem/Writemem operation classes class VlReadMem final { - bool m_hex; // Hex format - int m_bits; // Bit width of values + const bool m_hex; // Hex format + const int m_bits; // Bit width of values const std::string& m_filename; // Filename - QData m_end; // End address (as specified by user) + const QData m_end; // End address (as specified by user) FILE* m_fp; // File handle for filename QData m_addr; // Next address to read int m_linenum; // Line number last read from file @@ -96,8 +96,8 @@ public: }; class VlWriteMem final { - bool m_hex; // Hex format - int m_bits; // Bit width of values + const bool m_hex; // Hex format + const int m_bits; // Bit width of values FILE* m_fp; // File handle for filename QData m_addr; // Next address to write public: diff --git a/include/verilated_vcd_c.cpp b/include/verilated_vcd_c.cpp index 1a21bdbf2..860c9de41 100644 --- a/include/verilated_vcd_c.cpp +++ b/include/verilated_vcd_c.cpp @@ -281,7 +281,7 @@ void VerilatedVcd::bufferResize(vluint64_t minsize) { // minsize is size of largest write. We buffer at least 8 times as much data, // writing when we are 3/4 full (with thus 2*minsize remaining free) if (VL_UNLIKELY(minsize > m_wrChunkSize)) { - char* oldbufp = m_wrBufp; + const char* oldbufp = m_wrBufp; m_wrChunkSize = minsize * 2; m_wrBufp = new char[m_wrChunkSize * 8]; std::memcpy(m_wrBufp, oldbufp, m_writep - oldbufp); @@ -298,7 +298,7 @@ void VerilatedVcd::bufferFlush() VL_MT_UNSAFE_ONE { // When it gets nearly full we dump it using this routine which calls write() // This is much faster than using buffered I/O if (VL_UNLIKELY(!isOpen())) return; - char* wp = m_wrBufp; + const char* wp = m_wrBufp; while (true) { const ssize_t remaining = (m_writep - wp); if (remaining == 0) break; @@ -311,7 +311,7 @@ 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 + const std::string msg = std::string{"VerilatedVcd::bufferFlush: "} + std::strerror(errno); VL_FATAL_MT("", 0, "", msg.c_str()); closeErr(); @@ -386,7 +386,7 @@ void VerilatedVcd::dumpHeader() { const std::string& decl = i.second; // Determine difference between the old and new names - const char* hiername = hiernamestr.c_str(); + const char* const hiername = hiernamestr.c_str(); const char* lp = lastName; const char* np = hiername; lastName = hiername; diff --git a/include/verilated_vcd_c.h b/include/verilated_vcd_c.h index 6eb3f1d6b..07b8fb0be 100644 --- a/include/verilated_vcd_c.h +++ b/include/verilated_vcd_c.h @@ -74,7 +74,7 @@ private: int m_modDepth = 0; // Depth of module hierarchy char* m_wrBufp; // Output buffer - char* m_wrFlushp; // Output buffer flush trigger location + const char* m_wrFlushp; // Output buffer flush trigger location char* m_writep; // Write pointer into output buffer vluint64_t m_wrChunkSize; // Output buffer size vluint64_t m_wroteBytes = 0; // Number of bytes written to this file diff --git a/include/verilated_vpi.cpp b/include/verilated_vpi.cpp index 5b7bbfe5c..9d8901012 100644 --- a/include/verilated_vpi.cpp +++ b/include/verilated_vpi.cpp @@ -123,8 +123,8 @@ public: class VerilatedVpioTimedCb final : public VerilatedVpio { // A handle to a timed callback created with vpi_register_cb // User can call vpi_remove_cb or vpi_release_handle on it - vluint64_t m_id; // Unique id/sequence number to find schedule's event - QData m_time; + const vluint64_t m_id; // Unique id/sequence number to find schedule's event + const QData m_time; public: VerilatedVpioTimedCb(vluint64_t id, QData time) @@ -141,8 +141,8 @@ public: class VerilatedVpioReasonCb final : public VerilatedVpio { // A handle to a non-timed callback created with vpi_register_cb // User can call vpi_remove_cb or vpi_release_handle on it - vluint64_t m_id; // Unique id/sequence number to find schedule's event - PLI_INT32 m_reason; // VPI callback reason code + const vluint64_t m_id; // Unique id/sequence number to find schedule's event + const PLI_INT32 m_reason; // VPI callback reason code public: // cppcheck-suppress uninitVar // m_value @@ -158,7 +158,7 @@ public: }; class VerilatedVpioConst final : public VerilatedVpio { - vlsint32_t m_num; + const vlsint32_t m_num; public: explicit VerilatedVpioConst(vlsint32_t num) @@ -219,7 +219,7 @@ public: }; class VerilatedVpioRange final : public VerilatedVpio { - const VerilatedRange* m_range; + const VerilatedRange* const m_range; public: explicit VerilatedVpioRange(const VerilatedRange* range) @@ -235,7 +235,7 @@ public: class VerilatedVpioRangeIter final : public VerilatedVpio { // Only supports 1 dimension - const VerilatedRange* m_range; + const VerilatedRange* const m_range; bool m_done = false; public: @@ -258,7 +258,7 @@ public: class VerilatedVpioScope VL_NOT_FINAL : public VerilatedVpio { protected: - const VerilatedScope* m_scopep; + const VerilatedScope* const m_scopep; public: explicit VerilatedVpioScope(const VerilatedScope* scopep) @@ -352,7 +352,7 @@ public: }; class VerilatedVpioVarIter final : public VerilatedVpio { - const VerilatedScope* m_scopep; + const VerilatedScope* const m_scopep; VerilatedVarNameMap::const_iterator m_it; bool m_started = false; @@ -389,9 +389,9 @@ public: class VerilatedVpioMemoryWordIter final : public VerilatedVpio { const vpiHandle m_handle; - const VerilatedVar* m_varp; + const VerilatedVar* const m_varp; vlsint32_t m_iteration; - vlsint32_t m_direction; + const vlsint32_t m_direction; bool m_done = false; public: @@ -413,7 +413,7 @@ public: delete this; // IEEE 37.2.2 vpi_scan at end does a vpi_release_handle return nullptr; } - vpiHandle result = vpi_handle_by_index(m_handle, m_iteration); + const vpiHandle result = vpi_handle_by_index(m_handle, m_iteration); iterationInc(); return result; } @@ -457,7 +457,7 @@ public: delete this; // IEEE 37.2.2 vpi_scan at end does a vpi_release_handle return nullptr; } - const VerilatedScope* modp = *m_it++; + const VerilatedScope* const modp = *m_it++; return (new VerilatedVpioModule{modp})->castVpiHandle(); } }; @@ -595,7 +595,7 @@ public: const auto last = std::prev(cbObjList.end()); // prevent looping over newly added elements for (auto it = cbObjList.begin(); true;) { // cbReasonRemove sets to nullptr, so we know on removal the old end() will still exist - bool was_last = it == last; + const bool was_last = it == last; if (VL_UNLIKELY(it->invalid())) { // Deleted earlier, cleanup it = cbObjList.erase(it); if (was_last) break; @@ -1111,7 +1111,7 @@ const char* VerilatedVpiError::strFromVpiProp(PLI_INT32 vpiVal) VL_MT_SAFE { #define SELF_CHECK_RESULT_CSTR(got, exp) \ if (0 != std::strcmp((got), (exp))) { \ - std::string msg \ + const std::string msg \ = std::string{"%Error: "} + "GOT = '" + (got) + "'" + " EXP = '" + (exp) + "'"; \ VL_FATAL_MT(__FILE__, __LINE__, "", msg.c_str()); \ } @@ -1305,7 +1305,7 @@ vpiHandle vpi_register_cb(p_cb_data cb_data_p) { QData time = 0; if (cb_data_p->time) time = VL_SET_QII(cb_data_p->time->high, cb_data_p->time->low); const QData abstime = VL_TIME_Q() + time; - vluint64_t id = VerilatedVpiImp::nextCallbackId(); + const vluint64_t id = VerilatedVpiImp::nextCallbackId(); VerilatedVpioTimedCb* const vop = new VerilatedVpioTimedCb{id, abstime}; VerilatedVpiImp::cbTimedAdd(id, cb_data_p, abstime); return vop->castVpiHandle(); @@ -1410,7 +1410,7 @@ vpiHandle vpi_handle_by_index(vpiHandle object, PLI_INT32 indx) { VerilatedVpiImp::assertOneCheck(); VL_VPI_ERROR_RESET_(); // Memory words are not indexable - VerilatedVpioMemoryWord* const vop = VerilatedVpioMemoryWord::castp(object); + const VerilatedVpioMemoryWord* const vop = VerilatedVpioMemoryWord::castp(object); if (VL_UNLIKELY(vop)) return nullptr; const VerilatedVpioVar* const varop = VerilatedVpioVar::castp(object); if (VL_LIKELY(varop)) { @@ -1442,7 +1442,7 @@ vpiHandle vpi_handle(PLI_INT32 type, vpiHandle object) { VL_VPI_ERROR_RESET_(); switch (type) { case vpiLeftRange: { - if (VerilatedVpioVarBase* const vop = VerilatedVpioVarBase::castp(object)) { + if (const VerilatedVpioVarBase* const vop = VerilatedVpioVarBase::castp(object)) { if (VL_UNLIKELY(!vop->rangep())) return nullptr; return (new VerilatedVpioConst{vop->rangep()->left()})->castVpiHandle(); } else if (VerilatedVpioRange* const vop = VerilatedVpioRange::castp(object)) { @@ -1455,7 +1455,7 @@ vpiHandle vpi_handle(PLI_INT32 type, vpiHandle object) { return nullptr; } case vpiRightRange: { - if (VerilatedVpioVarBase* const vop = VerilatedVpioVarBase::castp(object)) { + if (const VerilatedVpioVarBase* const vop = VerilatedVpioVarBase::castp(object)) { if (VL_UNLIKELY(!vop->rangep())) return nullptr; return (new VerilatedVpioConst{vop->rangep()->right()})->castVpiHandle(); } else if (VerilatedVpioRange* const vop = VerilatedVpioRange::castp(object)) { @@ -1468,18 +1468,18 @@ vpiHandle vpi_handle(PLI_INT32 type, vpiHandle object) { return nullptr; } case vpiIndex: { - VerilatedVpioVar* const vop = VerilatedVpioVar::castp(object); + const VerilatedVpioVar* const vop = VerilatedVpioVar::castp(object); if (VL_UNLIKELY(!vop)) return nullptr; const vlsint32_t val = vop->index(); return (new VerilatedVpioConst{val})->castVpiHandle(); } case vpiScope: { - VerilatedVpioVarBase* const vop = VerilatedVpioVarBase::castp(object); + const VerilatedVpioVarBase* const vop = VerilatedVpioVarBase::castp(object); if (VL_UNLIKELY(!vop)) return nullptr; return (new VerilatedVpioScope{vop->scopep()})->castVpiHandle(); } case vpiParent: { - VerilatedVpioMemoryWord* const vop = VerilatedVpioMemoryWord::castp(object); + const VerilatedVpioMemoryWord* const vop = VerilatedVpioMemoryWord::castp(object); if (VL_UNLIKELY(!vop)) return nullptr; return (new VerilatedVpioVar{vop->varp(), vop->scopep()})->castVpiHandle(); } @@ -1697,7 +1697,7 @@ void vl_get_value(const VerilatedVar* varp, void* varDatap, p_vpi_value valuep, // Maximum required size is for binary string, one byte per bit plus null termination static VL_THREAD_LOCAL char t_outStr[VL_VALUE_STRING_MAX_WORDS * VL_EDATASIZE + 1]; // cppcheck-suppress variableScope - static VL_THREAD_LOCAL int t_outStrSz = sizeof(t_outStr) - 1; + const static VL_THREAD_LOCAL int t_outStrSz = sizeof(t_outStr) - 1; // We used to presume vpiValue.format = vpiIntVal or if single bit vpiScalarVal // This may cause backward compatibility issues with older code. if (valuep->format == vpiVectorVal) { @@ -1718,14 +1718,14 @@ void vl_get_value(const VerilatedVar* varp, void* varDatap, p_vpi_value valuep, t_out[0].bval = 0; return; } else if (varp->vltype() == VLVT_UINT64) { - QData data = *(reinterpret_cast(varDatap)); + const QData data = *(reinterpret_cast(varDatap)); t_out[1].aval = static_cast(data >> 32ULL); t_out[1].bval = 0; t_out[0].aval = static_cast(data); t_out[0].bval = 0; return; } else if (varp->vltype() == VLVT_WDATA) { - int words = VL_WORDS_I(varp->packed().elements()); + const int words = VL_WORDS_I(varp->packed().elements()); if (VL_UNCOVERABLE(words >= VL_VALUE_STRING_MAX_WORDS)) { VL_FATAL_MT(__FILE__, __LINE__, "", "vpi_get_value with more than VL_VALUE_STRING_MAX_WORDS; increase and " @@ -1741,7 +1741,7 @@ void vl_get_value(const VerilatedVar* varp, void* varDatap, p_vpi_value valuep, } else if (valuep->format == vpiBinStrVal) { valuep->value.str = t_outStr; int bits = varp->packed().elements(); - CData* datap = (reinterpret_cast(varDatap)); + const CData* datap = (reinterpret_cast(varDatap)); int i; if (bits > t_outStrSz) { // limit maximum size of output to size of buffer to prevent overrun. @@ -1754,7 +1754,7 @@ void vl_get_value(const VerilatedVar* varp, void* varDatap, p_vpi_value valuep, VL_VALUE_STRING_MAX_WORDS, bits); } for (i = 0; i < bits; ++i) { - char val = (datap[i >> 3] >> (i & 7)) & 1; + const char val = (datap[i >> 3] >> (i & 7)) & 1; t_outStr[bits - i - 1] = val ? '1' : '0'; } t_outStr[i] = '\0'; @@ -1763,7 +1763,7 @@ void vl_get_value(const VerilatedVar* varp, void* varDatap, p_vpi_value valuep, valuep->value.str = t_outStr; int chars = (varp->packed().elements() + 2) / 3; const int bytes = VL_BYTES_I(varp->packed().elements()); - CData* datap = (reinterpret_cast(varDatap)); + const CData* datap = (reinterpret_cast(varDatap)); int i; if (chars > t_outStrSz) { // limit maximum size of output to size of buffer to prevent overrun. @@ -1788,7 +1788,7 @@ void vl_get_value(const VerilatedVar* varp, void* varDatap, p_vpi_value valuep, if (i == (chars - 1)) { // most signifcant char, mask off non existant bits when vector // size is not a multiple of 3 - unsigned int rem = varp->packed().elements() % 3; + const unsigned int rem = varp->packed().elements() % 3; if (rem) { // generate bit mask & zero non existant bits val &= (1 << rem) - 1; @@ -1821,7 +1821,7 @@ void vl_get_value(const VerilatedVar* varp, void* varDatap, p_vpi_value valuep, } else if (valuep->format == vpiHexStrVal) { valuep->value.str = t_outStr; int chars = (varp->packed().elements() + 3) >> 2; - CData* datap = (reinterpret_cast(varDatap)); + const CData* datap = (reinterpret_cast(varDatap)); int i; if (chars > t_outStrSz) { // limit maximum size of output to size of buffer to prevent overrun. @@ -1855,7 +1855,7 @@ void vl_get_value(const VerilatedVar* varp, void* varDatap, p_vpi_value valuep, } else { valuep->value.str = t_outStr; int bytes = VL_BYTES_I(varp->packed().elements()); - CData* datap = (reinterpret_cast(varDatap)); + const CData* datap = (reinterpret_cast(varDatap)); int i; if (bytes > t_outStrSz) { // limit maximum size of output to size of buffer to prevent overrun. @@ -1899,7 +1899,7 @@ void vpi_get_value(vpiHandle object, p_vpi_value valuep) { VL_VPI_ERROR_RESET_(); if (VL_UNLIKELY(!valuep)) return; - if (VerilatedVpioVar* const vop = VerilatedVpioVar::castp(object)) { + if (const VerilatedVpioVar* const vop = VerilatedVpioVar::castp(object)) { vl_get_value(vop->varp(), vop->varDatap(), valuep, vop->fullname()); return; } else if (const VerilatedVpioParam* const vop = VerilatedVpioParam::castp(object)) { @@ -1970,9 +1970,9 @@ vpiHandle vpi_put_value(vpiHandle object, p_vpi_value valuep, p_vpi_time /*time_ } else if (valuep->format == vpiBinStrVal) { const int bits = vop->varp()->packed().elements(); const int len = std::strlen(valuep->value.str); - CData* datap = (reinterpret_cast(vop->varDatap())); + CData* const datap = (reinterpret_cast(vop->varDatap())); for (int i = 0; i < bits; ++i) { - char set = (i < len) ? (valuep->value.str[len - i - 1] == '1') : 0; + const char set = (i < len) ? (valuep->value.str[len - i - 1] == '1') : 0; // zero bits 7:1 of byte when assigning to bit 0, else // or in 1 if bit set if (i & 7) { @@ -1986,7 +1986,7 @@ vpiHandle vpi_put_value(vpiHandle object, p_vpi_value valuep, p_vpi_time /*time_ const int chars = (vop->varp()->packed().elements() + 2) / 3; const int bytes = VL_BYTES_I(vop->varp()->packed().elements()); const int len = std::strlen(valuep->value.str); - CData* datap = (reinterpret_cast(vop->varDatap())); + CData* const datap = (reinterpret_cast(vop->varDatap())); div_t idx; datap[0] = 0; // reset zero'th byte for (int i = 0; i < chars; ++i) { @@ -1997,7 +1997,7 @@ vpiHandle vpi_put_value(vpiHandle object, p_vpi_value valuep, p_vpi_time /*time_ idx = div(i * 3, 8); if (i < len) { // ignore illegal chars - char digit = valuep->value.str[len - i - 1]; + const char digit = valuep->value.str[len - i - 1]; if (digit >= '0' && digit <= '7') { val.half = digit - '0'; } else { @@ -2064,8 +2064,8 @@ vpiHandle vpi_put_value(vpiHandle object, p_vpi_value valuep, p_vpi_time /*time_ } } else if (valuep->format == vpiHexStrVal) { const int chars = (vop->varp()->packed().elements() + 3) >> 2; - CData* datap = (reinterpret_cast(vop->varDatap())); - char* val = valuep->value.str; + CData* const datap = (reinterpret_cast(vop->varDatap())); + const 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; const int len = std::strlen(val); @@ -2073,7 +2073,7 @@ vpiHandle vpi_put_value(vpiHandle object, p_vpi_value valuep, p_vpi_time /*time_ char hex; // compute hex digit value if (i < len) { - char digit = val[len - i - 1]; + const char digit = val[len - i - 1]; if (digit >= '0' && digit <= '9') { hex = digit - '0'; } else if (digit >= 'a' && digit <= 'f') { @@ -2105,7 +2105,7 @@ vpiHandle vpi_put_value(vpiHandle object, p_vpi_value valuep, p_vpi_time /*time_ } else if (valuep->format == vpiStringVal) { const int bytes = VL_BYTES_I(vop->varp()->packed().elements()); const int len = std::strlen(valuep->value.str); - CData* datap = (reinterpret_cast(vop->varDatap())); + CData* const datap = (reinterpret_cast(vop->varDatap())); for (int i = 0; i < bytes; ++i) { // prepend with 0 values before placing string the least significant bytes datap[i] = (i < len) ? valuep->value.str[len - i - 1] : 0; @@ -2167,7 +2167,7 @@ void vpi_get_time(vpiHandle object, p_vpi_time time_p) { return; } else if (time_p->type == vpiScaledRealTime) { double dtime = VL_TIME_D(); - if (VerilatedVpioScope* const vop = VerilatedVpioScope::castp(object)) { + if (const VerilatedVpioScope* const vop = VerilatedVpioScope::castp(object)) { const int scalePow10 = Verilated::threadContextp()->timeprecision() - vop->scopep()->timeunit(); const double scale = vl_time_multiplier(scalePow10); // e.g. 0.0001 @@ -2287,7 +2287,7 @@ PLI_INT32 vpi_release_handle(vpiHandle object) { PLI_INT32 vpi_get_vlog_info(p_vpi_vlog_info vlog_info_p) VL_MT_SAFE { VerilatedVpiImp::assertOneCheck(); VL_VPI_ERROR_RESET_(); - auto argc_argv = Verilated::threadContextp()->impp()->argc_argv(); + const auto argc_argv = Verilated::threadContextp()->impp()->argc_argv(); vlog_info_p->argc = argc_argv.first; vlog_info_p->argv = argc_argv.second; vlog_info_p->product = const_cast(Verilated::productName());