From efa28f646a94440c71c613594dbc89e28e779dce Mon Sep 17 00:00:00 2001 From: Yilou Wang Date: Mon, 15 Jun 2026 12:31:58 +0200 Subject: [PATCH] Test assertion control with multiple class and interface instances --- test_regress/t/t_assert_ctl_immediate.out | 15 +++++++----- test_regress/t/t_assert_ctl_immediate.v | 30 +++++++++++++++++++++++ 2 files changed, 39 insertions(+), 6 deletions(-) diff --git a/test_regress/t/t_assert_ctl_immediate.out b/test_regress/t/t_assert_ctl_immediate.out index cfd6811b6..58b76b5f2 100644 --- a/test_regress/t/t_assert_ctl_immediate.out +++ b/test_regress/t/t_assert_ctl_immediate.out @@ -3,10 +3,13 @@ [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: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. +[0] %Error: t_assert_ctl_immediate.v:159: Assertion failed in top.t.module_with_method_ctl: 'assert' failed. +[0] %Error: t_assert_ctl_immediate.v:132: Assertion failed in top.t.module_with_method_ctl.Ctl.check_positive: 'assert' failed. +[0] %Error: t_assert_ctl_immediate.v:169: Assertion failed in top.t.module_with_method_ctl: 'assert' failed. +[0] %Error: t_assert_ctl_immediate.v:93: Assertion failed in top.t.module_with_method_ctl.iface.check_positive: 'assert' failed. +[0] %Error: t_assert_ctl_immediate.v:180: Assertion failed in top.t.module_with_method_ctl: 'assert' failed. +[0] %Error: t_assert_ctl_immediate.v:186: Assertion failed in top.t.module_with_method_ctl: 'assert' failed. +[0] %Error: t_assert_ctl_immediate.v:195: Assertion failed in top.t.module_with_method_ctl: 'assert' failed. +[0] %Error: t_assert_ctl_immediate.v:199: Assertion failed in top.t.module_with_method_ctl: 'assert' failed. +[0] %Error: t_assert_ctl_immediate.v:203: Assertion failed in top.t.module_with_method_ctl: 'assert' failed. *-* All Finished *-* diff --git a/test_regress/t/t_assert_ctl_immediate.v b/test_regress/t/t_assert_ctl_immediate.v index 18ef2775d..cc9d22b1b 100644 --- a/test_regress/t/t_assert_ctl_immediate.v +++ b/test_regress/t/t_assert_ctl_immediate.v @@ -79,6 +79,8 @@ endmodule // - assert inside an interface function // - virtual interface dispatch to an assertion-control function // - interface class (AstClass with isInterfaceClass) via a concrete impl +// - multiple instances of each thing: OFF via one instance, ON via another +// (assertion control is global per-context, IEEE 1800-2023 20.11) interface AssertCtlIf; function void suppress(); @@ -120,6 +122,12 @@ module module_with_method_ctl; function void kill_all(); $assertkill; endfunction + function void inst_off(); + $assertoff; + endfunction + function void inst_on(); + $asserton; + endfunction function void check_positive(int v); assert (v > 0); endfunction @@ -132,12 +140,17 @@ module module_with_method_ctl; endclass Ctl c; + Ctl c2; AssertCtlIf iface (); + AssertCtlIf iface2 (); IAssertCtlImpl impl; + IAssertCtlImpl impl2; initial begin c = new; + c2 = new; impl = new; + impl2 = new; // --- class method coverage --- Ctl::off_all(); @@ -172,6 +185,23 @@ module module_with_method_ctl; impl.enable(); assert (0); // fires + // --- multiple instances: OFF via one instance, ON via another --- + // Assertion control is global per-context (IEEE 1800-2023 20.11, no scope + // list), so OFF issued via one instance gates every assertion and ON issued + // via a different instance re-enables them. + c.inst_off(); // class: OFF via c + assert (0); // gated -> no fire + c2.inst_on(); // class: ON via c2 + assert (0); // fires + iface.suppress(); // interface: OFF via iface + assert (0); // gated -> no fire + iface2.enable(); // interface: ON via iface2 + assert (0); // fires + impl.suppress(); // interface class: OFF via impl + assert (0); // gated -> no fire + impl2.enable(); // interface class: ON via impl2 + assert (0); // fires + // --- $assertkill (last: terminal per IEEE 1800-2023 Table 20-5) --- c.kill_all(); assert (0); // killed -> no fire