Skip to content

Commit

Permalink
Fix toggle coverage indexing
Browse files Browse the repository at this point in the history
Signed-off-by: Tomasz Gorochowik <[email protected]>
  • Loading branch information
tgorochowik committed Jan 14, 2025
1 parent ced0d02 commit 28d4524
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 6 deletions.
11 changes: 7 additions & 4 deletions src/V3Coverage.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -299,9 +299,12 @@ class CoverageVisitor final : public VNVisitor {
}
}

void toggleVarBottom(const ToggleEnt& above, const AstVar* varp) {
void toggleVarBottom(const ToggleEnt& above, const AstVar* varp, int index) {
char comment[100];
snprintf(comment, 100, "toggle_%pZ_", m_modp);
if (index >=0 )
snprintf(comment, 100, "toggle_%p_%dZ_", m_modp, index);
else
snprintf(comment, 100, "toggle_%pZ_", m_modp);
AstCoverToggle* const newp = new AstCoverToggle{
varp->fileline(),
newCoverInc(varp->fileline(), "", "v_toggle", string(comment) + varp->name() + above.m_comment, "", 0,
Expand All @@ -322,11 +325,11 @@ class CoverageVisitor final : public VNVisitor {
index_code, 1},
new AstSel{varp->fileline(), above.m_chgRefp->cloneTree(true),
index_code, 1}};
toggleVarBottom(newent, varp);
toggleVarBottom(newent, varp, index_docs);
newent.cleanup();
}
} else {
toggleVarBottom(above, varp);
toggleVarBottom(above, varp, -1);
}
} else if (const AstUnpackArrayDType* const adtypep = VN_CAST(dtypep, UnpackArrayDType)) {
for (int index_docs = adtypep->lo(); index_docs <= adtypep->hi(); ++index_docs) {
Expand Down
10 changes: 8 additions & 2 deletions src/VlcTop.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -128,8 +128,14 @@ 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")) << "_";
os << point_num << ",";
const string cmt = point->comment().substr(0, point->comment().find("Z"));
size_t u_cnt = std::count_if(cmt.begin(), cmt.end(), []( char c ){return c =='_';});
os << cmt;
cout << "for comment: " << point->comment() << " cmt: " << cmt << " count is " << u_cnt << "\n";
if (u_cnt == 1) {
os << "_" << point_num;
}
os << ",";
os << point->count() << "\n";

branchesHit += opt.countOk(point->count());
Expand Down

0 comments on commit 28d4524

Please sign in to comment.