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 <lars@metafoo.de>
This commit is contained in:
Lars-Peter Clausen 2022-02-16 10:52:58 +01:00
parent d104e28dbf
commit 2e845821a8
3 changed files with 30 additions and 0 deletions

View File

@ -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

View File

@ -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

View File

@ -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