From ed2f8dc097f23b9c7d59267141f54f0a59f885a0 Mon Sep 17 00:00:00 2001 From: Wilson Snyder Date: Wed, 3 Mar 2021 22:53:50 -0500 Subject: [PATCH] Internals: Rename some internal functions etc to avoid _V --- include/verilated.cpp | 35 ++++---- include/verilated.h | 143 ++++++++++++++++---------------- include/verilated_dpi.cpp | 38 +++++---- include/verilated_dpi.h | 4 +- include/verilated_vpi.cpp | 166 +++++++++++++++++++------------------- src/V3EmitCSyms.cpp | 5 +- src/V3Error.cpp | 8 +- src/V3FileLine.cpp | 4 +- src/V3Number_test.cpp | 2 +- src/VlcMain.cpp | 2 +- 10 files changed, 206 insertions(+), 201 deletions(-) diff --git a/include/verilated.cpp b/include/verilated.cpp index ca4cb6dd5..6ecb1bf8f 100644 --- a/include/verilated.cpp +++ b/include/verilated.cpp @@ -15,6 +15,9 @@ /// This file must be compiled and linked against all objects /// created from Verilator. /// +/// Those macro/function/variable starting or ending in _ are internal, +/// however many of the other function/macros here are also internal. +/// /// Code available from: https://verilator.org /// //========================================================================= @@ -369,7 +372,7 @@ WDataOutP VL_ZERO_RESET_W(int obits, WDataOutP outwp) VL_MT_SAFE { //=========================================================================== // Debug -void _VL_DEBUG_PRINT_W(int lbits, WDataInP iwp) VL_MT_SAFE { +void _vl_debug_print_w(int lbits, WDataInP iwp) VL_MT_SAFE { VL_PRINTF_MT(" Data: w%d: ", lbits); for (int i = VL_WORDS_I(lbits) - 1; i >= 0; --i) VL_PRINTF_MT("%08x ", iwp[i]); VL_PRINTF_MT("\n"); @@ -604,7 +607,7 @@ double VL_ISTOR_D_W(int lbits, WDataInP lwp) VL_PURE { if (!VL_SIGN_W(lbits, lwp)) return VL_ITOR_D_W(lbits, lwp); vluint32_t pos[VL_MULS_MAX_WORDS + 1]; // Fixed size, as MSVC++ doesn't allow [words] here VL_NEGATE_W(VL_WORDS_I(lbits), pos, lwp); - _VL_CLEAN_INPLACE_W(lbits, pos); + _vl_clean_inplace_w(lbits, pos); return -VL_ITOR_D_W(lbits, pos); } @@ -676,7 +679,7 @@ std::string _vl_vsformat_time(char* tmp, double ld, bool left, size_t width) { } // Do a va_arg returning a quad, assuming input argument is anything less than wide -#define _VL_VA_ARG_Q(ap, bits) (((bits) <= VL_IDATASIZE) ? va_arg(ap, IData) : va_arg(ap, QData)) +#define VL_VA_ARG_Q_(ap, bits) (((bits) <= VL_IDATASIZE) ? va_arg(ap, IData) : va_arg(ap, QData)) void _vl_vsformat(std::string& output, const char* formatp, va_list ap) VL_MT_SAFE { // Format a Verilog $write style format into the output list @@ -779,7 +782,7 @@ void _vl_vsformat(std::string& output, const char* formatp, va_list ap) VL_MT_SA WData qlwp[VL_WQ_WORDS_E]; WDataInP lwp = nullptr; if (lbits <= VL_QUADSIZE) { - ld = _VL_VA_ARG_Q(ap, lbits); + ld = VL_VA_ARG_Q_(ap, lbits); VL_SET_WQ(qlwp, ld); lwp = qlwp; } else { @@ -1237,7 +1240,7 @@ FILE* VL_CVT_I_FP(IData lhs) VL_MT_SAFE { return VerilatedImp::fdToFp(lhs); } -void _VL_VINT_TO_STRING(int obits, char* destoutp, WDataInP sourcep) VL_MT_SAFE { +void _vl_vint_to_string(int obits, char* destoutp, WDataInP sourcep) VL_MT_SAFE { // See also VL_DATA_TO_STRING_NW int lsb = obits - 1; bool start = true; @@ -1256,7 +1259,7 @@ void _VL_VINT_TO_STRING(int obits, char* destoutp, WDataInP sourcep) VL_MT_SAFE } } -void _VL_STRING_TO_VINT(int obits, void* destp, size_t srclen, const char* srcp) VL_MT_SAFE { +void _vl_string_to_vint(int obits, void* destp, size_t srclen, const char* srcp) VL_MT_SAFE { // Convert C string to Verilog format size_t bytes = VL_BYTES_I(obits); char* op = reinterpret_cast(destp); @@ -1295,7 +1298,7 @@ IData VL_FGETS_IXI(int obits, void* destp, IData fpi) VL_MT_SAFE { VL_FATAL_MT(__FILE__, __LINE__, "", "Internal: fgets buffer overrun"); // LCOV_EXCL_LINE } - _VL_STRING_TO_VINT(obits, destp, got, str.data()); + _vl_string_to_vint(obits, destp, got, str.data()); return got; } @@ -1336,7 +1339,7 @@ void VL_SFORMAT_X(int obits, CData& destr, const char* formatp, ...) VL_MT_SAFE _vl_vsformat(t_output, formatp, ap); va_end(ap); - _VL_STRING_TO_VINT(obits, &destr, t_output.length(), t_output.c_str()); + _vl_string_to_vint(obits, &destr, t_output.length(), t_output.c_str()); } void VL_SFORMAT_X(int obits, SData& destr, const char* formatp, ...) VL_MT_SAFE { @@ -1347,7 +1350,7 @@ void VL_SFORMAT_X(int obits, SData& destr, const char* formatp, ...) VL_MT_SAFE _vl_vsformat(t_output, formatp, ap); va_end(ap); - _VL_STRING_TO_VINT(obits, &destr, t_output.length(), t_output.c_str()); + _vl_string_to_vint(obits, &destr, t_output.length(), t_output.c_str()); } void VL_SFORMAT_X(int obits, IData& destr, const char* formatp, ...) VL_MT_SAFE { @@ -1358,7 +1361,7 @@ void VL_SFORMAT_X(int obits, IData& destr, const char* formatp, ...) VL_MT_SAFE _vl_vsformat(t_output, formatp, ap); va_end(ap); - _VL_STRING_TO_VINT(obits, &destr, t_output.length(), t_output.c_str()); + _vl_string_to_vint(obits, &destr, t_output.length(), t_output.c_str()); } void VL_SFORMAT_X(int obits, QData& destr, const char* formatp, ...) VL_MT_SAFE { @@ -1369,7 +1372,7 @@ void VL_SFORMAT_X(int obits, QData& destr, const char* formatp, ...) VL_MT_SAFE _vl_vsformat(t_output, formatp, ap); va_end(ap); - _VL_STRING_TO_VINT(obits, &destr, t_output.length(), t_output.c_str()); + _vl_string_to_vint(obits, &destr, t_output.length(), t_output.c_str()); } void VL_SFORMAT_X(int obits, void* destp, const char* formatp, ...) VL_MT_SAFE { @@ -1380,7 +1383,7 @@ void VL_SFORMAT_X(int obits, void* destp, const char* formatp, ...) VL_MT_SAFE { _vl_vsformat(t_output, formatp, ap); va_end(ap); - _VL_STRING_TO_VINT(obits, destp, t_output.length(), t_output.c_str()); + _vl_string_to_vint(obits, destp, t_output.length(), t_output.c_str()); } void VL_SFORMAT_X(int obits_ignored, std::string& output, const char* formatp, ...) VL_MT_SAFE { @@ -1533,7 +1536,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); + _vl_vint_to_string(lhswords * VL_EDATASIZE, filenamez, lhsp); int code = system(filenamez); // Yes, system() is threadsafe return code >> 8; // Want exit status } @@ -1612,7 +1615,7 @@ IData VL_VALUEPLUSARGS_INW(int rbits, const std::string& ld, WDataOutP rwp) VL_M default: // Other simulators simply return 0 in these cases and don't error out return 0; } - _VL_CLEAN_INPLACE_W(rbits, rwp); + _vl_clean_inplace_w(rbits, rwp); return 1; } IData VL_VALUEPLUSARGS_INN(int, const std::string& ld, std::string& rdr) VL_MT_SAFE { @@ -1676,7 +1679,7 @@ std::string VL_TOUPPER_NN(const std::string& ld) VL_MT_SAFE { } std::string VL_CVT_PACK_STR_NW(int lwords, WDataInP lwp) VL_MT_SAFE { - // See also _VL_VINT_TO_STRING + // See also _vl_vint_to_string char destout[VL_TO_STRING_MAX_WORDS * VL_EDATASIZE + 1]; int obits = lwords * VL_EDATASIZE; int lsb = obits - 1; @@ -1912,7 +1915,7 @@ void VlReadMem::setData(void* valuep, const std::string& rhs) { } else { WDataOutP datap = reinterpret_cast(valuep); if (!innum) VL_ZERO_RESET_W(m_bits, datap); - _VL_SHIFTL_INPLACE_W(m_bits, datap, static_cast(shift)); + _vl_shiftl_inplace_w(m_bits, datap, static_cast(shift)); datap[0] |= value; } innum = true; diff --git a/include/verilated.h b/include/verilated.h index 856c04af7..9e2ab1059 100644 --- a/include/verilated.h +++ b/include/verilated.h @@ -16,6 +16,9 @@ /// all C++ files it generates. It contains standard macros and /// classes required by the Verilated code. /// +/// Those macro/function/variable starting or ending in _ are internal, +/// however many of the other function/macros here are also internal. +/// /// Code available from: https://verilator.org /// //************************************************************************* @@ -736,7 +739,7 @@ extern const char* vl_mc_scan_plusargs(const char* prefixp); // PLIish #define VL_SET_QW(lwp) \ ((static_cast((lwp)[0])) \ | (static_cast((lwp)[1]) << (static_cast(VL_EDATASIZE)))) -#define _VL_SET_QII(ld, rd) ((static_cast(ld) << 32ULL) | static_cast(rd)) +#define VL_SET_QII(ld, rd) ((static_cast(ld) << 32ULL) | static_cast(rd)) /// Return FILE* from IData extern FILE* VL_CVT_I_FP(IData lhs) VL_MT_SAFE; @@ -816,7 +819,7 @@ static inline QData VL_EXTENDSIGN_Q(int lbits, QData lhs) VL_PURE { } // Debugging prints -extern void _VL_DEBUG_PRINT_W(int lbits, WDataInP iwp); +extern void _vl_debug_print_w(int lbits, WDataInP iwp); //========================================================================= // Pli macros @@ -898,7 +901,7 @@ double vl_time_multiplier(int scale) VL_PURE; // EMIT_RULE: VL_ASSIGNCLEAN: oclean=clean; obits==lbits; #define VL_ASSIGNCLEAN_W(obits, owp, lwp) VL_CLEAN_WW((obits), (obits), (owp), (lwp)) -static inline WDataOutP _VL_CLEAN_INPLACE_W(int obits, WDataOutP owp) VL_MT_SAFE { +static inline WDataOutP _vl_clean_inplace_w(int obits, WDataOutP owp) VL_MT_SAFE { int words = VL_WORDS_I(obits); owp[words - 1] &= VL_MASK_E(obits); return owp; @@ -1372,10 +1375,10 @@ static inline WDataOutP VL_NOT_W(int words, WDataOutP owp, WDataInP lwp) VL_MT_S // EMIT_RULE: VL_GTE: oclean=clean; lclean==clean; rclean==clean; obits=1; lbits==rbits; // EMIT_RULE: VL_LTE: oclean=clean; lclean==clean; rclean==clean; obits=1; lbits==rbits; #define VL_NEQ_W(words, lwp, rwp) (!VL_EQ_W(words, lwp, rwp)) -#define VL_LT_W(words, lwp, rwp) (_VL_CMP_W(words, lwp, rwp) < 0) -#define VL_LTE_W(words, lwp, rwp) (_VL_CMP_W(words, lwp, rwp) <= 0) -#define VL_GT_W(words, lwp, rwp) (_VL_CMP_W(words, lwp, rwp) > 0) -#define VL_GTE_W(words, lwp, rwp) (_VL_CMP_W(words, lwp, rwp) >= 0) +#define VL_LT_W(words, lwp, rwp) (_vl_cmp_w(words, lwp, rwp) < 0) +#define VL_LTE_W(words, lwp, rwp) (_vl_cmp_w(words, lwp, rwp) <= 0) +#define VL_GT_W(words, lwp, rwp) (_vl_cmp_w(words, lwp, rwp) > 0) +#define VL_GTE_W(words, lwp, rwp) (_vl_cmp_w(words, lwp, rwp) >= 0) // Output clean, AND MUST BE CLEAN static inline IData VL_EQ_W(int words, WDataInP lwp, WDataInP rwp) VL_MT_SAFE { @@ -1385,7 +1388,7 @@ static inline IData VL_EQ_W(int words, WDataInP lwp, WDataInP rwp) VL_MT_SAFE { } // Internal usage -static inline int _VL_CMP_W(int words, WDataInP lwp, WDataInP rwp) VL_MT_SAFE { +static inline int _vl_cmp_w(int words, WDataInP lwp, WDataInP rwp) VL_MT_SAFE { for (int i = words - 1; i >= 0; --i) { if (lwp[i] > rwp[i]) return 1; if (lwp[i] < rwp[i]) return -1; @@ -1393,10 +1396,10 @@ static inline int _VL_CMP_W(int words, WDataInP lwp, WDataInP rwp) VL_MT_SAFE { return 0; // == } -#define VL_LTS_IWW(obits, lbits, rbbits, lwp, rwp) (_VL_CMPS_W(lbits, lwp, rwp) < 0) -#define VL_LTES_IWW(obits, lbits, rbits, lwp, rwp) (_VL_CMPS_W(lbits, lwp, rwp) <= 0) -#define VL_GTS_IWW(obits, lbits, rbits, lwp, rwp) (_VL_CMPS_W(lbits, lwp, rwp) > 0) -#define VL_GTES_IWW(obits, lbits, rbits, lwp, rwp) (_VL_CMPS_W(lbits, lwp, rwp) >= 0) +#define VL_LTS_IWW(obits, lbits, rbbits, lwp, rwp) (_vl_cmps_w(lbits, lwp, rwp) < 0) +#define VL_LTES_IWW(obits, lbits, rbits, lwp, rwp) (_vl_cmps_w(lbits, lwp, rwp) <= 0) +#define VL_GTS_IWW(obits, lbits, rbits, lwp, rwp) (_vl_cmps_w(lbits, lwp, rwp) > 0) +#define VL_GTES_IWW(obits, lbits, rbits, lwp, rwp) (_vl_cmps_w(lbits, lwp, rwp) >= 0) static inline IData VL_GTS_III(int, int lbits, int, IData lhs, IData rhs) VL_PURE { // For lbits==32, this becomes just a single instruction, otherwise ~5. @@ -1444,7 +1447,7 @@ static inline IData VL_LTES_IQQ(int, int lbits, int, QData lhs, QData rhs) VL_PU return lhs_signed <= rhs_signed; } -static inline int _VL_CMPS_W(int lbits, WDataInP lwp, WDataInP rwp) VL_MT_SAFE { +static inline int _vl_cmps_w(int lbits, WDataInP lwp, WDataInP rwp) VL_MT_SAFE { int words = VL_WORDS_I(lbits); int i = words - 1; // We need to flip sense if negative comparison @@ -1621,12 +1624,12 @@ static inline WDataOutP VL_DIVS_WWW(int lbits, WDataOutP owp, WDataInP lwp, WData rwstore[VL_MULS_MAX_WORDS]; WDataInP ltup = lwp; WDataInP rtup = rwp; - if (lsign) ltup = _VL_CLEAN_INPLACE_W(lbits, VL_NEGATE_W(VL_WORDS_I(lbits), lwstore, lwp)); - if (rsign) rtup = _VL_CLEAN_INPLACE_W(lbits, VL_NEGATE_W(VL_WORDS_I(lbits), rwstore, rwp)); + if (lsign) ltup = _vl_clean_inplace_w(lbits, VL_NEGATE_W(VL_WORDS_I(lbits), lwstore, lwp)); + if (rsign) rtup = _vl_clean_inplace_w(lbits, VL_NEGATE_W(VL_WORDS_I(lbits), rwstore, rwp)); if ((lsign && !rsign) || (!lsign && rsign)) { WData qNoSign[VL_MULS_MAX_WORDS]; VL_DIV_WWW(lbits, qNoSign, ltup, rtup); - _VL_CLEAN_INPLACE_W(lbits, VL_NEGATE_W(VL_WORDS_I(lbits), owp, qNoSign)); + _vl_clean_inplace_w(lbits, VL_NEGATE_W(VL_WORDS_I(lbits), owp, qNoSign)); return owp; } else { return VL_DIV_WWW(lbits, owp, ltup, rtup); @@ -1643,12 +1646,12 @@ static inline WDataOutP VL_MODDIVS_WWW(int lbits, WDataOutP owp, WDataInP lwp, WData rwstore[VL_MULS_MAX_WORDS]; WDataInP ltup = lwp; WDataInP rtup = rwp; - if (lsign) ltup = _VL_CLEAN_INPLACE_W(lbits, VL_NEGATE_W(VL_WORDS_I(lbits), lwstore, lwp)); - if (rsign) rtup = _VL_CLEAN_INPLACE_W(lbits, VL_NEGATE_W(VL_WORDS_I(lbits), rwstore, rwp)); + if (lsign) ltup = _vl_clean_inplace_w(lbits, VL_NEGATE_W(VL_WORDS_I(lbits), lwstore, lwp)); + if (rsign) rtup = _vl_clean_inplace_w(lbits, VL_NEGATE_W(VL_WORDS_I(lbits), rwstore, rwp)); if (lsign) { // Only dividend sign matters for modulus WData qNoSign[VL_MULS_MAX_WORDS]; VL_MODDIV_WWW(lbits, qNoSign, ltup, rtup); - _VL_CLEAN_INPLACE_W(lbits, VL_NEGATE_W(VL_WORDS_I(lbits), owp, qNoSign)); + _vl_clean_inplace_w(lbits, VL_NEGATE_W(VL_WORDS_I(lbits), owp, qNoSign)); return owp; } else { return VL_MODDIV_WWW(lbits, owp, ltup, rtup); @@ -1747,31 +1750,31 @@ QData VL_POWSS_QQW(int obits, int, int rbits, QData lhs, WDataInP rwp, bool lsig // INTERNAL: Stuff LHS bit 0++ into OUTPUT at specified offset // ld may be "dirty", output is clean -static inline void _VL_INSERT_II(int, CData& lhsr, IData ld, int hbit, int lbit, +static inline void _vl_insert_II(int, CData& lhsr, IData ld, int hbit, int lbit, int rbits) VL_PURE { IData cleanmask = VL_MASK_I(rbits); IData insmask = (VL_MASK_I(hbit - lbit + 1)) << lbit; lhsr = (lhsr & ~insmask) | ((ld << lbit) & (insmask & cleanmask)); } -static inline void _VL_INSERT_II(int, SData& lhsr, IData ld, int hbit, int lbit, +static inline void _vl_insert_II(int, SData& lhsr, IData ld, int hbit, int lbit, int rbits) VL_PURE { IData cleanmask = VL_MASK_I(rbits); IData insmask = (VL_MASK_I(hbit - lbit + 1)) << lbit; lhsr = (lhsr & ~insmask) | ((ld << lbit) & (insmask & cleanmask)); } -static inline void _VL_INSERT_II(int, IData& lhsr, IData ld, int hbit, int lbit, +static inline void _vl_insert_II(int, IData& lhsr, IData ld, int hbit, int lbit, int rbits) VL_PURE { IData cleanmask = VL_MASK_I(rbits); IData insmask = (VL_MASK_I(hbit - lbit + 1)) << lbit; lhsr = (lhsr & ~insmask) | ((ld << lbit) & (insmask & cleanmask)); } -static inline void _VL_INSERT_QQ(int, QData& lhsr, QData ld, int hbit, int lbit, +static inline void _vl_insert_QQ(int, QData& lhsr, QData ld, int hbit, int lbit, int rbits) VL_PURE { QData cleanmask = VL_MASK_Q(rbits); QData insmask = (VL_MASK_Q(hbit - lbit + 1)) << lbit; lhsr = (lhsr & ~insmask) | ((ld << lbit) & (insmask & cleanmask)); } -static inline void _VL_INSERT_WI(int, WDataOutP owp, IData ld, int hbit, int lbit, +static inline void _vl_insert_WI(int, WDataOutP owp, IData ld, int hbit, int lbit, int rbits = 0) VL_MT_SAFE { int hoffset = VL_BITBIT_E(hbit); int loffset = VL_BITBIT_E(lbit); @@ -1804,7 +1807,7 @@ static inline void _VL_INSERT_WI(int, WDataOutP owp, IData ld, int hbit, int lbi // INTERNAL: Stuff large LHS bit 0++ into OUTPUT at specified offset // lwp may be "dirty" -static inline void _VL_INSERT_WW(int, WDataOutP owp, WDataInP lwp, int hbit, int lbit, +static inline void _vl_insert_WW(int, WDataOutP owp, WDataInP lwp, int hbit, int lbit, int rbits = 0) VL_MT_SAFE { int hoffset = VL_BITBIT_E(hbit); int loffset = VL_BITBIT_E(lbit); @@ -1859,11 +1862,11 @@ static inline void _VL_INSERT_WW(int, WDataOutP owp, WDataInP lwp, int hbit, int } } -static inline void _VL_INSERT_WQ(int obits, WDataOutP owp, QData ld, int hbit, int lbit, +static inline void _vl_insert_WQ(int obits, WDataOutP owp, QData ld, int hbit, int lbit, int rbits = 0) VL_MT_SAFE { WData lwp[VL_WQ_WORDS_E]; VL_SET_WQ(lwp, ld); - _VL_INSERT_WW(obits, owp, lwp, hbit, lbit, rbits); + _vl_insert_WW(obits, owp, lwp, hbit, lbit, rbits); } // EMIT_RULE: VL_REPLICATE: oclean=clean>width32, dirty<=width32; lclean=clean; rclean==clean; @@ -1891,7 +1894,7 @@ static inline WDataOutP VL_REPLICATE_WII(int obits, int lbits, int, WDataOutP ow IData rep) VL_MT_SAFE { owp[0] = ld; for (unsigned i = 1; i < rep; ++i) { - _VL_INSERT_WI(obits, owp, ld, i * lbits + lbits - 1, i * lbits); + _vl_insert_WI(obits, owp, ld, i * lbits + lbits - 1, i * lbits); } return owp; } @@ -1899,7 +1902,7 @@ static inline WDataOutP VL_REPLICATE_WQI(int obits, int lbits, int, WDataOutP ow IData rep) VL_MT_SAFE { VL_SET_WQ(owp, ld); for (unsigned i = 1; i < rep; ++i) { - _VL_INSERT_WQ(obits, owp, ld, i * lbits + lbits - 1, i * lbits); + _vl_insert_WQ(obits, owp, ld, i * lbits + lbits - 1, i * lbits); } return owp; } @@ -1907,7 +1910,7 @@ static inline WDataOutP VL_REPLICATE_WWI(int obits, int lbits, int, WDataOutP ow IData rep) VL_MT_SAFE { for (int i = 0; i < VL_WORDS_I(lbits); ++i) owp[i] = lwp[i]; for (unsigned i = 1; i < rep; ++i) { - _VL_INSERT_WW(obits, owp, lwp, i * lbits + lbits - 1, i * lbits); + _vl_insert_WW(obits, owp, lwp, i * lbits + lbits - 1, i * lbits); } return owp; } @@ -2047,63 +2050,63 @@ static inline WDataOutP VL_CONCAT_WII(int obits, int lbits, int rbits, WDataOutP IData rd) VL_MT_SAFE { owp[0] = rd; for (int i = 1; i < VL_WORDS_I(obits); ++i) owp[i] = 0; - _VL_INSERT_WI(obits, owp, ld, rbits + lbits - 1, rbits); + _vl_insert_WI(obits, owp, ld, rbits + lbits - 1, rbits); return owp; } static inline WDataOutP VL_CONCAT_WWI(int obits, int lbits, int rbits, WDataOutP owp, WDataInP lwp, IData rd) VL_MT_SAFE { owp[0] = rd; for (int i = 1; i < VL_WORDS_I(obits); ++i) owp[i] = 0; - _VL_INSERT_WW(obits, owp, lwp, rbits + lbits - 1, rbits); + _vl_insert_WW(obits, owp, lwp, rbits + lbits - 1, rbits); return owp; } static inline WDataOutP VL_CONCAT_WIW(int obits, int lbits, int rbits, WDataOutP owp, IData ld, WDataInP rwp) VL_MT_SAFE { for (int i = 0; i < VL_WORDS_I(rbits); ++i) owp[i] = rwp[i]; for (int i = VL_WORDS_I(rbits); i < VL_WORDS_I(obits); ++i) owp[i] = 0; - _VL_INSERT_WI(obits, owp, ld, rbits + lbits - 1, rbits); + _vl_insert_WI(obits, owp, ld, rbits + lbits - 1, rbits); return owp; } static inline WDataOutP VL_CONCAT_WIQ(int obits, int lbits, int rbits, WDataOutP owp, IData ld, QData rd) VL_MT_SAFE { VL_SET_WQ(owp, rd); for (int i = VL_WQ_WORDS_E; i < VL_WORDS_I(obits); ++i) owp[i] = 0; - _VL_INSERT_WI(obits, owp, ld, rbits + lbits - 1, rbits); + _vl_insert_WI(obits, owp, ld, rbits + lbits - 1, rbits); return owp; } static inline WDataOutP VL_CONCAT_WQI(int obits, int lbits, int rbits, WDataOutP owp, QData ld, IData rd) VL_MT_SAFE { owp[0] = rd; for (int i = 1; i < VL_WORDS_I(obits); ++i) owp[i] = 0; - _VL_INSERT_WQ(obits, owp, ld, rbits + lbits - 1, rbits); + _vl_insert_WQ(obits, owp, ld, rbits + lbits - 1, rbits); return owp; } static inline WDataOutP VL_CONCAT_WQQ(int obits, int lbits, int rbits, WDataOutP owp, QData ld, QData rd) VL_MT_SAFE { VL_SET_WQ(owp, rd); for (int i = VL_WQ_WORDS_E; i < VL_WORDS_I(obits); ++i) owp[i] = 0; - _VL_INSERT_WQ(obits, owp, ld, rbits + lbits - 1, rbits); + _vl_insert_WQ(obits, owp, ld, rbits + lbits - 1, rbits); return owp; } static inline WDataOutP VL_CONCAT_WWQ(int obits, int lbits, int rbits, WDataOutP owp, WDataInP lwp, QData rd) VL_MT_SAFE { VL_SET_WQ(owp, rd); for (int i = VL_WQ_WORDS_E; i < VL_WORDS_I(obits); ++i) owp[i] = 0; - _VL_INSERT_WW(obits, owp, lwp, rbits + lbits - 1, rbits); + _vl_insert_WW(obits, owp, lwp, rbits + lbits - 1, rbits); return owp; } static inline WDataOutP VL_CONCAT_WQW(int obits, int lbits, int rbits, WDataOutP owp, QData ld, WDataInP rwp) VL_MT_SAFE { for (int i = 0; i < VL_WORDS_I(rbits); ++i) owp[i] = rwp[i]; for (int i = VL_WORDS_I(rbits); i < VL_WORDS_I(obits); ++i) owp[i] = 0; - _VL_INSERT_WQ(obits, owp, ld, rbits + lbits - 1, rbits); + _vl_insert_WQ(obits, owp, ld, rbits + lbits - 1, rbits); return owp; } static inline WDataOutP VL_CONCAT_WWW(int obits, int lbits, int rbits, WDataOutP owp, WDataInP lwp, WDataInP rwp) VL_MT_SAFE { for (int i = 0; i < VL_WORDS_I(rbits); ++i) owp[i] = rwp[i]; for (int i = VL_WORDS_I(rbits); i < VL_WORDS_I(obits); ++i) owp[i] = 0; - _VL_INSERT_WW(obits, owp, lwp, rbits + lbits - 1, rbits); + _vl_insert_WW(obits, owp, lwp, rbits + lbits - 1, rbits); return owp; } @@ -2112,7 +2115,7 @@ static inline WDataOutP VL_CONCAT_WWW(int obits, int lbits, int rbits, WDataOutP // Static shift, used by internal functions // The output is the same as the input - it overlaps! -static inline void _VL_SHIFTL_INPLACE_W(int obits, WDataOutP iowp, +static inline void _vl_shiftl_inplace_w(int obits, WDataOutP iowp, IData rd /*1 or 4*/) VL_MT_SAFE { int words = VL_WORDS_I(obits); EData linsmask = VL_MASK_E(rd); @@ -2138,7 +2141,7 @@ static inline WDataOutP VL_SHIFTL_WWI(int obits, int, int, WDataOutP owp, WDataI for (int i = word_shift; i < VL_WORDS_I(obits); ++i) owp[i] = lwp[i - word_shift]; } else { for (int i = 0; i < VL_WORDS_I(obits); ++i) owp[i] = 0; - _VL_INSERT_WW(obits, owp, lwp, obits - 1, rd); + _vl_insert_WW(obits, owp, lwp, obits - 1, rd); } return owp; } @@ -2427,7 +2430,7 @@ static inline WDataOutP VL_SEL_WWII(int obits, int lbits, int, int, WDataOutP ow // Just a word extract for (int i = 0; i < VL_WORDS_I(obits); ++i) owp[i] = lwp[i + word_shift]; } else { - // Not a _VL_INSERT because the bits come from any bit number and goto bit 0 + // Not a _vl_insert because the bits come from any bit number and goto bit 0 int loffset = lsb & VL_SIZEBITS_E; int nbitsfromlow = VL_EDATASIZE - loffset; // bits that end up in lword (know loffset!=0) // Middle words @@ -2481,7 +2484,7 @@ static inline WDataOutP VL_RTOIROUND_W_D(int obits, WDataOutP owp, double lhs) V if (lsb < 0) { VL_SET_WQ(owp, mantissa >> -lsb); } else if (lsb < obits) { - _VL_INSERT_WQ(obits, owp, mantissa, lsb + 52, lsb); + _vl_insert_WQ(obits, owp, mantissa, lsb + 52, lsb); } if (lhs < 0) VL_NEGATE_INPLACE_W(VL_WORDS_I(obits), owp); return owp; @@ -2493,41 +2496,41 @@ static inline WDataOutP VL_RTOIROUND_W_D(int obits, WDataOutP owp, double lhs) V // EMIT_RULE: VL_ASSIGNRANGE: rclean=dirty; static inline void VL_ASSIGNSEL_IIII(int rbits, int obits, int lsb, CData& lhsr, IData rhs) VL_PURE { - _VL_INSERT_II(obits, lhsr, rhs, lsb + obits - 1, lsb, rbits); + _vl_insert_II(obits, lhsr, rhs, lsb + obits - 1, lsb, rbits); } static inline void VL_ASSIGNSEL_IIII(int rbits, int obits, int lsb, SData& lhsr, IData rhs) VL_PURE { - _VL_INSERT_II(obits, lhsr, rhs, lsb + obits - 1, lsb, rbits); + _vl_insert_II(obits, lhsr, rhs, lsb + obits - 1, lsb, rbits); } static inline void VL_ASSIGNSEL_IIII(int rbits, int obits, int lsb, IData& lhsr, IData rhs) VL_PURE { - _VL_INSERT_II(obits, lhsr, rhs, lsb + obits - 1, lsb, rbits); + _vl_insert_II(obits, lhsr, rhs, lsb + obits - 1, lsb, rbits); } static inline void VL_ASSIGNSEL_QIII(int rbits, int obits, int lsb, QData& lhsr, IData rhs) VL_PURE { - _VL_INSERT_QQ(obits, lhsr, rhs, lsb + obits - 1, lsb, rbits); + _vl_insert_QQ(obits, lhsr, rhs, lsb + obits - 1, lsb, rbits); } static inline void VL_ASSIGNSEL_QQII(int rbits, int obits, int lsb, QData& lhsr, QData rhs) VL_PURE { - _VL_INSERT_QQ(obits, lhsr, rhs, lsb + obits - 1, lsb, rbits); + _vl_insert_QQ(obits, lhsr, rhs, lsb + obits - 1, lsb, rbits); } static inline void VL_ASSIGNSEL_QIIQ(int rbits, int obits, int lsb, QData& lhsr, QData rhs) VL_PURE { - _VL_INSERT_QQ(obits, lhsr, rhs, lsb + obits - 1, lsb, rbits); + _vl_insert_QQ(obits, lhsr, rhs, lsb + obits - 1, lsb, rbits); } // static inline void VL_ASSIGNSEL_IIIW(int obits, int lsb, IData& lhsr, WDataInP rwp) VL_MT_SAFE { // Illegal, as lhs width >= rhs width static inline void VL_ASSIGNSEL_WIII(int rbits, int obits, int lsb, WDataOutP owp, IData rhs) VL_MT_SAFE { - _VL_INSERT_WI(obits, owp, rhs, lsb + obits - 1, lsb, rbits); + _vl_insert_WI(obits, owp, rhs, lsb + obits - 1, lsb, rbits); } static inline void VL_ASSIGNSEL_WIIQ(int rbits, int obits, int lsb, WDataOutP owp, QData rhs) VL_MT_SAFE { - _VL_INSERT_WQ(obits, owp, rhs, lsb + obits - 1, lsb, rbits); + _vl_insert_WQ(obits, owp, rhs, lsb + obits - 1, lsb, rbits); } static inline void VL_ASSIGNSEL_WIIW(int rbits, int obits, int lsb, WDataOutP owp, WDataInP rwp) VL_MT_SAFE { - _VL_INSERT_WW(obits, owp, rwp, lsb + obits - 1, lsb, rbits); + _vl_insert_WW(obits, owp, rwp, lsb + obits - 1, lsb, rbits); } //====================================================================== @@ -2549,81 +2552,81 @@ static inline WDataOutP VL_COND_WIWW(int obits, int, int, int, WDataOutP owp, in // hence all upper words must be zeroed. // If changing the number of functions here, also change EMITCINLINES_NUM_CONSTW -#define _END(obits, wordsSet) \ +#define VL_C_END_(obits, wordsSet) \ for (int i = (wordsSet); i < VL_WORDS_I(obits); ++i) o[i] = 0; \ return o // clang-format off static inline WDataOutP VL_CONST_W_1X(int obits, WDataOutP o, EData d0) VL_MT_SAFE { o[0] = d0; - _END(obits, 1); + VL_C_END_(obits, 1); } static inline WDataOutP VL_CONST_W_2X(int obits, WDataOutP o, EData d1, EData d0) VL_MT_SAFE { o[0] = d0; o[1] = d1; - _END(obits, 2); + VL_C_END_(obits, 2); } static inline WDataOutP VL_CONST_W_3X(int obits, WDataOutP o, EData d2, EData d1, EData d0) VL_MT_SAFE { o[0] = d0; o[1] = d1; o[2] = d2; - _END(obits,3); + VL_C_END_(obits,3); } static inline WDataOutP VL_CONST_W_4X(int obits, WDataOutP o, EData d3, EData d2, EData d1, EData d0) VL_MT_SAFE { o[0] = d0; o[1] = d1; o[2] = d2; o[3] = d3; - _END(obits,4); + VL_C_END_(obits,4); } static inline WDataOutP VL_CONST_W_5X(int obits, WDataOutP o, EData d4, EData d3, EData d2, EData d1, EData d0) VL_MT_SAFE { o[0] = d0; o[1] = d1; o[2] = d2; o[3] = d3; o[4] = d4; - _END(obits,5); + VL_C_END_(obits,5); } static inline WDataOutP VL_CONST_W_6X(int obits, WDataOutP o, EData d5, EData d4, EData d3, EData d2, EData d1, EData d0) VL_MT_SAFE { o[0] = d0; o[1] = d1; o[2] = d2; o[3] = d3; o[4] = d4; o[5] = d5; - _END(obits,6); + VL_C_END_(obits,6); } static inline WDataOutP VL_CONST_W_7X(int obits, WDataOutP o, EData d6, EData d5, EData d4, EData d3, EData d2, EData d1, EData d0) VL_MT_SAFE { o[0] = d0; o[1] = d1; o[2] = d2; o[3] = d3; o[4] = d4; o[5] = d5; o[6] = d6; - _END(obits,7); + VL_C_END_(obits,7); } static inline WDataOutP VL_CONST_W_8X(int obits, WDataOutP o, EData d7, EData d6, EData d5, EData d4, EData d3, EData d2, EData d1, EData d0) VL_MT_SAFE { o[0] = d0; o[1] = d1; o[2] = d2; o[3] = d3; o[4] = d4; o[5] = d5; o[6] = d6; o[7] = d7; - _END(obits,8); + VL_C_END_(obits,8); } // static inline WDataOutP VL_CONSTHI_W_1X(int obits, int lsb, WDataOutP obase, EData d0) VL_MT_SAFE { WDataOutP o = obase + VL_WORDS_I(lsb); o[0] = d0; - _END(obits, VL_WORDS_I(lsb) + 1); + VL_C_END_(obits, VL_WORDS_I(lsb) + 1); } static inline WDataOutP VL_CONSTHI_W_2X(int obits, int lsb, WDataOutP obase, EData d1, EData d0) VL_MT_SAFE { WDataOutP o = obase + VL_WORDS_I(lsb); o[0] = d0; o[1] = d1; - _END(obits, VL_WORDS_I(lsb) + 2); + VL_C_END_(obits, VL_WORDS_I(lsb) + 2); } static inline WDataOutP VL_CONSTHI_W_3X(int obits, int lsb, WDataOutP obase, EData d2, EData d1, EData d0) VL_MT_SAFE { WDataOutP o = obase + VL_WORDS_I(lsb); o[0] = d0; o[1] = d1; o[2] = d2; - _END(obits, VL_WORDS_I(lsb) + 3); + VL_C_END_(obits, VL_WORDS_I(lsb) + 3); } static inline WDataOutP VL_CONSTHI_W_4X(int obits, int lsb, WDataOutP obase, EData d3, EData d2, EData d1, EData d0) VL_MT_SAFE { WDataOutP o = obase + VL_WORDS_I(lsb); o[0] = d0; o[1] = d1; o[2] = d2; o[3] = d3; - _END(obits, VL_WORDS_I(lsb) + 4); + VL_C_END_(obits, VL_WORDS_I(lsb) + 4); } static inline WDataOutP VL_CONSTHI_W_5X(int obits, int lsb, WDataOutP obase, EData d4, @@ -2631,7 +2634,7 @@ static inline WDataOutP VL_CONSTHI_W_5X(int obits, int lsb, WDataOutP obase, WDataOutP o = obase + VL_WORDS_I(lsb); o[0] = d0; o[1] = d1; o[2] = d2; o[3] = d3; o[4] = d4; - _END(obits, VL_WORDS_I(lsb) + 5); + VL_C_END_(obits, VL_WORDS_I(lsb) + 5); } static inline WDataOutP VL_CONSTHI_W_6X(int obits, int lsb, WDataOutP obase, EData d5, EData d4, @@ -2639,7 +2642,7 @@ static inline WDataOutP VL_CONSTHI_W_6X(int obits, int lsb, WDataOutP obase, WDataOutP o = obase + VL_WORDS_I(lsb); o[0] = d0; o[1] = d1; o[2] = d2; o[3] = d3; o[4] = d4; o[5] = d5; - _END(obits, VL_WORDS_I(lsb) + 6); + VL_C_END_(obits, VL_WORDS_I(lsb) + 6); } static inline WDataOutP VL_CONSTHI_W_7X(int obits, int lsb, WDataOutP obase, EData d6, EData d5, EData d4, @@ -2647,7 +2650,7 @@ static inline WDataOutP VL_CONSTHI_W_7X(int obits, int lsb, WDataOutP obase, WDataOutP o = obase + VL_WORDS_I(lsb); o[0] = d0; o[1] = d1; o[2] = d2; o[3] = d3; o[4] = d4; o[5] = d5; o[6] = d6; - _END(obits, VL_WORDS_I(lsb) + 7); + VL_C_END_(obits, VL_WORDS_I(lsb) + 7); } static inline WDataOutP VL_CONSTHI_W_8X(int obits, int lsb, WDataOutP obase, EData d7, EData d6, EData d5, EData d4, @@ -2655,10 +2658,10 @@ static inline WDataOutP VL_CONSTHI_W_8X(int obits, int lsb, WDataOutP obase, WDataOutP o = obase + VL_WORDS_I(lsb); o[0] = d0; o[1] = d1; o[2] = d2; o[3] = d3; o[4] = d4; o[5] = d5; o[6] = d6; o[7] = d7; - _END(obits, VL_WORDS_I(lsb) + 8); + VL_C_END_(obits, VL_WORDS_I(lsb) + 8); } -#undef _END +#undef VL_C_END_ // Partial constant, lower words of vector wider than 8*32, starting at bit number lsb static inline void VL_CONSTLO_W_8X(int lsb, WDataOutP obase, diff --git a/include/verilated_dpi.cpp b/include/verilated_dpi.cpp index 5926da182..00d13172d 100644 --- a/include/verilated_dpi.cpp +++ b/include/verilated_dpi.cpp @@ -37,11 +37,11 @@ //====================================================================== // Internal macros -#define _VL_SVDPI_WARN(...) VL_PRINTF_MT(__VA_ARGS__) +#define VL_SVDPI_WARN_(...) VL_PRINTF_MT(__VA_ARGS__) // Function requires a "context" in the import declaration -#define _VL_SVDPI_CONTEXT_WARN() \ - _VL_SVDPI_WARN("%%Warning: DPI C Function called by Verilog DPI import with missing " \ +#define VL_SVDPI_CONTEXT_WARN_() \ + VL_SVDPI_WARN_("%%Warning: DPI C Function called by Verilog DPI import with missing " \ "'context' keyword.\n") //====================================================================== @@ -120,7 +120,7 @@ void svGetPartselLogic(svLogicVecVal* dp, const svLogicVecVal* sp, int lsb, int dp[VL_WORDS_I(width) - 1].bval &= VL_MASK_I(width); } void svPutPartselBit(svBitVecVal* dp, const svBitVecVal s, int lbit, int width) { - // See also _VL_INSERT_WI + // See also _vl_insert_WI int hbit = lbit + width - 1; int hoffset = VL_BITBIT_I(hbit); int loffset = VL_BITBIT_I(lbit); @@ -218,7 +218,7 @@ static void* _vl_sv_adjusted_datap(const VerilatedDpiOpenVar* varp, int nargs, i int indx2, int indx3) { void* datap = varp->datap(); if (VL_UNLIKELY(nargs != varp->udims())) { - _VL_SVDPI_WARN("%%Warning: DPI svOpenArrayHandle function called on" + VL_SVDPI_WARN_("%%Warning: DPI svOpenArrayHandle function called on" " %d dimensional array using %d dimensional function.\n", varp->udims(), nargs); return nullptr; @@ -226,7 +226,7 @@ static void* _vl_sv_adjusted_datap(const VerilatedDpiOpenVar* varp, int nargs, i if (nargs >= 1) { datap = varp->datapAdjustIndex(datap, 1, indx1); if (VL_UNLIKELY(!datap)) { - _VL_SVDPI_WARN("%%Warning: DPI svOpenArrayHandle function index 1 " + VL_SVDPI_WARN_("%%Warning: DPI svOpenArrayHandle function index 1 " "out of bounds; %d outside [%d:%d].\n", indx1, varp->left(1), varp->right(1)); return nullptr; @@ -235,7 +235,7 @@ static void* _vl_sv_adjusted_datap(const VerilatedDpiOpenVar* varp, int nargs, i if (nargs >= 2) { datap = varp->datapAdjustIndex(datap, 2, indx2); if (VL_UNLIKELY(!datap)) { - _VL_SVDPI_WARN("%%Warning: DPI svOpenArrayHandle function index 2 " + VL_SVDPI_WARN_("%%Warning: DPI svOpenArrayHandle function index 2 " "out of bounds; %d outside [%d:%d].\n", indx2, varp->left(2), varp->right(2)); return nullptr; @@ -244,7 +244,7 @@ static void* _vl_sv_adjusted_datap(const VerilatedDpiOpenVar* varp, int nargs, i if (nargs >= 3) { datap = varp->datapAdjustIndex(datap, 3, indx3); if (VL_UNLIKELY(!datap)) { - _VL_SVDPI_WARN("%%Warning: DPI svOpenArrayHandle function index 3 " + VL_SVDPI_WARN_("%%Warning: DPI svOpenArrayHandle function index 3 " "out of bounds; %d outside [%d:%d].\n", indx1, varp->left(3), varp->right(3)); return nullptr; @@ -285,7 +285,7 @@ static void _vl_svGetBitArrElemVecVal(svBitVecVal* d, const svOpenArrayHandle s, return; } default: // LCOV_EXCL_START // Errored earlier - _VL_SVDPI_WARN("%%Warning: DPI svOpenArrayHandle function unsupported datatype (%d).\n", + VL_SVDPI_WARN_("%%Warning: DPI svOpenArrayHandle function unsupported datatype (%d).\n", varp->vltype()); return; // LCOV_EXCL_STOP } @@ -327,7 +327,7 @@ static void _vl_svGetLogicArrElemVecVal(svLogicVecVal* d, const svOpenArrayHandl return; } default: // LCOV_EXCL_START // Errored earlier - _VL_SVDPI_WARN("%%Warning: DPI svOpenArrayHandle function unsupported datatype (%d).\n", + VL_SVDPI_WARN_("%%Warning: DPI svOpenArrayHandle function unsupported datatype (%d).\n", varp->vltype()); return; // LCOV_EXCL_STOP } @@ -343,14 +343,14 @@ static void _vl_svPutBitArrElemVecVal(const svOpenArrayHandle d, const svBitVecV case VLVT_UINT8: *(reinterpret_cast(datap)) = s[0]; return; case VLVT_UINT16: *(reinterpret_cast(datap)) = s[0]; return; case VLVT_UINT32: *(reinterpret_cast(datap)) = s[0]; return; - case VLVT_UINT64: *(reinterpret_cast(datap)) = _VL_SET_QII(s[1], s[0]); break; + case VLVT_UINT64: *(reinterpret_cast(datap)) = VL_SET_QII(s[1], s[0]); break; case VLVT_WDATA: { WDataOutP wdatap = (reinterpret_cast(datap)); for (int i = 0; i < VL_WORDS_I(varp->packed().elements()); ++i) wdatap[i] = s[i]; return; } default: // LCOV_EXCL_START // Errored earlier - _VL_SVDPI_WARN("%%Warning: DPI svOpenArrayHandle function unsupported datatype (%d).\n", + VL_SVDPI_WARN_("%%Warning: DPI svOpenArrayHandle function unsupported datatype (%d).\n", varp->vltype()); return; // LCOV_EXCL_STOP } @@ -365,16 +365,14 @@ static void _vl_svPutLogicArrElemVecVal(const svOpenArrayHandle d, const svLogic case VLVT_UINT8: *(reinterpret_cast(datap)) = s[0].aval; return; case VLVT_UINT16: *(reinterpret_cast(datap)) = s[0].aval; return; case VLVT_UINT32: *(reinterpret_cast(datap)) = s[0].aval; return; - case VLVT_UINT64: - *(reinterpret_cast(datap)) = _VL_SET_QII(s[1].aval, s[0].aval); - break; + case VLVT_UINT64: *(reinterpret_cast(datap)) = VL_SET_QII(s[1].aval, s[0].aval); break; case VLVT_WDATA: { WDataOutP wdatap = (reinterpret_cast(datap)); for (int i = 0; i < VL_WORDS_I(varp->packed().elements()); ++i) wdatap[i] = s[i].aval; return; } default: // LCOV_EXCL_START // Errored earlier - _VL_SVDPI_WARN("%%Warning: DPI svOpenArrayHandle function unsupported datatype (%d).\n", + VL_SVDPI_WARN_("%%Warning: DPI svOpenArrayHandle function unsupported datatype (%d).\n", varp->vltype()); return; // LCOV_EXCL_STOP } @@ -390,7 +388,7 @@ static svBit _vl_svGetBitArrElem(const svOpenArrayHandle s, int nargs, int indx1 switch (varp->vltype()) { // LCOV_EXCL_BR_LINE case VLVT_UINT8: return (*(reinterpret_cast(datap))) & 1; default: // LCOV_EXCL_START // Errored earlier - _VL_SVDPI_WARN("%%Warning: DPI svOpenArrayHandle function unsupported datatype (%d).\n", + VL_SVDPI_WARN_("%%Warning: DPI svOpenArrayHandle function unsupported datatype (%d).\n", varp->vltype()); return 0; // LCOV_EXCL_STOP } @@ -406,7 +404,7 @@ static void _vl_svPutBitArrElem(const svOpenArrayHandle d, svBit value, int narg switch (varp->vltype()) { // LCOV_EXCL_BR_LINE case VLVT_UINT8: *(reinterpret_cast(datap)) = value; return; default: // LCOV_EXCL_START // Errored earlier - _VL_SVDPI_WARN("%%Warning: DPI svOpenArrayHandle function unsupported datatype (%d).\n", + VL_SVDPI_WARN_("%%Warning: DPI svOpenArrayHandle function unsupported datatype (%d).\n", varp->vltype()); return; // LCOV_EXCL_STOP } @@ -720,7 +718,7 @@ void svPutLogicArrElem3(const svOpenArrayHandle d, svLogic value, int indx1, int svScope svGetScope() { if (VL_UNLIKELY(!Verilated::dpiInContext())) { - _VL_SVDPI_CONTEXT_WARN(); + VL_SVDPI_CONTEXT_WARN_(); return nullptr; } // NOLINTNEXTLINE(google-readability-casting) @@ -756,7 +754,7 @@ void* svGetUserData(const svScope scope, void* userKey) { int svGetCallerInfo(const char** fileNamepp, int* lineNumberp) { if (VL_UNLIKELY(!Verilated::dpiInContext())) { - _VL_SVDPI_CONTEXT_WARN(); + VL_SVDPI_CONTEXT_WARN_(); return false; } if (VL_LIKELY(fileNamepp)) *fileNamepp = Verilated::dpiFilenamep(); // thread local diff --git a/include/verilated_dpi.h b/include/verilated_dpi.h index c2c01cd61..5d666669d 100644 --- a/include/verilated_dpi.h +++ b/include/verilated_dpi.h @@ -39,7 +39,7 @@ static inline void VL_SET_W_SVBV(int obits, WDataOutP owp, const svBitVecVal* lw owp[words - 1] = lwp[words - 1] & VL_MASK_I(obits); } static inline QData VL_SET_Q_SVBV(const svBitVecVal* lwp) VL_MT_SAFE { - return _VL_SET_QII(lwp[1], lwp[0]); + return VL_SET_QII(lwp[1], lwp[0]); } static inline IData VL_SET_I_SVBV(const svBitVecVal* lwp) VL_MT_SAFE { return lwp[0]; } @@ -62,7 +62,7 @@ static inline void VL_SET_W_SVLV(int obits, WDataOutP owp, const svLogicVecVal* owp[words - 1] = lwp[words - 1].aval & VL_MASK_I(obits); } static inline QData VL_SET_Q_SVLV(const svLogicVecVal* lwp) VL_MT_SAFE { - return _VL_SET_QII(lwp[1].aval, lwp[0].aval); + return VL_SET_QII(lwp[1].aval, lwp[0].aval); } static inline IData VL_SET_I_SVLV(const svLogicVecVal* lwp) VL_MT_SAFE { return lwp[0].aval; } diff --git a/include/verilated_vpi.cpp b/include/verilated_vpi.cpp index bd2a186f3..47de95749 100644 --- a/include/verilated_vpi.cpp +++ b/include/verilated_vpi.cpp @@ -35,21 +35,21 @@ // Internal constants #define VL_DEBUG_IF_PLI VL_DEBUG_IF -constexpr unsigned VL_VPI_LINE_SIZE = 8192; +constexpr unsigned VL_VPI_LINE_SIZE_ = 8192; //====================================================================== // Internal macros -#define _VL_VPI_INTERNAL VerilatedVpiImp::error_info()->setMessage(vpiInternal)->setMessage -#define _VL_VPI_SYSTEM VerilatedVpiImp::error_info()->setMessage(vpiSystem)->setMessage -#define _VL_VPI_ERROR VerilatedVpiImp::error_info()->setMessage(vpiError)->setMessage -#define _VL_VPI_WARNING VerilatedVpiImp::error_info()->setMessage(vpiWarning)->setMessage -#define _VL_VPI_NOTICE VerilatedVpiImp::error_info()->setMessage(vpiNotice)->setMessage -#define _VL_VPI_ERROR_RESET VerilatedVpiImp::error_info()->resetError +#define VL_VPI_INTERNAL_ VerilatedVpiImp::error_info()->setMessage(vpiInternal)->setMessage +#define VL_VPI_SYSTEM_ VerilatedVpiImp::error_info()->setMessage(vpiSystem)->setMessage +#define VL_VPI_ERROR_ VerilatedVpiImp::error_info()->setMessage(vpiError)->setMessage +#define VL_VPI_WARNING_ VerilatedVpiImp::error_info()->setMessage(vpiWarning)->setMessage +#define VL_VPI_NOTICE_ VerilatedVpiImp::error_info()->setMessage(vpiNotice)->setMessage +#define VL_VPI_ERROR_RESET_ VerilatedVpiImp::error_info()->resetError // Not supported yet -#define _VL_VPI_UNIMP() \ - (_VL_VPI_ERROR(__FILE__, __LINE__, Verilated::catName("Unsupported VPI function: ", VL_FUNC))) +#define VL_VPI_UNIMP_() \ + (VL_VPI_ERROR_(__FILE__, __LINE__, Verilated::catName("Unsupported VPI function: ", VL_FUNC))) //====================================================================== // Implementation @@ -645,7 +645,7 @@ class VerilatedVpiError final { t_vpi_error_info m_errorInfo; bool m_flag = false; - char m_buff[VL_VPI_LINE_SIZE]; + char m_buff[VL_VPI_LINE_SIZE_]; void setError(PLI_BYTE8* message, PLI_BYTE8* code, PLI_BYTE8* file, PLI_INT32 line) { m_errorInfo.message = message; m_errorInfo.file = file; @@ -1143,16 +1143,16 @@ vpiHandle vpi_register_cb(p_cb_data cb_data_p) { // Don't confuse with the callback-activated t_cb_data object handle // which is the object causing the callback rather than the callback itself VerilatedVpiImp::assertOneCheck(); - _VL_VPI_ERROR_RESET(); + VL_VPI_ERROR_RESET_(); // cppcheck-suppress nullPointer if (VL_UNLIKELY(!cb_data_p)) { - _VL_VPI_WARNING(__FILE__, __LINE__, "%s : callback data pointer is null", VL_FUNC); + VL_VPI_WARNING_(__FILE__, __LINE__, "%s : callback data pointer is null", VL_FUNC); return nullptr; } switch (cb_data_p->reason) { case cbAfterDelay: { QData time = 0; - if (cb_data_p->time) time = _VL_SET_QII(cb_data_p->time->high, cb_data_p->time->low); + if (cb_data_p->time) time = VL_SET_QII(cb_data_p->time->high, cb_data_p->time->low); QData abstime = VL_TIME_Q() + time; vluint64_t id = VerilatedVpiImp::nextCallbackId(); VerilatedVpioTimedCb* vop = new VerilatedVpioTimedCb{id, abstime}; @@ -1175,7 +1175,7 @@ vpiHandle vpi_register_cb(p_cb_data cb_data_p) { return vop->castVpiHandle(); } default: - _VL_VPI_WARNING(__FILE__, __LINE__, "%s: Unsupported callback type %s", VL_FUNC, + VL_VPI_WARNING_(__FILE__, __LINE__, "%s: Unsupported callback type %s", VL_FUNC, VerilatedVpiError::strFromVpiCallbackReason(cb_data_p->reason)); return nullptr; } @@ -1184,26 +1184,26 @@ vpiHandle vpi_register_cb(p_cb_data cb_data_p) { PLI_INT32 vpi_remove_cb(vpiHandle cb_obj) { VL_DEBUG_IF_PLI(VL_DBG_MSGF("- vpi: vpi_remove_cb %p\n", cb_obj);); VerilatedVpiImp::assertOneCheck(); - _VL_VPI_ERROR_RESET(); + VL_VPI_ERROR_RESET_(); VerilatedVpio* vop = VerilatedVpio::castp(cb_obj); if (VL_UNLIKELY(!vop)) return 0; return vop->dovpi_remove_cb(); } -void vpi_get_cb_info(vpiHandle /*object*/, p_cb_data /*cb_data_p*/) { _VL_VPI_UNIMP(); } +void vpi_get_cb_info(vpiHandle /*object*/, p_cb_data /*cb_data_p*/) { VL_VPI_UNIMP_(); } vpiHandle vpi_register_systf(p_vpi_systf_data /*systf_data_p*/) { - _VL_VPI_UNIMP(); + VL_VPI_UNIMP_(); return nullptr; } void vpi_get_systf_info(vpiHandle /*object*/, p_vpi_systf_data /*systf_data_p*/) { - _VL_VPI_UNIMP(); + VL_VPI_UNIMP_(); } // for obtaining handles vpiHandle vpi_handle_by_name(PLI_BYTE8* namep, vpiHandle scope) { VerilatedVpiImp::assertOneCheck(); - _VL_VPI_ERROR_RESET(); + VL_VPI_ERROR_RESET_(); if (VL_UNLIKELY(!namep)) return nullptr; VL_DEBUG_IF_PLI(VL_DBG_MSGF("- vpi: vpi_handle_by_name %s %p\n", namep, scope);); const VerilatedVar* varp = nullptr; @@ -1256,7 +1256,7 @@ vpiHandle vpi_handle_by_index(vpiHandle object, PLI_INT32 indx) { // Used to get array entries VL_DEBUG_IF_PLI(VL_DBG_MSGF("- vpi: vpi_handle_by_index %p %d\n", object, indx);); VerilatedVpiImp::assertOneCheck(); - _VL_VPI_ERROR_RESET(); + VL_VPI_ERROR_RESET_(); // Memory words are not indexable VerilatedVpioMemoryWord* vop = VerilatedVpioMemoryWord::castp(object); if (VL_UNLIKELY(vop)) return nullptr; @@ -1278,7 +1278,7 @@ vpiHandle vpi_handle_by_index(vpiHandle object, PLI_INT32 indx) { indx - varop->varp()->unpacked().left())) ->castVpiHandle(); } - _VL_VPI_INTERNAL(__FILE__, __LINE__, "%s : can't resolve handle", VL_FUNC); + VL_VPI_INTERNAL_(__FILE__, __LINE__, "%s : can't resolve handle", VL_FUNC); return nullptr; } @@ -1287,7 +1287,7 @@ vpiHandle vpi_handle_by_index(vpiHandle object, PLI_INT32 indx) { vpiHandle vpi_handle(PLI_INT32 type, vpiHandle object) { VL_DEBUG_IF_PLI(VL_DBG_MSGF("- vpi: vpi_handle %d %p\n", type, object);); VerilatedVpiImp::assertOneCheck(); - _VL_VPI_ERROR_RESET(); + VL_VPI_ERROR_RESET_(); switch (type) { case vpiLeftRange: { if (VerilatedVpioVar* vop = VerilatedVpioVar::castp(object)) { @@ -1297,7 +1297,7 @@ vpiHandle vpi_handle(PLI_INT32 type, vpiHandle object) { if (VL_UNLIKELY(!vop->rangep())) return nullptr; return (new VerilatedVpioConst(vop->rangep()->left()))->castVpiHandle(); } - _VL_VPI_WARNING(__FILE__, __LINE__, + VL_VPI_WARNING_(__FILE__, __LINE__, "%s: Unsupported vpiHandle (%p) for type %s, nothing will be returned", VL_FUNC, object, VerilatedVpiError::strFromVpiMethod(type)); return nullptr; @@ -1310,7 +1310,7 @@ vpiHandle vpi_handle(PLI_INT32 type, vpiHandle object) { if (VL_UNLIKELY(!vop->rangep())) return nullptr; return (new VerilatedVpioConst(vop->rangep()->right()))->castVpiHandle(); } - _VL_VPI_WARNING(__FILE__, __LINE__, + VL_VPI_WARNING_(__FILE__, __LINE__, "%s: Unsupported vpiHandle (%p) for type %s, nothing will be returned", VL_FUNC, object, VerilatedVpiError::strFromVpiMethod(type)); return nullptr; @@ -1331,7 +1331,7 @@ vpiHandle vpi_handle(PLI_INT32 type, vpiHandle object) { return (new VerilatedVpioVar(vop->varp(), vop->scopep()))->castVpiHandle(); } default: - _VL_VPI_WARNING(__FILE__, __LINE__, "%s: Unsupported type %s, nothing will be returned", + VL_VPI_WARNING_(__FILE__, __LINE__, "%s: Unsupported type %s, nothing will be returned", VL_FUNC, VerilatedVpiError::strFromVpiMethod(type)); return nullptr; } @@ -1339,21 +1339,21 @@ vpiHandle vpi_handle(PLI_INT32 type, vpiHandle object) { vpiHandle vpi_handle_multi(PLI_INT32 /*type*/, vpiHandle /*refHandle1*/, vpiHandle /*refHandle2*/, ...) { - _VL_VPI_UNIMP(); + VL_VPI_UNIMP_(); return nullptr; } vpiHandle vpi_iterate(PLI_INT32 type, vpiHandle object) { VL_DEBUG_IF_PLI(VL_DBG_MSGF("- vpi: vpi_iterate %d %p\n", type, object);); VerilatedVpiImp::assertOneCheck(); - _VL_VPI_ERROR_RESET(); + VL_VPI_ERROR_RESET_(); switch (type) { case vpiMemoryWord: { VerilatedVpioVar* vop = VerilatedVpioVar::castp(object); if (VL_UNLIKELY(!vop)) return nullptr; if (vop->varp()->dims() < 2) return nullptr; if (vop->varp()->dims() > 2) { - _VL_VPI_WARNING(__FILE__, __LINE__, + VL_VPI_WARNING_(__FILE__, __LINE__, "%s: %s, object %s has unsupported number of indices (%d)", VL_FUNC, VerilatedVpiError::strFromVpiMethod(type), vop->fullname(), vop->varp()->dims()); @@ -1366,7 +1366,7 @@ vpiHandle vpi_iterate(PLI_INT32 type, vpiHandle object) { if (vop->varp()->dims() < 2) return nullptr; // Unsupported is multidim list if (vop->varp()->dims() > 2) { - _VL_VPI_WARNING(__FILE__, __LINE__, + VL_VPI_WARNING_(__FILE__, __LINE__, "%s: %s, object %s has unsupported number of indices (%d)", VL_FUNC, VerilatedVpiError::strFromVpiMethod(type), vop->fullname(), vop->varp()->dims()); @@ -1387,7 +1387,7 @@ vpiHandle vpi_iterate(PLI_INT32 type, vpiHandle object) { return ((new VerilatedVpioModuleIter(it->second))->castVpiHandle()); } default: - _VL_VPI_WARNING(__FILE__, __LINE__, "%s: Unsupported type %s, nothing will be returned", + VL_VPI_WARNING_(__FILE__, __LINE__, "%s: Unsupported type %s, nothing will be returned", VL_FUNC, VerilatedVpiError::strFromVpiObjType(type)); return nullptr; } @@ -1395,7 +1395,7 @@ vpiHandle vpi_iterate(PLI_INT32 type, vpiHandle object) { vpiHandle vpi_scan(vpiHandle object) { VL_DEBUG_IF_PLI(VL_DBG_MSGF("- vpi: vpi_scan %p\n", object);); VerilatedVpiImp::assertOneCheck(); - _VL_VPI_ERROR_RESET(); + VL_VPI_ERROR_RESET_(); VerilatedVpio* vop = VerilatedVpio::castp(object); if (VL_UNLIKELY(!vop)) return nullptr; return vop->dovpi_scan(); @@ -1407,7 +1407,7 @@ PLI_INT32 vpi_get(PLI_INT32 property, vpiHandle object) { // Leave this in the header file - in many cases the compiler can constant propagate "object" VL_DEBUG_IF_PLI(VL_DBG_MSGF("- vpi: vpi_get %d %p\n", property, object);); VerilatedVpiImp::assertOneCheck(); - _VL_VPI_ERROR_RESET(); + VL_VPI_ERROR_RESET_(); switch (property) { case vpiTimePrecision: { return Verilated::timeprecision(); @@ -1440,14 +1440,14 @@ PLI_INT32 vpi_get(PLI_INT32 property, vpiHandle object) { return vop->size(); } default: - _VL_VPI_WARNING(__FILE__, __LINE__, "%s: Unsupported type %s, nothing will be returned", + VL_VPI_WARNING_(__FILE__, __LINE__, "%s: Unsupported type %s, nothing will be returned", VL_FUNC, VerilatedVpiError::strFromVpiProp(property)); return 0; } } PLI_INT64 vpi_get64(PLI_INT32 /*property*/, vpiHandle /*object*/) { - _VL_VPI_UNIMP(); + VL_VPI_UNIMP_(); return 0; } @@ -1455,7 +1455,7 @@ PLI_BYTE8* vpi_get_str(PLI_INT32 property, vpiHandle object) { VL_DEBUG_IF_PLI(VL_DBG_MSGF("- vpi: vpi_get_str %d %p\n", property, object);); VerilatedVpiImp::assertOneCheck(); VerilatedVpio* vop = VerilatedVpio::castp(object); - _VL_VPI_ERROR_RESET(); + VL_VPI_ERROR_RESET_(); if (VL_UNLIKELY(!vop)) return nullptr; switch (property) { case vpiName: { @@ -1471,7 +1471,7 @@ PLI_BYTE8* vpi_get_str(PLI_INT32 property, vpiHandle object) { return const_cast(VerilatedVpiError::strFromVpiObjType(vop->type())); } default: - _VL_VPI_WARNING(__FILE__, __LINE__, "%s: Unsupported type %s, nothing will be returned", + VL_VPI_WARNING_(__FILE__, __LINE__, "%s: Unsupported type %s, nothing will be returned", VL_FUNC, VerilatedVpiError::strFromVpiProp(property)); return nullptr; } @@ -1479,8 +1479,8 @@ PLI_BYTE8* vpi_get_str(PLI_INT32 property, vpiHandle object) { // delay processing -void vpi_get_delays(vpiHandle /*object*/, p_vpi_delay /*delay_p*/) { _VL_VPI_UNIMP(); } -void vpi_put_delays(vpiHandle /*object*/, p_vpi_delay /*delay_p*/) { _VL_VPI_UNIMP(); } +void vpi_get_delays(vpiHandle /*object*/, p_vpi_delay /*delay_p*/) { VL_VPI_UNIMP_(); } +void vpi_put_delays(vpiHandle /*object*/, p_vpi_delay /*delay_p*/) { VL_VPI_UNIMP_(); } // value processing bool vl_check_format(const VerilatedVar* varp, const p_vpi_value valuep, const char* fullname, @@ -1532,7 +1532,7 @@ bool vl_check_format(const VerilatedVar* varp, const p_vpi_value valuep, const c } else { status = false; } - _VL_VPI_ERROR(__FILE__, __LINE__, "%s: Unsupported format (%s) for %s", VL_FUNC, + VL_VPI_ERROR_(__FILE__, __LINE__, "%s: Unsupported format (%s) for %s", VL_FUNC, VerilatedVpiError::strFromVpiVal(valuep->format), fullname); return status; } @@ -1592,7 +1592,7 @@ void vl_get_value(const VerilatedVar* varp, void* varDatap, p_vpi_value valuep, if (bits > t_outStrSz) { // limit maximum size of output to size of buffer to prevent overrun. bits = t_outStrSz; - _VL_VPI_WARNING( + VL_VPI_WARNING_( __FILE__, __LINE__, "%s: Truncating string value of %s for %s" " as buffer size (%d, VL_MULS_MAX_WORDS=%d) is less than required (%d)", @@ -1613,7 +1613,7 @@ void vl_get_value(const VerilatedVar* varp, void* varDatap, p_vpi_value valuep, int i; if (chars > t_outStrSz) { // limit maximum size of output to size of buffer to prevent overrun. - _VL_VPI_WARNING( + VL_VPI_WARNING_( __FILE__, __LINE__, "%s: Truncating string value of %s for %s" " as buffer size (%d, VL_MULS_MAX_WORDS=%d) is less than required (%d)", @@ -1671,7 +1671,7 @@ void vl_get_value(const VerilatedVar* varp, void* varDatap, p_vpi_value valuep, int i; if (chars > t_outStrSz) { // limit maximum size of output to size of buffer to prevent overrun. - _VL_VPI_WARNING( + VL_VPI_WARNING_( __FILE__, __LINE__, "%s: Truncating string value of %s for %s" " as buffer size (%d, VL_MULS_MAX_WORDS=%d) is less than required (%d)", @@ -1705,7 +1705,7 @@ void vl_get_value(const VerilatedVar* varp, void* varDatap, p_vpi_value valuep, int i; if (bytes > t_outStrSz) { // limit maximum size of output to size of buffer to prevent overrun. - _VL_VPI_WARNING( + VL_VPI_WARNING_( __FILE__, __LINE__, "%s: Truncating string value of %s for %s" " as buffer size (%d, VL_MULS_MAX_WORDS=%d) is less than required (%d)", @@ -1735,14 +1735,14 @@ void vl_get_value(const VerilatedVar* varp, void* varDatap, p_vpi_value valuep, } else if (valuep->format == vpiSuppressVal) { return; } - _VL_VPI_ERROR(__FILE__, __LINE__, "%s: Unsupported format (%s) as requested for %s", VL_FUNC, + VL_VPI_ERROR_(__FILE__, __LINE__, "%s: Unsupported format (%s) as requested for %s", VL_FUNC, VerilatedVpiError::strFromVpiVal(valuep->format), fullname); } void vpi_get_value(vpiHandle object, p_vpi_value valuep) { VL_DEBUG_IF_PLI(VL_DBG_MSGF("- vpi: vpi_get_value %p\n", object);); VerilatedVpiImp::assertOneCheck(); - _VL_VPI_ERROR_RESET(); + VL_VPI_ERROR_RESET_(); if (VL_UNLIKELY(!valuep)) return; if (VerilatedVpioVar* vop = VerilatedVpioVar::castp(object)) { @@ -1756,20 +1756,20 @@ void vpi_get_value(vpiHandle object, p_vpi_value valuep) { valuep->value.integer = vop->num(); return; } - _VL_VPI_ERROR(__FILE__, __LINE__, "%s: Unsupported format (%s) for %s", VL_FUNC, + VL_VPI_ERROR_(__FILE__, __LINE__, "%s: Unsupported format (%s) for %s", VL_FUNC, VerilatedVpiError::strFromVpiVal(valuep->format), vop->fullname()); return; } - _VL_VPI_ERROR(__FILE__, __LINE__, "%s: Unsupported vpiHandle (%p)", VL_FUNC, object); + VL_VPI_ERROR_(__FILE__, __LINE__, "%s: Unsupported vpiHandle (%p)", VL_FUNC, object); } vpiHandle vpi_put_value(vpiHandle object, p_vpi_value valuep, p_vpi_time /*time_p*/, PLI_INT32 /*flags*/) { VL_DEBUG_IF_PLI(VL_DBG_MSGF("- vpi: vpi_put_value %p %p\n", object, valuep);); VerilatedVpiImp::assertOneCheck(); - _VL_VPI_ERROR_RESET(); + VL_VPI_ERROR_RESET_(); if (VL_UNLIKELY(!valuep)) { - _VL_VPI_WARNING(__FILE__, __LINE__, "Ignoring vpi_put_value with nullptr value pointer"); + VL_VPI_WARNING_(__FILE__, __LINE__, "Ignoring vpi_put_value with nullptr value pointer"); return nullptr; } if (VerilatedVpioVar* vop = VerilatedVpioVar::castp(object)) { @@ -1779,7 +1779,7 @@ vpiHandle vpi_put_value(vpiHandle object, p_vpi_value valuep, p_vpi_time /*time_ VL_DBG_MSGF("- vpi: varp=%p putatp=%p\n", vop->varp()->datap(), vop->varDatap());); if (VL_UNLIKELY(!vop->varp()->isPublicRW())) { - _VL_VPI_WARNING(__FILE__, __LINE__, + VL_VPI_WARNING_(__FILE__, __LINE__, "Ignoring vpi_put_value to signal marked read-only," " use public_flat_rw instead: %s", vop->fullname()); @@ -1801,7 +1801,7 @@ vpiHandle vpi_put_value(vpiHandle object, p_vpi_value valuep, p_vpi_time /*time_ = valuep->value.vector[0].aval & vop->mask(); return object; } else if (vop->varp()->vltype() == VLVT_UINT64) { - *(reinterpret_cast(vop->varDatap())) = _VL_SET_QII( + *(reinterpret_cast(vop->varDatap())) = VL_SET_QII( valuep->value.vector[1].aval & vop->mask(), valuep->value.vector[0].aval); return object; } else if (vop->varp()->vltype() == VLVT_WDATA) { @@ -1847,7 +1847,7 @@ vpiHandle vpi_put_value(vpiHandle object, p_vpi_value valuep, p_vpi_time /*time_ if (digit >= '0' && digit <= '7') { val.half = digit - '0'; } else { - _VL_VPI_WARNING(__FILE__, __LINE__, + VL_VPI_WARNING_(__FILE__, __LINE__, "%s: Non octal character '%c' in '%s' as value %s for %s", VL_FUNC, digit, valuep->value.str, VerilatedVpiError::strFromVpiVal(valuep->format), @@ -1883,13 +1883,13 @@ vpiHandle vpi_put_value(vpiHandle object, p_vpi_value valuep, p_vpi_time /*time_ unsigned long long val; int success = 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_VPI_ERROR_(__FILE__, __LINE__, "%s: Parsing failed for '%s' as value %s for %s", VL_FUNC, valuep->value.str, VerilatedVpiError::strFromVpiVal(valuep->format), vop->fullname()); return nullptr; } if (success > 1) { - _VL_VPI_WARNING(__FILE__, __LINE__, + VL_VPI_WARNING_(__FILE__, __LINE__, "%s: Trailing garbage '%s' in '%s' as value %s for %s", VL_FUNC, remainder, valuep->value.str, VerilatedVpiError::strFromVpiVal(valuep->format), vop->fullname()); @@ -1927,7 +1927,7 @@ vpiHandle vpi_put_value(vpiHandle object, p_vpi_value valuep, p_vpi_time /*time_ } else if (digit >= 'A' && digit <= 'F') { hex = digit - 'A' + 10; } else { - _VL_VPI_WARNING(__FILE__, __LINE__, + VL_VPI_WARNING_(__FILE__, __LINE__, "%s: Non hex character '%c' in '%s' as value %s for %s", VL_FUNC, digit, valuep->value.str, VerilatedVpiError::strFromVpiVal(valuep->format), @@ -1969,39 +1969,39 @@ vpiHandle vpi_put_value(vpiHandle object, p_vpi_value valuep, p_vpi_time /*time_ return object; } } - _VL_VPI_ERROR(__FILE__, __LINE__, "%s: Unsupported format (%s) as requested for %s", + VL_VPI_ERROR_(__FILE__, __LINE__, "%s: Unsupported format (%s) as requested for %s", VL_FUNC, VerilatedVpiError::strFromVpiVal(valuep->format), vop->fullname()); return nullptr; } else if (VerilatedVpioParam* vop = VerilatedVpioParam::castp(object)) { - _VL_VPI_WARNING(__FILE__, __LINE__, "%s: Ignoring vpi_put_value to vpiParameter: %s", + VL_VPI_WARNING_(__FILE__, __LINE__, "%s: Ignoring vpi_put_value to vpiParameter: %s", VL_FUNC, vop->fullname()); return nullptr; } else if (VerilatedVpioConst* vop = VerilatedVpioConst::castp(object)) { - _VL_VPI_WARNING(__FILE__, __LINE__, "%s: Ignoring vpi_put_value to vpiConstant: %s", + VL_VPI_WARNING_(__FILE__, __LINE__, "%s: Ignoring vpi_put_value to vpiConstant: %s", VL_FUNC, vop->fullname()); return nullptr; } - _VL_VPI_ERROR(__FILE__, __LINE__, "%s: Unsupported vpiHandle (%p)", VL_FUNC, object); + VL_VPI_ERROR_(__FILE__, __LINE__, "%s: Unsupported vpiHandle (%p)", VL_FUNC, object); return nullptr; } void vpi_get_value_array(vpiHandle /*object*/, p_vpi_arrayvalue /*arrayvalue_p*/, PLI_INT32* /*index_p*/, PLI_UINT32 /*num*/) { - _VL_VPI_UNIMP(); + VL_VPI_UNIMP_(); } void vpi_put_value_array(vpiHandle /*object*/, p_vpi_arrayvalue /*arrayvalue_p*/, PLI_INT32* /*index_p*/, PLI_UINT32 /*num*/) { - _VL_VPI_UNIMP(); + VL_VPI_UNIMP_(); } // time processing void vpi_get_time(vpiHandle object, p_vpi_time time_p) { VerilatedVpiImp::assertOneCheck(); - _VL_VPI_ERROR_RESET(); + VL_VPI_ERROR_RESET_(); // cppcheck-suppress nullPointer if (VL_UNLIKELY(!time_p)) { - _VL_VPI_WARNING(__FILE__, __LINE__, "Ignoring vpi_get_time with nullptr value pointer"); + VL_VPI_WARNING_(__FILE__, __LINE__, "Ignoring vpi_get_time with nullptr value pointer"); return; } if (time_p->type == vpiSimTime) { @@ -2021,32 +2021,32 @@ void vpi_get_time(vpiHandle object, p_vpi_time time_p) { time_p->real = dtime; return; } - _VL_VPI_ERROR(__FILE__, __LINE__, "%s: Unsupported type (%d)", VL_FUNC, time_p->type); + VL_VPI_ERROR_(__FILE__, __LINE__, "%s: Unsupported type (%d)", VL_FUNC, time_p->type); } // I/O routines PLI_UINT32 vpi_mcd_open(PLI_BYTE8* filenamep) { VerilatedVpiImp::assertOneCheck(); - _VL_VPI_ERROR_RESET(); + VL_VPI_ERROR_RESET_(); return VL_FOPEN_NN(filenamep, "wb"); } PLI_UINT32 vpi_mcd_close(PLI_UINT32 mcd) { VerilatedVpiImp::assertOneCheck(); - _VL_VPI_ERROR_RESET(); + VL_VPI_ERROR_RESET_(); VL_FCLOSE_I(mcd); return 0; } PLI_BYTE8* vpi_mcd_name(PLI_UINT32 /*mcd*/) { - _VL_VPI_UNIMP(); + VL_VPI_UNIMP_(); return nullptr; } PLI_INT32 vpi_mcd_printf(PLI_UINT32 mcd, PLI_BYTE8* formatp, ...) { VerilatedVpiImp::assertOneCheck(); - _VL_VPI_ERROR_RESET(); + VL_VPI_ERROR_RESET_(); va_list ap; va_start(ap, formatp); int chars = vpi_mcd_vprintf(mcd, formatp, ap); @@ -2056,7 +2056,7 @@ PLI_INT32 vpi_mcd_printf(PLI_UINT32 mcd, PLI_BYTE8* formatp, ...) { PLI_INT32 vpi_printf(PLI_BYTE8* formatp, ...) { VerilatedVpiImp::assertOneCheck(); - _VL_VPI_ERROR_RESET(); + VL_VPI_ERROR_RESET_(); va_list ap; va_start(ap, formatp); int chars = vpi_vprintf(formatp, ap); @@ -2066,14 +2066,14 @@ PLI_INT32 vpi_printf(PLI_BYTE8* formatp, ...) { PLI_INT32 vpi_vprintf(PLI_BYTE8* formatp, va_list ap) { VerilatedVpiImp::assertOneCheck(); - _VL_VPI_ERROR_RESET(); + VL_VPI_ERROR_RESET_(); return VL_VPRINTF(formatp, ap); } PLI_INT32 vpi_mcd_vprintf(PLI_UINT32 mcd, PLI_BYTE8* format, va_list ap) { VerilatedVpiImp::assertOneCheck(); FILE* fp = VL_CVT_I_FP(mcd); - _VL_VPI_ERROR_RESET(); + VL_VPI_ERROR_RESET_(); // cppcheck-suppress nullPointer if (VL_UNLIKELY(!fp)) return 0; int chars = vfprintf(fp, format, ap); @@ -2082,7 +2082,7 @@ PLI_INT32 vpi_mcd_vprintf(PLI_UINT32 mcd, PLI_BYTE8* format, va_list ap) { PLI_INT32 vpi_flush(void) { VerilatedVpiImp::assertOneCheck(); - _VL_VPI_ERROR_RESET(); + VL_VPI_ERROR_RESET_(); Verilated::runFlushCallbacks(); return 0; } @@ -2090,7 +2090,7 @@ PLI_INT32 vpi_flush(void) { PLI_INT32 vpi_mcd_flush(PLI_UINT32 mcd) { VerilatedVpiImp::assertOneCheck(); FILE* fp = VL_CVT_I_FP(mcd); - _VL_VPI_ERROR_RESET(); + VL_VPI_ERROR_RESET_(); if (VL_UNLIKELY(!fp)) return 1; fflush(fp); return 0; @@ -2099,7 +2099,7 @@ PLI_INT32 vpi_mcd_flush(PLI_UINT32 mcd) { // utility routines PLI_INT32 vpi_compare_objects(vpiHandle /*object1*/, vpiHandle /*object2*/) { - _VL_VPI_UNIMP(); + VL_VPI_UNIMP_(); return 0; } PLI_INT32 vpi_chk_error(p_vpi_error_info error_info_p) { @@ -2123,7 +2123,7 @@ PLI_INT32 vpi_release_handle(vpiHandle object) { VL_DEBUG_IF_PLI(VL_DBG_MSGF("- vpi: vpi_release_handle %p\n", object);); VerilatedVpiImp::assertOneCheck(); VerilatedVpio* vop = VerilatedVpio::castp(object); - _VL_VPI_ERROR_RESET(); + VL_VPI_ERROR_RESET_(); if (VL_UNLIKELY(!vop)) return 0; VL_DO_DANGLING(delete vop, vop); return 1; @@ -2131,7 +2131,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(); + VL_VPI_ERROR_RESET_(); vlog_info_p->argc = Verilated::getCommandArgs()->argc; vlog_info_p->argv = const_cast(Verilated::getCommandArgs()->argv); vlog_info_p->product = const_cast(Verilated::productName()); @@ -2142,26 +2142,26 @@ PLI_INT32 vpi_get_vlog_info(p_vpi_vlog_info vlog_info_p) VL_MT_SAFE { // routines added with 1364-2001 PLI_INT32 vpi_get_data(PLI_INT32 /*id*/, PLI_BYTE8* /*dataLoc*/, PLI_INT32 /*numOfBytes*/) { - _VL_VPI_UNIMP(); + VL_VPI_UNIMP_(); return 0; } PLI_INT32 vpi_put_data(PLI_INT32 /*id*/, PLI_BYTE8* /*dataLoc*/, PLI_INT32 /*numOfBytes*/) { - _VL_VPI_UNIMP(); + VL_VPI_UNIMP_(); return 0; } void* vpi_get_userdata(vpiHandle /*obj*/) { - _VL_VPI_UNIMP(); + VL_VPI_UNIMP_(); return nullptr; } PLI_INT32 vpi_put_userdata(vpiHandle /*obj*/, void* /*userdata*/) { - _VL_VPI_UNIMP(); + VL_VPI_UNIMP_(); return 0; } PLI_INT32 vpi_control(PLI_INT32 operation, ...) { VL_DEBUG_IF_PLI(VL_DBG_MSGF("- vpi: vpi_control %d\n", operation);); VerilatedVpiImp::assertOneCheck(); - _VL_VPI_ERROR_RESET(); + VL_VPI_ERROR_RESET_(); switch (operation) { case vpiFinish: { VL_FINISH_MT("", 0, "*VPI*"); @@ -2172,7 +2172,7 @@ PLI_INT32 vpi_control(PLI_INT32 operation, ...) { return 1; // LCOV_EXCL_LINE } default: { - _VL_VPI_WARNING(__FILE__, __LINE__, "%s: Unsupported type %s, ignoring", VL_FUNC, + VL_VPI_WARNING_(__FILE__, __LINE__, "%s: Unsupported type %s, ignoring", VL_FUNC, VerilatedVpiError::strFromVpiProp(operation)); return 0; } @@ -2181,6 +2181,6 @@ PLI_INT32 vpi_control(PLI_INT32 operation, ...) { vpiHandle vpi_handle_by_multi_index(vpiHandle /*obj*/, PLI_INT32 /*num_index*/, PLI_INT32* /*index_array*/) { - _VL_VPI_UNIMP(); + VL_VPI_UNIMP_(); return nullptr; } diff --git a/src/V3EmitCSyms.cpp b/src/V3EmitCSyms.cpp index d9c0882b0..f5554b8f9 100644 --- a/src/V3EmitCSyms.cpp +++ b/src/V3EmitCSyms.cpp @@ -922,8 +922,9 @@ void EmitCSyms::emitDpiImp() { for (AstCFunc* nodep : m_dpis) { if (nodep->dpiExportWrapper()) { - puts("#ifndef _VL_DPIDECL_" + nodep->name() + "\n"); - puts("#define _VL_DPIDECL_" + nodep->name() + "\n"); + // Prevent multi-definition if used by multiple models + puts("#ifndef VL_DPIDECL_" + nodep->name() + "_\n"); + puts("#define VL_DPIDECL_" + nodep->name() + "_\n"); puts(nodep->rtnTypeVoid() + " " + nodep->name() + "(" + cFuncArgs(nodep) + ") {\n"); puts("// DPI export" + ifNoProtect(" at " + nodep->fileline()->ascii()) + "\n"); puts("return " + topClassName() + "::" + nodep->name() + "("); diff --git a/src/V3Error.cpp b/src/V3Error.cpp index 95a34a7f0..b8c0e6484 100644 --- a/src/V3Error.cpp +++ b/src/V3Error.cpp @@ -16,7 +16,7 @@ // clang-format off #include "V3Error.h" -#ifndef _V3ERROR_NO_GLOBAL_ +#ifndef V3ERROR_NO_GLOBAL_ # include "V3Ast.h" # include "V3Global.h" # include "V3Stats.h" @@ -174,7 +174,7 @@ void V3Error::vlAbort() { // Global Functions void V3Error::suppressThisWarning() { -#ifndef _V3ERROR_NO_GLOBAL_ +#ifndef V3ERROR_NO_GLOBAL_ V3Stats::addStatSum(string("Warnings, Suppressed ") + s_errorCode.ascii(), 1); #endif s_errorSuppressed = true; @@ -215,7 +215,7 @@ void V3Error::v3errorEnd(std::ostringstream& sstr, const string& locationStr) { } // Output if ( -#ifndef _V3ERROR_NO_GLOBAL_ +#ifndef V3ERROR_NO_GLOBAL_ !(v3Global.opt.quietExit() && s_errorCode == V3ErrorCode::EC_FATALEXIT) #else true @@ -265,7 +265,7 @@ void V3Error::v3errorEnd(std::ostringstream& sstr, const string& locationStr) { << endl; s_tellManual = 2; } -#ifndef _V3ERROR_NO_GLOBAL_ +#ifndef V3ERROR_NO_GLOBAL_ if (debug()) { v3Global.rootp()->dumpTreeFile(v3Global.debugFilename("final.tree", 990)); if (s_errorExitCb) s_errorExitCb(); diff --git a/src/V3FileLine.cpp b/src/V3FileLine.cpp index 272277948..5fae3ce6a 100644 --- a/src/V3FileLine.cpp +++ b/src/V3FileLine.cpp @@ -21,7 +21,7 @@ #include "V3Error.h" #include "V3FileLine.h" #include "V3String.h" -#ifndef _V3ERROR_NO_GLOBAL_ +#ifndef V3ERROR_NO_GLOBAL_ # include "V3Global.h" # include "V3Config.h" # include "V3File.h" @@ -240,7 +240,7 @@ FileLine* FileLine::copyOrSameFileLine() { // Return this, or a copy of this // There are often more than one token per line, thus we use the // same pointer as long as we're on the same line, file & warn state. -#ifndef _V3ERROR_NO_GLOBAL_ +#ifndef V3ERROR_NO_GLOBAL_ V3Config::applyIgnores(this); // Toggle warnings based on global config file #endif static FileLine* lastNewp = nullptr; diff --git a/src/V3Number_test.cpp b/src/V3Number_test.cpp index 07ba971e8..1e3b142f0 100644 --- a/src/V3Number_test.cpp +++ b/src/V3Number_test.cpp @@ -16,7 +16,7 @@ // CHEAT! #define V3NUMBER_ASCII_BINARY -#define _V3ERROR_NO_GLOBAL_ 1 +#define V3ERROR_NO_GLOBAL_ #include #include "verilatedos.h" diff --git a/src/VlcMain.cpp b/src/VlcMain.cpp index 45be06f0c..3df97d3cb 100644 --- a/src/VlcMain.cpp +++ b/src/VlcMain.cpp @@ -24,7 +24,7 @@ #include "verilatedos.h" // Cheat for speed and compile .cpp files into one object -#define _V3ERROR_NO_GLOBAL_ 1 +#define V3ERROR_NO_GLOBAL_ #include "V3Error.cpp" #include "V3String.cpp" #include "V3Os.cpp"