From 04ac61a197ea5b5d94e7d34d6222e94a6d36daba Mon Sep 17 00:00:00 2001 From: Matthew Ballance Date: Tue, 9 Jun 2026 01:51:29 +0000 Subject: [PATCH] rename enumerators to avoid win32 compilation error Signed-off-by: Matthew Ballance --- include/verilated_cov_model.h | 10 ++++++---- include/verilated_covergroup.cpp | 10 +++++----- include/verilated_covergroup.h | 2 +- src/V3AstAttr.h | 8 ++++---- 4 files changed, 16 insertions(+), 14 deletions(-) diff --git a/include/verilated_cov_model.h b/include/verilated_cov_model.h index 89d936fe6..519fd214c 100644 --- a/include/verilated_cov_model.h +++ b/include/verilated_cov_model.h @@ -30,11 +30,13 @@ // Per-bin classification. A bin's kind is which set it lives in (structural), // not a per-bin field. Only Normal feeds coverage(); the rest are recorded. +// Enumerators are 'KIND_'-prefixed because the bare LRM terms collide with +// macros (e.g. IGNORE), which the preprocessor would expand. enum class VlCovBinKind : uint8_t { - NORMAL = 0, // Base coverage-collecting bin - DEFAULT = 1, // Bin declared with 'default' range (which is excluded per LRM) - IGNORE = 2, // Ignore bin - ILLEGAL = 3 // Illegal bin + KIND_NORMAL = 0, // Base coverage-collecting bin + KIND_DEFAULT = 1, // Bin declared with 'default' range (which is excluded per LRM) + KIND_IGNORE = 2, // Ignore bin + KIND_ILLEGAL = 3 // Illegal bin }; //============================================================================= diff --git a/include/verilated_covergroup.cpp b/include/verilated_covergroup.cpp index 89671831b..6dc7006f1 100644 --- a/include/verilated_covergroup.cpp +++ b/include/verilated_covergroup.cpp @@ -35,7 +35,7 @@ void VlCoverpoint::addNamer(VlCovBinKind set, int count, VlCovBinNaming naming, const char* file, int line, int col) { m_namers.emplace_back(set, count, m_nextBase, naming, name, file, line, col); m_nextBase += count; - if (set == VlCovBinKind::NORMAL) m_normal += count; + if (set == VlCovBinKind::KIND_NORMAL) m_normal += count; } const VlCovNamer& VlCoverpoint::namerFor(int i) const { @@ -62,14 +62,14 @@ void VlCoverpoint::registerBins(VerilatedCovContext* covcontextp, const char* pa const std::string full = m_hier + "." + binp; const std::string lineStr = std::to_string(nm.line()); const std::string colStr = std::to_string(nm.col()); - if (kind == VlCovBinKind::NORMAL) { + if (kind == VlCovBinKind::KIND_NORMAL) { VL_COVER_INSERT(covcontextp, full.c_str(), &m_counts[i], "page", page, "filename", nm.file(), "lineno", lineStr.c_str(), "column", colStr.c_str(), "bin", binp.c_str()); } else { - const char* const binType = kind == VlCovBinKind::IGNORE ? "ignore" - : kind == VlCovBinKind::ILLEGAL ? "illegal" - : "default"; + const char* const binType = kind == VlCovBinKind::KIND_IGNORE ? "ignore" + : kind == VlCovBinKind::KIND_ILLEGAL ? "illegal" + : "default"; VL_COVER_INSERT(covcontextp, full.c_str(), &m_counts[i], "page", page, "filename", nm.file(), "lineno", lineStr.c_str(), "column", colStr.c_str(), "bin", binp.c_str(), "bin_type", binType); diff --git a/include/verilated_covergroup.h b/include/verilated_covergroup.h index 85b680e3d..1ffc98ff7 100644 --- a/include/verilated_covergroup.h +++ b/include/verilated_covergroup.h @@ -131,7 +131,7 @@ public: // path (incrementBin) stays a plain counter bump. int numCovered = 0; for (const VlCovNamer& nm : m_namers) { - if (nm.set() != VlCovBinKind::NORMAL) continue; + if (nm.set() != VlCovBinKind::KIND_NORMAL) continue; for (int i = nm.base(); i < nm.base() + nm.count(); ++i) { if (m_counts[i] >= m_atLeast) ++numCovered; } diff --git a/src/V3AstAttr.h b/src/V3AstAttr.h index 6e4851991..dd1754a9d 100644 --- a/src/V3AstAttr.h +++ b/src/V3AstAttr.h @@ -1194,10 +1194,10 @@ public: // VlCovBinKind enumerator naming the bin's set const char* binSetEnum() const { switch (m_e) { - case BINS_IGNORE: return "VlCovBinKind::IGNORE"; - case BINS_ILLEGAL: return "VlCovBinKind::ILLEGAL"; - case BINS_DEFAULT: return "VlCovBinKind::DEFAULT"; - default: return "VlCovBinKind::NORMAL"; + case BINS_IGNORE: return "VlCovBinKind::KIND_IGNORE"; + case BINS_ILLEGAL: return "VlCovBinKind::KIND_ILLEGAL"; + case BINS_DEFAULT: return "VlCovBinKind::KIND_DEFAULT"; + default: return "VlCovBinKind::KIND_NORMAL"; } } // Normal bins (feed coverage) are anything but ignore/illegal/default