Skip to content

Commit

Permalink
Only add coverage comments for toggle for now
Browse files Browse the repository at this point in the history
Signed-off-by: Tomasz Gorochowik <tgorochowik@antmicro.com>
  • Loading branch information
tgorochowik committed Jan 2, 2025
1 parent 9af37fd commit 6555fd4
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 15 deletions.
20 changes: 6 additions & 14 deletions src/V3Coverage.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -476,21 +470,21 @@ 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")));
}
// If/else attributes to each block as non-branch coverage
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")));
}
Expand All @@ -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")));
}
Expand All @@ -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);
Expand All @@ -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")));
}
Expand Down
5 changes: 4 additions & 1 deletion src/VlcTop.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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";

Expand Down

0 comments on commit 6555fd4

Please sign in to comment.