Improve message for priority case assertion failure (#4905)

This commit is contained in:
Yutetsu TAKATSUKASA
2024-02-22 03:09:14 -05:00
committed by GitHub
parent c3ff52208a
commit 4b9532fe24
7 changed files with 47 additions and 14 deletions
+12 -7
View File
@@ -286,13 +286,19 @@ class AssertVisitor final : public VNVisitor {
itemp = VN_AS(itemp->nextp(), CaseItem)) {
if (itemp->isDefault()) has_default = true;
}
const AstNodeDType* exprDtypep = nodep->exprp()->dtypep()->skipRefp();
string valFmt;
if (exprDtypep->isIntegralOrPacked())
valFmt = " for '" + cvtToStr(exprDtypep->widthMin()) + "'h%X'";
if (nodep->fullPragma() || nodep->priorityPragma()) {
// Need to add a default if there isn't one already
++m_statAsFull;
if (!has_default) {
nodep->addItemsp(new AstCaseItem{
nodep->fileline(), nullptr /*DEFAULT*/,
newFireAssert(nodep, "synthesis full_case, but non-match found")});
newFireAssert(
nodep, nodep->pragmaString() + ", but non-match found" + valFmt,
valFmt.empty() ? nullptr : nodep->exprp()->cloneTreePure(false))});
}
}
if (nodep->parallelPragma() || nodep->uniquePragma() || nodep->unique0Pragma()) {
@@ -344,14 +350,13 @@ class AssertVisitor final : public VNVisitor {
new AstLogNot{nodep->fileline(), propp->cloneTreePure(false)}};
AstNodeExpr* const exprp = nodep->exprp();
const string pragmaStr = nodep->pragmaString();
const string valFmt = "'" + cvtToStr(exprp->dtypep()->widthMin()) + "'h%X'";
if (!allow_none)
zeroIfp->addThensp(
newFireAssert(nodep, pragmaStr + ", but none matched for " + valFmt,
exprp->cloneTreePure(false)));
zeroIfp->addElsesp(newFireAssert(
nodep, pragmaStr + ", but multiple matches found for " + valFmt,
exprp->cloneTreePure(false)));
newFireAssert(nodep, pragmaStr + ", but none matched" + valFmt,
valFmt.empty() ? nullptr : exprp->cloneTreePure(false)));
zeroIfp->addElsesp(
newFireAssert(nodep, pragmaStr + ", but multiple matches found" + valFmt,
valFmt.empty() ? nullptr : exprp->cloneTreePure(false)));
ohotIfp->addThensp(zeroIfp);
ohotIfp->isBoundsCheck(true); // To avoid LATCH warning
ohotIfp->branchPred(VBranchPred::BP_UNLIKELY);