diff --git a/src/V3Global.h b/src/V3Global.h index 7b5c1aa18..e802ae289 100644 --- a/src/V3Global.h +++ b/src/V3Global.h @@ -130,6 +130,7 @@ class V3Global final { bool m_hasSystemCSections = false; // Has AstSystemCSection that need to be emitted bool m_useParallelBuild = false; // Use parallel build for model bool m_useRandSequence = false; // Has `randsequence` + bool m_useCovergroup = false; // Has covergroup declarations bool m_useRandomizeMethods = false; // Need to define randomize() class methods uint64_t m_currentHierBlockCost = 0; // Total cost of this hier block, used for scheduling @@ -213,6 +214,8 @@ public: void useParallelBuild(bool flag) { m_useParallelBuild = flag; } bool useRandSequence() const { return m_useRandSequence; } void useRandSequence(bool flag) { m_useRandSequence = flag; } + bool useCovergroup() const { return m_useCovergroup; } + void useCovergroup(bool flag) { m_useCovergroup = flag; } bool useRandomizeMethods() const { return m_useRandomizeMethods; } void useRandomizeMethods(bool flag) { m_useRandomizeMethods = flag; } void saveJsonPtrFieldName(const std::string& fieldName); diff --git a/src/Verilator.cpp b/src/Verilator.cpp index 54681e125..26eabfb9f 100644 --- a/src/Verilator.cpp +++ b/src/Verilator.cpp @@ -239,7 +239,7 @@ static void process() { // Functional coverage code generation // Generate code for covergroups/coverpoints - V3Covergroup::covergroup(v3Global.rootp()); + if (v3Global.useCovergroup()) V3Covergroup::covergroup(v3Global.rootp()); // Resolve randsequence if they are used by the design if (v3Global.useRandSequence()) V3RandSequence::randSequenceNetlist(v3Global.rootp()); diff --git a/src/verilog.y b/src/verilog.y index 480270a23..96364262f 100644 --- a/src/verilog.y +++ b/src/verilog.y @@ -6935,6 +6935,7 @@ covergroup_declaration: // ==IEEE: covergroup_declaration /*cont*/ yENDGROUP endLabelE { AstClass *cgClassp = new AstClass{$2, *$2, PARSEP->libname()}; cgClassp->isCovergroup(true); + v3Global.useCovergroup(true); AstNode* sampleArgs = nullptr;