From dced49a804a0f3c2a68a2851c16fc5f6328c28d9 Mon Sep 17 00:00:00 2001 From: Wilson Snyder Date: Fri, 10 Jul 2020 19:17:21 -0400 Subject: [PATCH] Internals: Cleanup branch coverage. No functional change. --- include/verilated_cov.cpp | 21 ++++++++------- include/verilated_save.cpp | 4 +-- include/verilated_vpi.cpp | 52 +++++++++++++++++++------------------- nodist/code_coverage.dat | 3 ++- 4 files changed, 40 insertions(+), 40 deletions(-) diff --git a/include/verilated_cov.cpp b/include/verilated_cov.cpp index d09aed228..65459998d 100644 --- a/include/verilated_cov.cpp +++ b/include/verilated_cov.cpp @@ -220,20 +220,19 @@ private: } static void selftest() VL_MT_SAFE { // Little selftest -#define VL_CST_CHECK(got, exp) \ +#define SELF_CHECK(got, exp) \ do { \ if ((got) != (exp)) VL_FATAL_MT(__FILE__, __LINE__, "", "%Error: selftest\n"); \ } while (0) - - VL_CST_CHECK(combineHier("a.b.c", "a.b.c"), "a.b.c"); - VL_CST_CHECK(combineHier("a.b.c", "a.b"), "a.b*"); - VL_CST_CHECK(combineHier("a.x.c", "a.y.c"), "a.*.c"); - VL_CST_CHECK(combineHier("a.z.z.z.c", "a.b.c"), "a.*.c"); - VL_CST_CHECK(combineHier("z", "a"), "*"); - VL_CST_CHECK(combineHier("q.a", "q.b"), "q.*"); - VL_CST_CHECK(combineHier("q.za", "q.zb"), "q.z*"); - VL_CST_CHECK(combineHier("1.2.3.a", "9.8.7.a"), "*.a"); -#undef VL_CST_CHECK + SELF_CHECK(combineHier("a.b.c", "a.b.c"), "a.b.c"); + SELF_CHECK(combineHier("a.b.c", "a.b"), "a.b*"); + SELF_CHECK(combineHier("a.x.c", "a.y.c"), "a.*.c"); + SELF_CHECK(combineHier("a.z.z.z.c", "a.b.c"), "a.*.c"); + SELF_CHECK(combineHier("z", "a"), "*"); + SELF_CHECK(combineHier("q.a", "q.b"), "q.*"); + SELF_CHECK(combineHier("q.za", "q.zb"), "q.z*"); + SELF_CHECK(combineHier("1.2.3.a", "9.8.7.a"), "*.a"); +#undef SELF_CHECK } void clearGuts() VL_REQUIRES(m_mutex) { for (ItemList::const_iterator it = m_items.begin(); it != m_items.end(); ++it) { diff --git a/include/verilated_save.cpp b/include/verilated_save.cpp index 0972f513f..e571e9cf8 100644 --- a/include/verilated_save.cpp +++ b/include/verilated_save.cpp @@ -129,7 +129,7 @@ void VerilatedSave::open(const char* filenamep) VL_MT_UNSAFE_ONE { // cppcheck-suppress duplicateExpression m_fd = ::open(filenamep, O_CREAT | O_WRONLY | O_TRUNC | O_LARGEFILE | O_NONBLOCK | O_CLOEXEC, 0666); - if (m_fd < 0) { + if (VL_UNLIKELY(m_fd < 0)) { // User code can check isOpen() m_isOpen = false; return; @@ -151,7 +151,7 @@ void VerilatedRestore::open(const char* filenamep) VL_MT_UNSAFE_ONE { } else { // cppcheck-suppress duplicateExpression m_fd = ::open(filenamep, O_CREAT | O_RDONLY | O_LARGEFILE | O_CLOEXEC, 0666); - if (m_fd < 0) { + if (VL_UNLIKELY(m_fd < 0)) { // User code can check isOpen() m_isOpen = false; return; diff --git a/include/verilated_vpi.cpp b/include/verilated_vpi.cpp index c29ad80a9..e19c332e4 100644 --- a/include/verilated_vpi.cpp +++ b/include/verilated_vpi.cpp @@ -964,52 +964,52 @@ const char* VerilatedVpiError::strFromVpiProp(PLI_INT32 vpiVal) VL_MT_SAFE { return names[(vpiVal <= vpiIsProtected) ? vpiVal : 0]; } -#define CHECK_RESULT_CSTR(got, exp) \ +#define SELF_CHECK_RESULT_CSTR(got, exp) \ if (0 != strcmp((got), (exp))) { \ std::string msg \ = std::string("%Error: ") + "GOT = '" + got + "'" + " EXP = '" + exp + "'"; \ VL_FATAL_MT(__FILE__, __LINE__, "", msg.c_str()); \ } -#define CHECK_ENUM_STR(fn, enum) \ +#define SELF_CHECK_ENUM_STR(fn, enum) \ do { \ const char* strVal = VerilatedVpiError::fn(enum); \ - CHECK_RESULT_CSTR(strVal, #enum); \ + SELF_CHECK_RESULT_CSTR(strVal, #enum); \ } while (0) void VerilatedVpi::selfTest() VL_MT_UNSAFE_ONE { VerilatedVpiError::selfTest(); } void VerilatedVpiError::selfTest() VL_MT_UNSAFE_ONE { VerilatedVpiImp::assertOneCheck(); - CHECK_ENUM_STR(strFromVpiVal, vpiBinStrVal); - CHECK_ENUM_STR(strFromVpiVal, vpiRawFourStateVal); + SELF_CHECK_ENUM_STR(strFromVpiVal, vpiBinStrVal); + SELF_CHECK_ENUM_STR(strFromVpiVal, vpiRawFourStateVal); - CHECK_ENUM_STR(strFromVpiObjType, vpiAlways); - CHECK_ENUM_STR(strFromVpiObjType, vpiWhile); - CHECK_ENUM_STR(strFromVpiObjType, vpiAttribute); - CHECK_ENUM_STR(strFromVpiObjType, vpiUdpArray); - CHECK_ENUM_STR(strFromVpiObjType, vpiContAssignBit); - CHECK_ENUM_STR(strFromVpiObjType, vpiGenVar); + SELF_CHECK_ENUM_STR(strFromVpiObjType, vpiAlways); + SELF_CHECK_ENUM_STR(strFromVpiObjType, vpiWhile); + SELF_CHECK_ENUM_STR(strFromVpiObjType, vpiAttribute); + SELF_CHECK_ENUM_STR(strFromVpiObjType, vpiUdpArray); + SELF_CHECK_ENUM_STR(strFromVpiObjType, vpiContAssignBit); + SELF_CHECK_ENUM_STR(strFromVpiObjType, vpiGenVar); - CHECK_ENUM_STR(strFromVpiMethod, vpiCondition); - CHECK_ENUM_STR(strFromVpiMethod, vpiStmt); + SELF_CHECK_ENUM_STR(strFromVpiMethod, vpiCondition); + SELF_CHECK_ENUM_STR(strFromVpiMethod, vpiStmt); - CHECK_ENUM_STR(strFromVpiCallbackReason, cbValueChange); - CHECK_ENUM_STR(strFromVpiCallbackReason, cbAtEndOfSimTime); + SELF_CHECK_ENUM_STR(strFromVpiCallbackReason, cbValueChange); + SELF_CHECK_ENUM_STR(strFromVpiCallbackReason, cbAtEndOfSimTime); - CHECK_ENUM_STR(strFromVpiProp, vpiType); - CHECK_ENUM_STR(strFromVpiProp, vpiProtected); - CHECK_ENUM_STR(strFromVpiProp, vpiDirection); - CHECK_ENUM_STR(strFromVpiProp, vpiTermIndex); - CHECK_ENUM_STR(strFromVpiProp, vpiConstType); - CHECK_ENUM_STR(strFromVpiProp, vpiAutomatic); - CHECK_ENUM_STR(strFromVpiProp, vpiOffset); - CHECK_ENUM_STR(strFromVpiProp, vpiStop); - CHECK_ENUM_STR(strFromVpiProp, vpiIsProtected); + SELF_CHECK_ENUM_STR(strFromVpiProp, vpiType); + SELF_CHECK_ENUM_STR(strFromVpiProp, vpiProtected); + SELF_CHECK_ENUM_STR(strFromVpiProp, vpiDirection); + SELF_CHECK_ENUM_STR(strFromVpiProp, vpiTermIndex); + SELF_CHECK_ENUM_STR(strFromVpiProp, vpiConstType); + SELF_CHECK_ENUM_STR(strFromVpiProp, vpiAutomatic); + SELF_CHECK_ENUM_STR(strFromVpiProp, vpiOffset); + SELF_CHECK_ENUM_STR(strFromVpiProp, vpiStop); + SELF_CHECK_ENUM_STR(strFromVpiProp, vpiIsProtected); } -#undef CHECK_ENUM_STR -#undef CHECK_RESULT_CSTR +#undef SELF_CHECK_ENUM_STR +#undef SELF_CHECK_RESULT_CSTR //====================================================================== // callback related diff --git a/nodist/code_coverage.dat b/nodist/code_coverage.dat index df768a0ab..3e298fd4f 100644 --- a/nodist/code_coverage.dat +++ b/nodist/code_coverage.dat @@ -53,6 +53,7 @@ exclude_line_regexp(qr/(\bv3fatalSrc\b |\bUINFO\b)/x); # Exclude for branch coverage only -exclude_branch_regexp(qr/(\bdebug\(\))/x); +exclude_branch_regexp(qr/(\bdebug\(\) + |\bSELF_CHECK)/x); 1;