From abe5e692ceea29733c8e4a97e35c1134e060555a Mon Sep 17 00:00:00 2001 From: Lars-Peter Clausen Date: Tue, 22 Mar 2022 11:10:47 +0100 Subject: [PATCH] Add regression test for classes defined in modules Check that it is possible to have multiple instances of a module that declares a class and that the class in each module instance is a unique type that can have dependencies on module parameters. Signed-off-by: Lars-Peter Clausen --- ivtest/ivltests/sv_class_in_module_decl.v | 32 +++++++++++++++++++++++ ivtest/regress-sv.list | 1 + ivtest/regress-vlog95.list | 1 + 3 files changed, 34 insertions(+) create mode 100644 ivtest/ivltests/sv_class_in_module_decl.v diff --git a/ivtest/ivltests/sv_class_in_module_decl.v b/ivtest/ivltests/sv_class_in_module_decl.v new file mode 100644 index 000000000..267bed7b9 --- /dev/null +++ b/ivtest/ivltests/sv_class_in_module_decl.v @@ -0,0 +1,32 @@ +// Check that it is possible to have multiple instances of a module that defines +// a class and that the actual class types can have different implementations +// based on module parameters. + +module M #( + parameter X = 0 +); + + class C; + function int f; + return X; + endfunction + endclass + + C c = new; + +endmodule + +module test; + + M #(10) m1(); + M #(20) m2(); + + initial begin + if (m1.c.f() == 10 && m2.c.f() == 20) begin + $display("PASSED"); + end else begin + $display("FAILED"); + end + end + +endmodule diff --git a/ivtest/regress-sv.list b/ivtest/regress-sv.list index 70e7b90c5..26c1e2ff8 100644 --- a/ivtest/regress-sv.list +++ b/ivtest/regress-sv.list @@ -458,6 +458,7 @@ sv_class_empty_item normal,-g2009 ivltests sv_class_extends_scoped normal,-g2009 ivltests sv_class_localparam normal,-g2009 ivltests sv_class_new_init normal,-g2009 ivltests +sv_class_in_module_decl normal,-g2009 ivltests sv_darray1 normal,-g2009 ivltests sv_darray2 normal,-g2009 ivltests sv_darray3 normal,-g2009 ivltests diff --git a/ivtest/regress-vlog95.list b/ivtest/regress-vlog95.list index 89af38b69..576b6354b 100644 --- a/ivtest/regress-vlog95.list +++ b/ivtest/regress-vlog95.list @@ -372,6 +372,7 @@ sv_class_empty_item CE,-g2009 ivltests sv_class_extends_scoped CE,-g2009 ivltests sv_class_localparam CE,-g2009 ivltests sv_class_new_init CE,-g2009 ivltests +sv_class_in_module_decl CE,-g2009 ivltests sv_end_label CE,-g2009 ivltests # Also generate sv_foreach2 CE,-g2009,-pallowsigned=1 ivltests sv_foreach3 CE,-g2009 ivltests