From 252174d15a27aa9ce4821e3afed6b52f8832fb69 Mon Sep 17 00:00:00 2001 From: Lars-Peter Clausen Date: Wed, 23 Mar 2022 10:15:37 +0100 Subject: [PATCH] Add additional regression tests for typedef overwrites Check that it is possible to create a typedef of an array type that shadows an existing typedef in a higher level scope. Also check that it is possible to create a typedef in a class scope that shadows an exiting typedef in a higher level scope. Signed-off-by: Lars-Peter Clausen --- ...sv_typedef_scope.v => sv_typedef_scope1.v} | 0 ivtest/ivltests/sv_typedef_scope2.v | 24 +++++++++++++++ ivtest/ivltests/sv_typedef_scope3.v | 30 +++++++++++++++++++ ivtest/regress-sv.list | 4 ++- ivtest/regress-vlog95.list | 1 + 5 files changed, 58 insertions(+), 1 deletion(-) rename ivtest/ivltests/{sv_typedef_scope.v => sv_typedef_scope1.v} (100%) create mode 100644 ivtest/ivltests/sv_typedef_scope2.v create mode 100644 ivtest/ivltests/sv_typedef_scope3.v diff --git a/ivtest/ivltests/sv_typedef_scope.v b/ivtest/ivltests/sv_typedef_scope1.v similarity index 100% rename from ivtest/ivltests/sv_typedef_scope.v rename to ivtest/ivltests/sv_typedef_scope1.v diff --git a/ivtest/ivltests/sv_typedef_scope2.v b/ivtest/ivltests/sv_typedef_scope2.v new file mode 100644 index 000000000..ec26f5727 --- /dev/null +++ b/ivtest/ivltests/sv_typedef_scope2.v @@ -0,0 +1,24 @@ +// Check that it is possible to overwrite a type identifier declared in a higher +// level scope. Check that this works if the new type is an array type. + +typedef logic [3:0] T; +T x; + +module test; + + typedef logic [7:0] T[1:0]; + T y; + + initial begin + y[0] = 8'hff; + y[1] = 8'hfe; + + if ($bits(T) == 16 && $size(x) == 4 && $size(y) == 2 && + y[0] == 8'hff && y[1] == 8'hfe) begin + $display("PASSED"); + end else begin + $display("FAILED"); + end + end + +endmodule diff --git a/ivtest/ivltests/sv_typedef_scope3.v b/ivtest/ivltests/sv_typedef_scope3.v new file mode 100644 index 000000000..d036d4e4a --- /dev/null +++ b/ivtest/ivltests/sv_typedef_scope3.v @@ -0,0 +1,30 @@ +// Check that it is possible to overwrite a type identifier declared in a higher +// level scope. Check that this works when the new type is declared in a class. + +typedef logic [3:0] T; +T x; + +module test; + + class C; + typedef logic [7:0] T; + T y; + + task t; + y = 8'hff; + if ($bits(x) == 4 && $bits(y) == 8 && y == 8'hff) begin + $display("PASSED"); + end else begin + $display("FAILED"); + end + endtask + endclass + + C c; + + initial begin + c = new; + c.t(); + end + +endmodule diff --git a/ivtest/regress-sv.list b/ivtest/regress-sv.list index 70e7b90c5..ea4ad8398 100644 --- a/ivtest/regress-sv.list +++ b/ivtest/regress-sv.list @@ -568,7 +568,9 @@ sv_timeunit_prec_fail2 CE,-g2009,-u,\ ./ivltests/sv_timeunit_prec_fail2a.v,\ ./ivltests/sv_timeunit_prec_fail2b.v,\ ./ivltests/sv_timeunit_prec_fail2c.v, ivltests gold=sv_timeunit_prec_fail2.gold -sv_typedef_scope normal,-g2009 ivltests +sv_typedef_scope1 normal,-g2009 ivltests +sv_typedef_scope2 normal,-g2009 ivltests +sv_typedef_scope3 normal,-g2009 ivltests sv_union1 normal,-g2009 ivltests sv_union1b normal,-g2009 ivltests sv_union2 normal,-g2009 ivltests diff --git a/ivtest/regress-vlog95.list b/ivtest/regress-vlog95.list index 89af38b69..9a789eaf3 100644 --- a/ivtest/regress-vlog95.list +++ b/ivtest/regress-vlog95.list @@ -387,6 +387,7 @@ sv_port_default7 CE,-g2009,-pallowsigned=1 ivltests sv_port_default8 CE,-g2009,-pallowsigned=1 ivltests sv_port_default9 CE,-g2009 ivltests sv_root_class CE,-g2009 ivltests +sv_typedef_scope3 CE,-g2009 ivltests sv_unit2b CE,-g2009 ivltests sv_unit3b CE,-g2009 ivltests sv_unit4b CE,-g2009 ivltests