Improve message on cast assertion failure.
This commit is contained in:
parent
aff501f5c4
commit
5634795140
|
|
@ -439,7 +439,9 @@ class AssertVisitor final : public VNVisitor {
|
|||
} else {
|
||||
++m_statAsNotImm;
|
||||
}
|
||||
if (!passsp && !failsp) failsp = newFireAssertUnchecked(nodep, "'assert' failed.");
|
||||
if (!passsp && !failsp)
|
||||
failsp = newFireAssertUnchecked(
|
||||
nodep, VN_IS(nodep, AssertIntrinsic) ? "'$cast' failed." : "'assert' failed.");
|
||||
} else {
|
||||
nodep->v3fatalSrc("Unknown node type");
|
||||
}
|
||||
|
|
|
|||
|
|
@ -9,76 +9,76 @@ endclass
|
|||
class BasedA extends Base;
|
||||
endclass
|
||||
class BasedB extends Base;
|
||||
static function BasedB getBasedB(bit getNull);
|
||||
BasedB b = new;
|
||||
return getNull ? null : b;
|
||||
endfunction
|
||||
static function BasedB getBasedB(bit getNull);
|
||||
BasedB b = new;
|
||||
return getNull ? null : b;
|
||||
endfunction
|
||||
endclass
|
||||
|
||||
module t;
|
||||
int i;
|
||||
int a;
|
||||
int ao;
|
||||
int i;
|
||||
int a;
|
||||
int ao;
|
||||
|
||||
Base b;
|
||||
Base bo;
|
||||
BasedA ba;
|
||||
BasedA bao;
|
||||
BasedB bb;
|
||||
BasedB bbo;
|
||||
Base b;
|
||||
Base bo;
|
||||
BasedA ba;
|
||||
BasedA bao;
|
||||
BasedB bb;
|
||||
BasedB bbo;
|
||||
|
||||
// verilator lint_off CASTCONST
|
||||
// verilator lint_off CASTCONST
|
||||
|
||||
initial begin
|
||||
a = 1234;
|
||||
i = $cast(ao, a);
|
||||
if (i != 1) $stop;
|
||||
if (ao != 1234) $stop;
|
||||
initial begin
|
||||
a = 1234;
|
||||
i = $cast(ao, a);
|
||||
if (i != 1) $stop;
|
||||
if (ao != 1234) $stop;
|
||||
|
||||
a = 12345;
|
||||
$cast(ao, a);
|
||||
if (ao != 12345) $stop;
|
||||
a = 12345;
|
||||
$cast(ao, a);
|
||||
if (ao != 12345) $stop;
|
||||
|
||||
i = $cast(ao, 2.1 * 3.7);
|
||||
if (i != 1) $stop;
|
||||
if (ao != 8) $stop;
|
||||
i = $cast(ao, 2.1 * 3.7);
|
||||
if (i != 1) $stop;
|
||||
if (ao != 8) $stop;
|
||||
|
||||
i = $cast(bo, null);
|
||||
if (i != 1) $stop;
|
||||
if (bo != null) $stop;
|
||||
i = $cast(bo, null);
|
||||
if (i != 1) $stop;
|
||||
if (bo != null) $stop;
|
||||
|
||||
ba = new;
|
||||
b = ba;
|
||||
i = $cast(bao, b);
|
||||
if (i != 1) $stop;
|
||||
if (b != ba) $stop;
|
||||
ba = new;
|
||||
b = ba;
|
||||
i = $cast(bao, b);
|
||||
if (i != 1) $stop;
|
||||
if (b != ba) $stop;
|
||||
|
||||
bb = new;
|
||||
b = bb;
|
||||
i = $cast(bbo, b);
|
||||
if (i != 1) $stop;
|
||||
if (b != bb) $stop;
|
||||
bb = new;
|
||||
b = bb;
|
||||
i = $cast(bbo, b);
|
||||
if (i != 1) $stop;
|
||||
if (b != bb) $stop;
|
||||
|
||||
bb = null;
|
||||
b = bb;
|
||||
i = $cast(bbo, b);
|
||||
if (i != 1) $stop;
|
||||
if (b != bb) $stop;
|
||||
bb = null;
|
||||
b = bb;
|
||||
i = $cast(bbo, b);
|
||||
if (i != 1) $stop;
|
||||
if (b != bb) $stop;
|
||||
|
||||
bb = BasedB::getBasedB(1);
|
||||
b = bb;
|
||||
i = $cast(bbo, b);
|
||||
if (i != 1) $stop;
|
||||
if (b != bb) $stop;
|
||||
bb = BasedB::getBasedB(1);
|
||||
b = bb;
|
||||
i = $cast(bbo, b);
|
||||
if (i != 1) $stop;
|
||||
if (b != bb) $stop;
|
||||
|
||||
bb = new;
|
||||
b = bb;
|
||||
bao = ba;
|
||||
i = $cast(bao, b);
|
||||
if (i != 0) $stop;
|
||||
if (bao != ba) $stop; // Unchanged
|
||||
bb = new;
|
||||
b = bb;
|
||||
bao = ba;
|
||||
i = $cast(bao, b);
|
||||
if (i != 0) $stop;
|
||||
if (bao != ba) $stop; // Unchanged
|
||||
|
||||
$write("*-* All Finished *-*\n");
|
||||
$finish;
|
||||
end
|
||||
$write("*-* All Finished *-*\n");
|
||||
$finish;
|
||||
end
|
||||
endmodule
|
||||
|
|
|
|||
|
|
@ -1,3 +1,3 @@
|
|||
[0] %Error: t_castdyn_run_bad.v:32: Assertion failed in top.t: 'assert' failed.
|
||||
%Error: t/t_castdyn_run_bad.v:32: Verilog $stop
|
||||
[0] %Error: t_castdyn_run_bad.v:35: Assertion failed in top.t: '$cast' failed.
|
||||
%Error: t/t_castdyn_run_bad.v:35: Verilog $stop
|
||||
Aborting...
|
||||
|
|
|
|||
|
|
@ -12,26 +12,29 @@ class ExbaseB extends Base;
|
|||
endclass
|
||||
|
||||
module t;
|
||||
int i;
|
||||
int i;
|
||||
|
||||
Base b;
|
||||
ExbaseA ba, ba1;
|
||||
ExbaseB bb, bb1;
|
||||
Base b;
|
||||
ExbaseA ba, ba1;
|
||||
ExbaseB bb, bb1;
|
||||
|
||||
initial begin
|
||||
ba = new;
|
||||
b = ba;
|
||||
i = $cast(ba1, b);
|
||||
if (i != 1) $stop;
|
||||
$cast(ba1, b); // ok at runtime
|
||||
initial begin
|
||||
ba = new;
|
||||
b = ba;
|
||||
i = $cast(ba1, b);
|
||||
if (i != 1) $stop;
|
||||
$cast(ba1, b); // ok at runtime
|
||||
|
||||
bb = new;
|
||||
b = bb;
|
||||
i = $cast(ba1, b);
|
||||
if (i != 0) $stop;
|
||||
$cast(ba1, b);
|
||||
b = null;
|
||||
$cast(ba1, b); // no failure on null
|
||||
|
||||
$write("*-* All Finished *-*\n");
|
||||
$finish;
|
||||
end
|
||||
bb = new;
|
||||
b = bb;
|
||||
i = $cast(ba1, b);
|
||||
if (i != 0) $stop;
|
||||
$cast(ba1, b); // <-- Bad $cast task
|
||||
|
||||
$write("*-* All Finished *-*\n");
|
||||
$finish;
|
||||
end
|
||||
endmodule
|
||||
|
|
|
|||
Loading…
Reference in New Issue