Fix generate case with empty body statements.

This commit is contained in:
Wilson Snyder 2023-02-12 18:14:18 -05:00
parent 15d0ec317d
commit 10d0088f73
2 changed files with 10 additions and 2 deletions

View File

@ -85,6 +85,7 @@ Verilator 5.006 2023-01-22
* Fix elaboration of member selected classes (#3890). [Ilya Barkov]
* Fix mismatched widths in DFG (#3872). [Geza Lore, Yike Zhou]
* Fix lint for non-integral types in packed structs.
* Fix generate case with empty body statements.
Verilator 5.004 2022-12-14

View File

@ -1250,6 +1250,7 @@ class ParamVisitor final : public VNVisitor {
}
void visit(AstGenCase* nodep) override {
UINFO(9, " GENCASE " << nodep << endl);
bool hit = false;
AstNode* keepp = nullptr;
iterateAndNextNull(nodep->exprp());
V3Case::caseLint(nodep);
@ -1275,7 +1276,10 @@ class ParamVisitor final : public VNVisitor {
if (const AstConst* const ccondp = VN_CAST(ep, Const)) {
V3Number match{nodep, 1};
match.opEq(ccondp->num(), exprp->num());
if (!keepp && match.isNeqZero()) keepp = itemp->stmtsp();
if (!hit && match.isNeqZero()) {
hit = true;
keepp = itemp->stmtsp();
}
} else {
itemp->v3error("Generate Case item does not evaluate to constant");
}
@ -1286,7 +1290,10 @@ class ParamVisitor final : public VNVisitor {
for (AstCaseItem* itemp = nodep->itemsp(); itemp;
itemp = VN_AS(itemp->nextp(), CaseItem)) {
if (itemp->isDefault()) {
if (!keepp) keepp = itemp->stmtsp();
if (!hit) {
hit = true;
keepp = itemp->stmtsp();
}
}
}
// Replace