From 6555fd4993b0bce4a410990d40d816fa33b30736 Mon Sep 17 00:00:00 2001 From: Tomasz Gorochowik Date: Thu, 2 Jan 2025 14:53:39 +0100 Subject: [PATCH] Only add coverage comments for toggle for now Signed-off-by: Tomasz Gorochowik --- src/V3Coverage.cpp | 20 ++++++-------------- src/VlcTop.cpp | 5 ++++- 2 files changed, 10 insertions(+), 15 deletions(-) diff --git a/src/V3Coverage.cpp b/src/V3Coverage.cpp index d2fc446198..4d2f4122cf 100644 --- a/src/V3Coverage.cpp +++ b/src/V3Coverage.cpp @@ -433,12 +433,6 @@ class CoverageVisitor final : public VNVisitor { // Note not AstNodeIf; other types don't get covered void visit(AstIf* nodep) override { UINFO(4, " IF: " << nodep << endl); - char comment_if[100]; - snprintf(comment_if, 100, "if_%pZ", m_modp); - char comment_else[100]; - snprintf(comment_else, 100, "else_%pZ", m_modp); - char comment_elsif[100]; - snprintf(comment_elsif, 100, "elsif_%pZ", m_modp); if (m_state.m_on) { // An else-if. When we iterate the if, use "elsif" marking const bool elsif @@ -476,13 +470,13 @@ class CoverageVisitor final : public VNVisitor { // Normal if. Linecov shows what's inside the if (not condition that is // always executed) UINFO(4, " COVER-branch: " << nodep << endl); - nodep->addThensp(newCoverInc(nodep->fileline(), "", "v_branch", comment_if, + nodep->addThensp(newCoverInc(nodep->fileline(), "", "v_branch", "if", linesCov(ifState, nodep), 0, traceNameForLine(nodep, "if"))); // The else has a column offset of 1 to uniquify it relative to the if // As "if" and "else" are more than one character wide, this won't overlap // another token - nodep->addElsesp(newCoverInc(nodep->fileline(), "", "v_branch", comment_else, + nodep->addElsesp(newCoverInc(nodep->fileline(), "", "v_branch", "else", linesCov(elseState, nodep), 1, traceNameForLine(nodep, "else"))); } @@ -490,7 +484,7 @@ class CoverageVisitor final : public VNVisitor { else if (first_elsif || cont_elsif) { UINFO(4, " COVER-elsif: " << nodep << endl); if (ifState.lineCoverageOn(nodep)) { - nodep->addThensp(newCoverInc(nodep->fileline(), "", "v_line", comment_elsif, + nodep->addThensp(newCoverInc(nodep->fileline(), "", "v_line", "elsif", linesCov(ifState, nodep), 0, traceNameForLine(nodep, "elsif"))); } @@ -499,13 +493,13 @@ class CoverageVisitor final : public VNVisitor { // Cover as separate blocks (not a branch as is not two-legged) if (ifState.lineCoverageOn(nodep)) { UINFO(4, " COVER-half-if: " << nodep << endl); - nodep->addThensp(newCoverInc(nodep->fileline(), "", "v_line", comment_if, + nodep->addThensp(newCoverInc(nodep->fileline(), "", "v_line", "if", linesCov(ifState, nodep), 0, traceNameForLine(nodep, "if"))); } if (elseState.lineCoverageOn(nodep)) { UINFO(4, " COVER-half-el: " << nodep << endl); - nodep->addElsesp(newCoverInc(nodep->fileline(), "", "v_line", comment_else, + nodep->addElsesp(newCoverInc(nodep->fileline(), "", "v_line", "else", linesCov(elseState, nodep), 1, traceNameForLine(nodep, "else"))); } @@ -517,8 +511,6 @@ class CoverageVisitor final : public VNVisitor { void visit(AstCaseItem* nodep) override { // We don't add an explicit "default" coverage if not provided, // as we already have a warning when there is no default. - char comment[100]; - snprintf(comment, 100, "case_%pZ", m_modp); UINFO(4, " CASEI: " << nodep << endl); if (m_state.lineCoverageOn(nodep)) { VL_RESTORER(m_state); @@ -527,7 +519,7 @@ class CoverageVisitor final : public VNVisitor { if (m_state.lineCoverageOn(nodep)) { // if the case body didn't disable it lineTrack(nodep); UINFO(4, " COVER: " << nodep << endl); - nodep->addStmtsp(newCoverInc(nodep->fileline(), "", "v_line", comment, + nodep->addStmtsp(newCoverInc(nodep->fileline(), "", "v_line", "case", linesCov(m_state, nodep), 0, traceNameForLine(nodep, "case"))); } diff --git a/src/VlcTop.cpp b/src/VlcTop.cpp index f5253a42cc..e04f38d8c3 100644 --- a/src/VlcTop.cpp +++ b/src/VlcTop.cpp @@ -128,7 +128,10 @@ void VlcTop::writeInfo(const string& filename) { for (const auto& point : sc.points()) { os << "BRDA:" << sc.lineno() << ","; os << "0,"; - os << point->comment().substr(0, point->comment().find("Z")) << "_"; + + if (point->comment().rfind("toggle") != 0) + os << point->comment().substr(0, point->comment().find("Z")) << "_"; + os << point_num << ","; os << point->count() << "\n";