Skip to content

Commit

Permalink
Branch coverage for switch case
Browse files Browse the repository at this point in the history
Signed-off-by: Tomasz Gorochowik <[email protected]>
  • Loading branch information
tgorochowik committed Dec 31, 2024
1 parent 5ca9118 commit 9472f36
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 2 deletions.
5 changes: 4 additions & 1 deletion src/V3Coverage.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -515,8 +515,11 @@ class CoverageVisitor final : public VNVisitor {
createHandle(nodep);
iterateAndNextNull(nodep->stmtsp());
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_branch", "case",
linesCov(m_state, nodep), 1,
traceNameForLine(nodep, "case")));
lineTrack(nodep);
nodep->addStmtsp(newCoverInc(nodep->fileline(), "", "v_line", "case",
linesCov(m_state, nodep), 0,
traceNameForLine(nodep, "case")));
Expand Down
6 changes: 5 additions & 1 deletion src/VlcTop.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -127,7 +127,11 @@ void VlcTop::writeInfo(const string& filename) {
int point_num = 0;
for (const auto& point : sc.points()) {
os << "BRDA:" << sc.lineno() << ",";
os << "0,";
if (point->comment() == "case") {
os << "42,";
} else {
os << "0,";
}
os << point_num << ",";
os << point->count() << "\n";

Expand Down

0 comments on commit 9472f36

Please sign in to comment.