From 998d0c655d53111fcc8d7fcae8dd2242c1ecdc56 Mon Sep 17 00:00:00 2001 From: Lars-Peter Clausen Date: Sun, 17 Apr 2022 14:00:21 +0200 Subject: [PATCH] Add regression test for chained type definitions Check that chained type definitions declared in different scopes are handled correctly. Signed-off-by: Lars-Peter Clausen --- ivtest/ivltests/sv_typedef_chained.v | 51 ++++++++++++++++++++++++++++ ivtest/regress-sv.list | 1 + 2 files changed, 52 insertions(+) create mode 100644 ivtest/ivltests/sv_typedef_chained.v diff --git a/ivtest/ivltests/sv_typedef_chained.v b/ivtest/ivltests/sv_typedef_chained.v new file mode 100644 index 000000000..d62399cec --- /dev/null +++ b/ivtest/ivltests/sv_typedef_chained.v @@ -0,0 +1,51 @@ +// Check that chained type definitions declared in different scopes work +// correctly. + +package P1; + localparam A = 8; + typedef logic [A-1:0] T; +endpackage + +package P2; + localparam A = 4; + typedef P1::T T; +endpackage + +bit failed = 1'b0; + +`define check(expr, val) \ + if (expr !== val) begin \ + $display("FAILED: %s, expected %0d, got %0d", `"expr`", val, expr); \ + failed = 1'b1; \ + end + +module test; + localparam A = 2; + + typedef P2::T T; + + T x; + P1::T y; + P2::T z; + + initial begin + x = 8'hff; + y = 8'hff; + z = 8'hff; + + `check(x, 8'hff); + `check($bits(T), 8); + `check($bits(x), 8); + `check(y, 8'hff); + `check($bits(y), 8); + `check($bits(P1::T), 8); + `check(z, 8'hff); + `check($bits(z), 8); + `check($bits(P2::T), 8); + + if (!failed) begin + $display("PASSED"); + end + end + +endmodule diff --git a/ivtest/regress-sv.list b/ivtest/regress-sv.list index f57aba917..930cd8487 100644 --- a/ivtest/regress-sv.list +++ b/ivtest/regress-sv.list @@ -704,6 +704,7 @@ sv_typedef_array_base1 normal,-g2009 ivltests sv_typedef_array_base2 normal,-g2009 ivltests sv_typedef_array_base3 normal,-g2009 ivltests sv_typedef_array_base4 normal,-g2009 ivltests +sv_typedef_chained normal,-g2009 ivltests sv_typedef_darray_base1 normal,-g2009 ivltests sv_typedef_darray_base2 normal,-g2009 ivltests sv_typedef_darray_base3 normal,-g2009 ivltests