From c8044bddf0bda0f2eccc3555a6118af3a3706ced Mon Sep 17 00:00:00 2001 From: Lars-Peter Clausen Date: Fri, 7 Oct 2022 23:23:55 +0200 Subject: [PATCH] Add regression test for access to static property of base class Check that it is possible to access a static property of a base class. Signed-off-by: Lars-Peter Clausen --- ivtest/ivltests/sv_class_static_prop4.v | 45 +++++++++++++++++++++++++ ivtest/regress-sv.list | 1 + ivtest/regress-vlog95.list | 1 + 3 files changed, 47 insertions(+) create mode 100644 ivtest/ivltests/sv_class_static_prop4.v diff --git a/ivtest/ivltests/sv_class_static_prop4.v b/ivtest/ivltests/sv_class_static_prop4.v new file mode 100644 index 000000000..553770eeb --- /dev/null +++ b/ivtest/ivltests/sv_class_static_prop4.v @@ -0,0 +1,45 @@ +// Check that it is possible to access static properties of a base class + +class B; + static int x = 0; + static int y = 0; +endclass + +class C extends B; + + task t(int a, int b); + x = a; + this.y = b; + endtask + + function int f; + return x + this.y; + endfunction + +endclass + +module test; + bit failed = 1'b0; + + `define check(expr, val) \ + if (expr !== val) begin \ + $display("FAILED: `%s`, expected %b, got %b", `"expr`", val, expr); \ + failed = 1'b1; \ + end + + C c = new; + + initial begin + // Check access inside the class + c.t(10, 20); + `check(c.f(), 30) + + // Check access outside of the class + c.x = 40; + `check(c.x, 40) + + if (!failed) begin + $display("PASSED"); + end + end +endmodule diff --git a/ivtest/regress-sv.list b/ivtest/regress-sv.list index cc5a8ec25..5d32a323c 100644 --- a/ivtest/regress-sv.list +++ b/ivtest/regress-sv.list @@ -590,6 +590,7 @@ sv_class_return normal,-g2009 ivltests sv_class_static_prop1 normal,-g2009 ivltests sv_class_static_prop2 normal,-g2009 ivltests sv_class_static_prop3 normal,-g2009 ivltests +sv_class_static_prop4 normal,-g2009 ivltests sv_class_super1 normal,-g2009 ivltests sv_class_super2 normal,-g2009 ivltests sv_class_super3 normal,-g2009 ivltests diff --git a/ivtest/regress-vlog95.list b/ivtest/regress-vlog95.list index 76d299369..ad008941a 100644 --- a/ivtest/regress-vlog95.list +++ b/ivtest/regress-vlog95.list @@ -437,6 +437,7 @@ sv_class_return CE,-g2009 ivltests sv_class_static_prop1 CE,-g2009 ivltests sv_class_static_prop2 CE,-g2009 ivltests sv_class_static_prop3 CE,-g2009 ivltests +sv_class_static_prop4 CE,-g2009 ivltests sv_class_super1 CE,-g2009 ivltests sv_class_super2 CE,-g2009 ivltests sv_class_super3 CE,-g2009 ivltests