Skip to content

Commit

Permalink
disable-iff and conditional assertion expressions should not error fo…
Browse files Browse the repository at this point in the history
…r constant values

The error is for degenerate sequences, but disable-iff and conditional properties are not sequences, they are properties, so the error doesn't make sense. No commercial tool errors or even warns for these.
  • Loading branch information
MikePopoloski committed May 27, 2024
1 parent f2d2335 commit a65d5b9
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 21 deletions.
2 changes: 0 additions & 2 deletions scripts/diagnostics.txt
Original file line number Diff line number Diff line change
Expand Up @@ -861,8 +861,6 @@ note NoteExpandedHere "expanded here"
note SeqAdmitsEmptyMatches "sequence property admits empty matches"
note SeqAdmitsNoMatches "sequence property can never be matched"
note SeqAcceptsOnlyEmptyMatches "sequence property admits only empty matches"
note SeqPropCondAlwaysFalse "condition is always false"
note DisableIffCondAlwaysTrue "disable iff condition is always true"

subsystem Types
error InvalidEnumBase "invalid enum base type {} (must be a single dimensional integer type)"
Expand Down
14 changes: 0 additions & 14 deletions source/ast/expressions/AssertionExpr.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1345,14 +1345,6 @@ AssertionExpr& ConditionalAssertionExpr::fromSyntax(const ConditionalPropertyExp
if (syntax.elseClause)
elseExpr = &bind(*syntax.elseClause->expr, context);

// If condition is a constant false value then there is never a match.
if (!elseExpr) {
if (context.tryEval(cond).isFalse()) {
auto& diag = context.addDiag(diag::SeqPropNondegenerate, syntax.sourceRange());
diag.addNote(diag::SeqPropCondAlwaysFalse, cond.sourceRange);
}
}

return *comp.emplace<ConditionalAssertionExpr>(cond, ifExpr, elseExpr);
}

Expand Down Expand Up @@ -1424,12 +1416,6 @@ AssertionExpr& DisableIffAssertionExpr::fromSyntax(const DisableIffSyntax& synta

checkSampledValueExpr(cond, context, false, diag::DisableIffLocalVar, diag::DisableIffMatched);

// If condition is always true then there's never a match.
if (context.tryEval(cond).isTrue()) {
auto& diag = context.addDiag(diag::SeqPropNondegenerate, syntax.sourceRange());
diag.addNote(diag::DisableIffCondAlwaysTrue, cond.sourceRange);
}

if (context.assertionInstance && context.assertionInstance->isRecursive)
context.addDiag(diag::RecursivePropDisableIff, syntax.sourceRange());

Expand Down
14 changes: 9 additions & 5 deletions tests/unittests/ast/AssertionTests.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2382,7 +2382,9 @@ endmodule
}
else if (diags.size() != 1 || diags[0].code != code) {
FAIL_CHECK(expr);
CHECK(diags[0].code == *code);
CHECK(diags.size() == 1);
if (diags.size() == 1)
CHECK(diags[0].code == *code);
}
};

Expand Down Expand Up @@ -2430,7 +2432,9 @@ endmodule
}
else if (diags.size() != 1 || diags[0].code != code) {
FAIL_CHECK(expr);
CHECK(diags[0].code == *code);
CHECK(diags.size() == 1);
if (diags.size() == 1)
CHECK(diags[0].code == *code);
}
};

Expand Down Expand Up @@ -2508,15 +2512,13 @@ endmodule

test("if (b) a ##1 c else d ##1 e");
test("if (1'b0) a ##1 c else d ##1 e");
test("if (1'b0) a ##1 c", diag::SeqPropNondegenerate);
test("if (1'b1) a ##1 c else d ##1 e");
test("if (a) b intersect ##2 b", diag::SeqPropNondegenerate);
test("if (a) ##2 b intersect ##2 b");
test("case (b) 1, 2, 3: 1 ##1 b; 4: a and b; default: 1 |-> b; endcase");
test("case (b) 1, 2, 3: 1 ##1 b; 4: a and b; default: 1[*0] |-> b; endcase",
diag::OverlapImplNondegenerate);
test("disable iff (clk) a");
test("disable iff (1'b1) a", diag::SeqPropNondegenerate);
}

TEST_CASE("Sequence nondegeneracy tests 3") {
Expand All @@ -2543,7 +2545,9 @@ endmodule
}
else if (diags.size() != 1 || diags[0].code != code) {
FAIL_CHECK(expr);
CHECK(diags[0].code == *code);
CHECK(diags.size() == 1);
if (diags.size() == 1)
CHECK(diags[0].code == *code);
}
};

Expand Down

0 comments on commit a65d5b9

Please sign in to comment.