diff --git a/Changes b/Changes index e2ad535ea..824cd3d65 100644 --- a/Changes +++ b/Changes @@ -6,6 +6,7 @@ indicates the contributor was also the author of the fix; Thanks! * Verilator 3.700*** ** Add --coverage_toggle for toggle coverage analysis. + Running coverage now requires SystemPerl 1.301 or newer. *** Add /*verilator coverage_on/_off */ to bracket coverage regions. diff --git a/src/V3AstNodes.h b/src/V3AstNodes.h index 7c76a0603..255f6a5bc 100644 --- a/src/V3AstNodes.h +++ b/src/V3AstNodes.h @@ -1011,15 +1011,15 @@ struct AstCoverDecl : public AstNodeStmt { // Children: none private: AstCoverDecl* m_dataDeclp; // [After V3CoverageJoin] Pointer to duplicate declaration to get data from instead - string m_typeText; + string m_page; string m_text; string m_hier; int m_column; int m_binNum; // Set by V3EmitCSyms to tell final V3Emit what to increment public: - AstCoverDecl(FileLine* fl, int column, const string& type, const string& comment) + AstCoverDecl(FileLine* fl, int column, const string& page, const string& comment) : AstNodeStmt(fl) { - m_text = comment; m_typeText = type; m_column = column; + m_text = comment; m_page = page; m_column = column; m_binNum = 0; m_dataDeclp = NULL; } @@ -1036,7 +1036,7 @@ public: void binNum(int flag) { m_binNum = flag; } int binNum() const { return m_binNum; } const string& comment() const { return m_text; } // text to insert in code - const string& typeText() const { return m_typeText; } + const string& page() const { return m_page; } const string& hier() const { return m_hier; } void hier(const string& flag) { m_hier=flag; } void comment(const string& flag) { m_text=flag; } diff --git a/src/V3Coverage.cpp b/src/V3Coverage.cpp index 6e267e8fa..d8060ea6c 100644 --- a/src/V3Coverage.cpp +++ b/src/V3Coverage.cpp @@ -74,7 +74,7 @@ private: } AstCoverInc* newCoverInc(FileLine* fl, const string& hier, - const string& type, const string& comment) { + const string& page_prefix, const string& comment) { int column = 0; FileMap::iterator it = m_fileps.find(fl); if (it == m_fileps.end()) { @@ -83,7 +83,11 @@ private: column = (it->second)++; } - AstCoverDecl* declp = new AstCoverDecl(fl, column, type, comment); + // We add the module name to the page. + // Someday the user might be allowed to specify a different page suffix + string page = page_prefix + "/" + m_modp->prettyName(); + + AstCoverDecl* declp = new AstCoverDecl(fl, column, page, comment); declp->hier(hier); m_modp->addStmtp(declp); @@ -207,7 +211,7 @@ private: if (!nodep->backp()->castIf() || nodep->backp()->castIf()->elsesp()!=nodep) { // Ignore if else; did earlier UINFO(4," COVER: "<addIfsp(newCoverInc(nodep->fileline(), "", "block", "if")); + nodep->addIfsp(newCoverInc(nodep->fileline(), "", "v_line", "if")); } } // Don't do empty else's, only empty if/case's @@ -218,9 +222,9 @@ private: && nodep->fileline()->coverageOn() && v3Global.opt.coverageLine()) { // if a "else" branch didn't disable it UINFO(4," COVER: "<elsesp()->castIf()) { - nodep->addElsesp(newCoverInc(nodep->elsesp()->fileline(), "", "block", "elsif")); + nodep->addElsesp(newCoverInc(nodep->elsesp()->fileline(), "", "v_line", "elsif")); } else { - nodep->addElsesp(newCoverInc(nodep->elsesp()->fileline(), "", "block", "else")); + nodep->addElsesp(newCoverInc(nodep->elsesp()->fileline(), "", "v_line", "else")); } } } @@ -234,7 +238,7 @@ private: nodep->bodysp()->iterateAndNext(*this); if (m_checkBlock) { // if the case body didn't disable it UINFO(4," COVER: "<addBodysp(newCoverInc(nodep->fileline(), "", "block", "case")); + nodep->addBodysp(newCoverInc(nodep->fileline(), "", "v_line", "case")); } m_checkBlock = true; // Reset as a child may have cleared it } @@ -245,7 +249,7 @@ private: nodep->iterateChildren(*this); if (!nodep->coverincp()) { // Note the name may be overridden by V3Assert processing - nodep->coverincp(newCoverInc(nodep->fileline(), m_beginHier, "psl_cover", "cover")); + nodep->coverincp(newCoverInc(nodep->fileline(), m_beginHier, "v_user", "cover")); } m_checkBlock = true; // Reset as a child may have cleared it } diff --git a/src/V3EmitC.cpp b/src/V3EmitC.cpp index 769df58cc..a4cf390c6 100644 --- a/src/V3EmitC.cpp +++ b/src/V3EmitC.cpp @@ -202,7 +202,7 @@ public: puts(", "); puts(cvtToStr(nodep->fileline()->lineno())); puts(", "); puts(cvtToStr(nodep->column())); puts(", \""); puts((nodep->hier()!=""?".":"")+nodep->hier()); puts("\""); - puts(", \""); puts(nodep->typeText()); puts("\""); + puts(", \""); puts(nodep->page()); puts("\""); puts(", \""); puts(nodep->comment()); puts("\""); puts(");\n"); } @@ -1199,8 +1199,8 @@ void EmitCImp::emitCoverageDecl(AstModule* modp) { if (v3Global.opt.coverage()) { ofp()->putsPrivate(true); puts("// Coverage\n"); - puts("void __vlCoverInsert(uint32_t* countp, bool enable, const char* filename, int lineno, int column,\n"); - puts( "const char* hier, const char* type, const char* comment);\n"); + puts("void __vlCoverInsert(uint32_t* countp, bool enable, const char* filenamep, int lineno, int column,\n"); + puts( "const char* hierp, const char* pagep, const char* commentp);\n"); } } @@ -1248,19 +1248,19 @@ void EmitCImp::emitCoverageImp(AstModule* modp) { // This gets around gcc slowness constructing all of the template arguments // SystemPerl 1.301 is much faster, but it's nice to remain back // compatible, and have a common wrapper. - puts("void "+modClassName(m_modp)+"::__vlCoverInsert(uint32_t* countp, bool enable, const char* filename, int lineno, int column,\n"); - puts( "const char* hier, const char* type, const char* comment) {\n"); + puts("void "+modClassName(m_modp)+"::__vlCoverInsert(uint32_t* countp, bool enable, const char* filenamep, int lineno, int column,\n"); + puts( "const char* hierp, const char* pagep, const char* commentp) {\n"); puts( "static uint32_t fake_zero_count = 0;\n"); puts( "if (!enable) countp = &fake_zero_count;\n"); // Used for second++ instantiation of identical bin puts( "*countp = 0;\n"); puts( "SP_COVER_INSERT(countp,"); - puts( " \"filename\",filename,"); + puts( " \"filename\",filenamep,"); puts( " \"lineno\",lineno,"); puts( " \"column\",column,\n"); - //puts( "\"hier\",string(__VlSymsp->name())+hier,"); // Need to move hier into scopes and back out if do this - puts( "\"hier\",string(name())+hier,"); - puts( " \"type\",type,"); - puts( " \"comment\",comment);\n"); + //puts( "\"hier\",string(__VlSymsp->name())+hierp,"); // Need to move hier into scopes and back out if do this + puts( "\"hier\",string(name())+hierp,"); + puts( " \"page\",pagep,"); + puts( " \"comment\",commentp);\n"); puts("}\n"); } } diff --git a/test_sp/Makefile b/test_sp/Makefile index e422fed6e..636fc8c02 100644 --- a/test_sp/Makefile +++ b/test_sp/Makefile @@ -20,7 +20,7 @@ export VERILATOR_ROOT # Pick up PERL and other variable settings include $(VERILATOR_ROOT)/include/verilated.mk -DEBUG_ON = --debug --trace-dups --output-split 100 +DEBUG_ON = --debug --trace-dups ###################################################################### test_default: prep preproc compile run coverage @@ -31,7 +31,7 @@ V_FLAGS = -f $(VERILATOR_ROOT)/test_v/input.vc # Note the --public --output-split-cfunc is here for testing only, # Avoid using these settings in real application Makefiles! -VERILATOR_FLAGS = --public --output-split-cfuncs 100 --output-split 100 \ +VERILATOR_FLAGS = --public --output-split-cfuncs 1000 --output-split 1000 \ --sp --coverage --stats --trace $(V_FLAGS) top.v prep: