Cover virtual interface dispatch in assertion control test

This commit is contained in:
Yilou Wang 2026-06-10 15:55:34 +02:00
parent 772aabd4f4
commit d9d153a217
2 changed files with 21 additions and 5 deletions

View File

@ -3,9 +3,10 @@
[0] %Error: t_assert_ctl_immediate.v:58: Assertion failed in top.t.module_with_assertctl: 'assert' failed.
[0] %Error: t_assert_ctl_immediate.v:46: Assertion failed in top.t.module_with_assertctl.f_assert: 'assert' failed.
[0] %Error: t_assert_ctl_immediate.v:46: Assertion failed in top.t.module_with_assertctl.f_assert: 'assert' failed.
[0] %Error: t_assert_ctl_immediate.v:138: Assertion failed in top.t.module_with_method_ctl: 'assert' failed.
[0] %Error: t_assert_ctl_immediate.v:122: Assertion failed in top.t.module_with_method_ctl.Ctl.check_positive: 'assert' failed.
[0] %Error: t_assert_ctl_immediate.v:148: Assertion failed in top.t.module_with_method_ctl: 'assert' failed.
[0] %Error: t_assert_ctl_immediate.v:90: Assertion failed in top.t.module_with_method_ctl.iface.check_positive: 'assert' failed.
[0] %Error: t_assert_ctl_immediate.v:158: Assertion failed in top.t.module_with_method_ctl: 'assert' failed.
[0] %Error: t_assert_ctl_immediate.v:146: Assertion failed in top.t.module_with_method_ctl: 'assert' failed.
[0] %Error: t_assert_ctl_immediate.v:124: Assertion failed in top.t.module_with_method_ctl.Ctl.check_positive: 'assert' failed.
[0] %Error: t_assert_ctl_immediate.v:156: Assertion failed in top.t.module_with_method_ctl: 'assert' failed.
[0] %Error: t_assert_ctl_immediate.v:91: Assertion failed in top.t.module_with_method_ctl.iface.check_positive: 'assert' failed.
[0] %Error: t_assert_ctl_immediate.v:167: Assertion failed in top.t.module_with_method_ctl: 'assert' failed.
[0] %Error: t_assert_ctl_immediate.v:173: Assertion failed in top.t.module_with_method_ctl: 'assert' failed.
*-* All Finished *-*

View File

@ -77,6 +77,7 @@ endmodule
// - assert that lives inside a class method (obeys context-global gating)
// - interface function $assertoff / $asserton
// - assert inside an interface function
// - virtual interface dispatch to an assertion-control function
// - interface class (AstClass with isInterfaceClass) via a concrete impl
interface AssertCtlIf;
@ -109,6 +110,7 @@ endclass
module module_with_method_ctl;
class Ctl;
virtual AssertCtlIf vif;
static function void off_all();
$assertcontrol(4);
endfunction
@ -121,6 +123,12 @@ module module_with_method_ctl;
function void check_positive(int v);
assert (v > 0);
endfunction
function void vif_suppress();
vif.suppress();
endfunction
function void vif_enable();
vif.enable();
endfunction
endclass
Ctl c;
@ -151,6 +159,13 @@ module module_with_method_ctl;
iface.enable();
iface.check_positive(-2); // assert inside iface fn, fires
// --- virtual interface dispatch coverage ---
c.vif = iface;
c.vif_suppress();
assert (0); // gated via virtual interface dispatch -> no fire
c.vif_enable();
assert (0); // fires
// --- interface class via concrete impl ---
impl.suppress();
assert (0); // gated via interface-class impl -> no fire