From 2e845821a88641486fa997ecdbcb08b4f40d5406 Mon Sep 17 00:00:00 2001 From: Lars-Peter Clausen Date: Wed, 16 Feb 2022 10:52:58 +0100 Subject: [PATCH] Add regression test for localparams in classes Check that localparams and non-overridable parameters can be declared in a class. Signed-off-by: Lars-Peter Clausen --- ivtest/ivltests/sv_class_localparam.v | 28 +++++++++++++++++++++++++++ ivtest/regress-sv.list | 1 + ivtest/regress-vlog95.list | 1 + 3 files changed, 30 insertions(+) create mode 100644 ivtest/ivltests/sv_class_localparam.v diff --git a/ivtest/ivltests/sv_class_localparam.v b/ivtest/ivltests/sv_class_localparam.v new file mode 100644 index 000000000..b92923d81 --- /dev/null +++ b/ivtest/ivltests/sv_class_localparam.v @@ -0,0 +1,28 @@ +// Check that it is possible to declare parameters and localparams inside a +// class. Both declared parameters that can not be overridden. + +module test; + +class C; + // `parameter` is also declaring a local parameter inside a class + parameter A = 1; + localparam B = 2; + + function bit test(); + return A == 1 && B == 2; + endfunction + +endclass + +initial begin + C c; + c = new; + + if (c.test() && c.A == 1 && c.B == 2) begin + $display("PASSED"); + end else begin + $display("FAILED"); + end +end + +endmodule diff --git a/ivtest/regress-sv.list b/ivtest/regress-sv.list index c4b8b163c..887715467 100644 --- a/ivtest/regress-sv.list +++ b/ivtest/regress-sv.list @@ -436,6 +436,7 @@ sv_class22 normal,-g2009 ivltests sv_class23 normal,-g2009 ivltests sv_class24 normal,-g2009 ivltests sv_class_extends_scoped normal,-g2009 ivltests +sv_class_localparam normal,-g2009 ivltests sv_class_new_init normal,-g2009 ivltests sv_darray1 normal,-g2009 ivltests sv_darray2 normal,-g2009 ivltests diff --git a/ivtest/regress-vlog95.list b/ivtest/regress-vlog95.list index 1c66d40f6..4196cb366 100644 --- a/ivtest/regress-vlog95.list +++ b/ivtest/regress-vlog95.list @@ -364,6 +364,7 @@ sv_class22 CE,-g2009 ivltests sv_class23 CE,-g2009 ivltests sv_class24 CE,-g2009 ivltests sv_class_extends_scoped CE,-g2009 ivltests +sv_class_localparam CE,-g2009 ivltests sv_class_new_init CE,-g2009 ivltests sv_end_label CE,-g2009 ivltests # Also generate sv_foreach2 CE,-g2009,-pallowsigned=1 ivltests