Improve message for priority case assertion failure (#4905)
This commit is contained in:
parent
c3ff52208a
commit
4b9532fe24
|
|
@ -286,13 +286,19 @@ class AssertVisitor final : public VNVisitor {
|
||||||
itemp = VN_AS(itemp->nextp(), CaseItem)) {
|
itemp = VN_AS(itemp->nextp(), CaseItem)) {
|
||||||
if (itemp->isDefault()) has_default = true;
|
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()) {
|
if (nodep->fullPragma() || nodep->priorityPragma()) {
|
||||||
// Need to add a default if there isn't one already
|
// Need to add a default if there isn't one already
|
||||||
++m_statAsFull;
|
++m_statAsFull;
|
||||||
if (!has_default) {
|
if (!has_default) {
|
||||||
nodep->addItemsp(new AstCaseItem{
|
nodep->addItemsp(new AstCaseItem{
|
||||||
nodep->fileline(), nullptr /*DEFAULT*/,
|
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()) {
|
if (nodep->parallelPragma() || nodep->uniquePragma() || nodep->unique0Pragma()) {
|
||||||
|
|
@ -344,14 +350,13 @@ class AssertVisitor final : public VNVisitor {
|
||||||
new AstLogNot{nodep->fileline(), propp->cloneTreePure(false)}};
|
new AstLogNot{nodep->fileline(), propp->cloneTreePure(false)}};
|
||||||
AstNodeExpr* const exprp = nodep->exprp();
|
AstNodeExpr* const exprp = nodep->exprp();
|
||||||
const string pragmaStr = nodep->pragmaString();
|
const string pragmaStr = nodep->pragmaString();
|
||||||
const string valFmt = "'" + cvtToStr(exprp->dtypep()->widthMin()) + "'h%X'";
|
|
||||||
if (!allow_none)
|
if (!allow_none)
|
||||||
zeroIfp->addThensp(
|
zeroIfp->addThensp(
|
||||||
newFireAssert(nodep, pragmaStr + ", but none matched for " + valFmt,
|
newFireAssert(nodep, pragmaStr + ", but none matched" + valFmt,
|
||||||
exprp->cloneTreePure(false)));
|
valFmt.empty() ? nullptr : exprp->cloneTreePure(false)));
|
||||||
zeroIfp->addElsesp(newFireAssert(
|
zeroIfp->addElsesp(
|
||||||
nodep, pragmaStr + ", but multiple matches found for " + valFmt,
|
newFireAssert(nodep, pragmaStr + ", but multiple matches found" + valFmt,
|
||||||
exprp->cloneTreePure(false)));
|
valFmt.empty() ? nullptr : exprp->cloneTreePure(false)));
|
||||||
ohotIfp->addThensp(zeroIfp);
|
ohotIfp->addThensp(zeroIfp);
|
||||||
ohotIfp->isBoundsCheck(true); // To avoid LATCH warning
|
ohotIfp->isBoundsCheck(true); // To avoid LATCH warning
|
||||||
ohotIfp->branchPred(VBranchPred::BP_UNLIKELY);
|
ohotIfp->branchPred(VBranchPred::BP_UNLIKELY);
|
||||||
|
|
|
||||||
|
|
@ -1,6 +1,6 @@
|
||||||
[0] -Info: t_assert_synth.v:115: top.t.test_info: Start of $info test
|
[0] -Info: t_assert_synth.v:115: top.t.test_info: Start of $info test
|
||||||
[0] -Info: t_assert_synth.v:116: top.t.test_info: Middle of $info test
|
[0] -Info: t_assert_synth.v:116: top.t.test_info: Middle of $info test
|
||||||
[0] -Info: t_assert_synth.v:117: top.t.test_info: End of $info test
|
[0] -Info: t_assert_synth.v:117: top.t.test_info: End of $info test
|
||||||
[40] %Error: t_assert_synth.v:31: Assertion failed in top.t: synthesis full_case, but non-match found
|
[40] %Error: t_assert_synth.v:31: Assertion failed in top.t: synthesis full_case, but non-match found for '2'h3'
|
||||||
%Error: t/t_assert_synth.v:31: Verilog $stop
|
%Error: t/t_assert_synth.v:31: Verilog $stop
|
||||||
Aborting...
|
Aborting...
|
||||||
|
|
|
||||||
|
|
@ -1,6 +1,6 @@
|
||||||
[0] -Info: t_assert_synth.v:115: top.t.test_info: Start of $info test
|
[0] -Info: t_assert_synth.v:115: top.t.test_info: Start of $info test
|
||||||
[0] -Info: t_assert_synth.v:116: top.t.test_info: Middle of $info test
|
[0] -Info: t_assert_synth.v:116: top.t.test_info: Middle of $info test
|
||||||
[0] -Info: t_assert_synth.v:117: top.t.test_info: End of $info test
|
[0] -Info: t_assert_synth.v:117: top.t.test_info: End of $info test
|
||||||
[40] %Error: t_assert_synth.v:40: Assertion failed in top.t: synthesis full_case, but non-match found
|
[40] %Error: t_assert_synth.v:40: Assertion failed in top.t: priority case, but non-match found for '2'h3'
|
||||||
%Error: t/t_assert_synth.v:40: Verilog $stop
|
%Error: t/t_assert_synth.v:40: Verilog $stop
|
||||||
Aborting...
|
Aborting...
|
||||||
|
|
|
||||||
|
|
@ -1,12 +1,19 @@
|
||||||
|
[0] %Error: t_assert_unique_case_bad.v:56: Assertion failed in top.t: priority case, but non-match found
|
||||||
|
match_item0
|
||||||
|
[20] %Error: t_assert_unique_case_bad.v:47: Assertion failed in top.t: unique case, but none matched
|
||||||
match_item0
|
match_item0
|
||||||
match_item0
|
match_item0
|
||||||
|
[40] %Error: t_assert_unique_case_bad.v:47: Assertion failed in top.t: unique case, but none matched
|
||||||
match_item0
|
match_item0
|
||||||
match_item0
|
match_item0
|
||||||
|
[60] %Error: t_assert_unique_case_bad.v:47: Assertion failed in top.t: unique case, but none matched
|
||||||
match_item0
|
match_item0
|
||||||
match_item0
|
match_item0
|
||||||
|
[80] %Error: t_assert_unique_case_bad.v:47: Assertion failed in top.t: unique case, but none matched
|
||||||
match_item0
|
match_item0
|
||||||
|
[90] %Error: t_assert_unique_case_bad.v:47: Assertion failed in top.t: unique case, but none matched
|
||||||
match_item0
|
match_item0
|
||||||
match_item0
|
[90] %Error: t_assert_unique_case_bad.v:38: Assertion failed in top.t: unique case, but multiple matches found for '12'h388'
|
||||||
[90] %Error: t_assert_unique_case_bad.v:36: Assertion failed in top.t: unique case, but multiple matches found for '12'h388'
|
|
||||||
*-* All Finished *-*
|
*-* All Finished *-*
|
||||||
|
[100] %Error: t_assert_unique_case_bad.v:47: Assertion failed in top.t: unique case, but none matched
|
||||||
match_item0
|
match_item0
|
||||||
|
|
|
||||||
|
|
@ -12,7 +12,7 @@ scenarios(simulator => 1);
|
||||||
top_filename("t/t_assert_unique_case_bad.v");
|
top_filename("t/t_assert_unique_case_bad.v");
|
||||||
|
|
||||||
compile(
|
compile(
|
||||||
verilator_flags2 => ["-x-assign 0 --assert --no-stop-fail"],
|
verilator_flags2 => ["-x-assign 0 --assert --no-stop-fail +define+NO_STOP_FAIL"],
|
||||||
);
|
);
|
||||||
|
|
||||||
execute(
|
execute(
|
||||||
|
|
|
||||||
|
|
@ -7,6 +7,6 @@ match_item0
|
||||||
match_item0
|
match_item0
|
||||||
match_item0
|
match_item0
|
||||||
match_item0
|
match_item0
|
||||||
[90] %Error: t_assert_unique_case_bad.v:36: Assertion failed in top.t: unique case, but multiple matches found for '12'h388'
|
[90] %Error: t_assert_unique_case_bad.v:38: Assertion failed in top.t: unique case, but multiple matches found for '12'h388'
|
||||||
%Error: t/t_assert_unique_case_bad.v:36: Verilog $stop
|
%Error: t/t_assert_unique_case_bad.v:38: Verilog $stop
|
||||||
Aborting...
|
Aborting...
|
||||||
|
|
|
||||||
|
|
@ -17,6 +17,7 @@ module t (/*AUTOARG*/
|
||||||
logic [31:0] addr;
|
logic [31:0] addr;
|
||||||
logic [11:0] match_item0, match_item1;
|
logic [11:0] match_item0, match_item1;
|
||||||
int cyc;
|
int cyc;
|
||||||
|
string s;
|
||||||
|
|
||||||
initial addr = 32'h380;
|
initial addr = 32'h380;
|
||||||
|
|
||||||
|
|
@ -25,6 +26,7 @@ module t (/*AUTOARG*/
|
||||||
addr <= 32'h380 + cyc;
|
addr <= 32'h380 + cyc;
|
||||||
match_item0 = 12'h 380 + cyc[11:0];
|
match_item0 = 12'h 380 + cyc[11:0];
|
||||||
match_item1 = 12'h 390 - cyc[11:0];
|
match_item1 = 12'h 390 - cyc[11:0];
|
||||||
|
$sformat(s, "%1d", cyc);
|
||||||
if (cyc == 9) begin
|
if (cyc == 9) begin
|
||||||
$write("*-* All Finished *-*\n");
|
$write("*-* All Finished *-*\n");
|
||||||
$finish;
|
$finish;
|
||||||
|
|
@ -40,4 +42,23 @@ module t (/*AUTOARG*/
|
||||||
endcase
|
endcase
|
||||||
end
|
end
|
||||||
|
|
||||||
|
`ifdef NO_STOP_FAIL
|
||||||
|
always_comb begin
|
||||||
|
unique case (s)
|
||||||
|
"": ;
|
||||||
|
"0": ;
|
||||||
|
"2": ;
|
||||||
|
"4": ;
|
||||||
|
"6": ;
|
||||||
|
endcase
|
||||||
|
end
|
||||||
|
always_comb begin
|
||||||
|
priority case (s)
|
||||||
|
$sformatf("%1d", cyc - 1): ;
|
||||||
|
"0": ;
|
||||||
|
"6": ;
|
||||||
|
endcase
|
||||||
|
end
|
||||||
|
`endif
|
||||||
|
|
||||||
endmodule
|
endmodule
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue