From 159345ca960de5700f31f08ae183bd384b140a37 Mon Sep 17 00:00:00 2001 From: Lars-Peter Clausen Date: Sat, 1 Oct 2022 11:21:44 +0200 Subject: [PATCH] Add regression tests for package scope identifiers Check that it is possible to reference a package scoped identifier that has the same name as a local identifier, but is a different kind of identifier. * A variable or function identifier from a package scope if it is a type identifier in the current scope * A type identifier from a package scope if it is a non-type identifier in the current scope Signed-off-by: Lars-Peter Clausen --- ivtest/ivltests/sv_ps_function4.v | 30 ++++++++++++++++++++++++++++++ ivtest/ivltests/sv_ps_type1.v | 26 ++++++++++++++++++++++++++ ivtest/ivltests/sv_ps_var1.v | 27 +++++++++++++++++++++++++++ ivtest/regress-sv.list | 3 +++ 4 files changed, 86 insertions(+) create mode 100644 ivtest/ivltests/sv_ps_function4.v create mode 100644 ivtest/ivltests/sv_ps_type1.v create mode 100644 ivtest/ivltests/sv_ps_var1.v diff --git a/ivtest/ivltests/sv_ps_function4.v b/ivtest/ivltests/sv_ps_function4.v new file mode 100644 index 000000000..f17a7349c --- /dev/null +++ b/ivtest/ivltests/sv_ps_function4.v @@ -0,0 +1,30 @@ +// Check that it is possible to reference a package scoped function, even if +// there is a type identifier of the same name in the current scope. + +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 + +package P; + function integer T(integer x); + return x + 1; + endfunction +endpackage + +module test; + typedef integer T; + initial begin + integer x; + + x = P::T(10); + `check(x, 11) + + if (!failed) begin + $display("PASSED"); + end + end +endmodule diff --git a/ivtest/ivltests/sv_ps_type1.v b/ivtest/ivltests/sv_ps_type1.v new file mode 100644 index 000000000..8c7794544 --- /dev/null +++ b/ivtest/ivltests/sv_ps_type1.v @@ -0,0 +1,26 @@ +// Check that it is possible to reference a package scoped type identifier, even if +// there is a identifier of the same name in the current scope. + +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 + +package P; + typedef logic [31:0] T; +endpackage + +module test; + logic T; + initial begin + P::T x; + `check($bits(x), 32) + + if (!failed) begin + $display("PASSED"); + end + end +endmodule diff --git a/ivtest/ivltests/sv_ps_var1.v b/ivtest/ivltests/sv_ps_var1.v new file mode 100644 index 000000000..4e8e9bd04 --- /dev/null +++ b/ivtest/ivltests/sv_ps_var1.v @@ -0,0 +1,27 @@ +// Check that it is possible to reference a package scoped identifier, even if +// there is a type identifier of the same name in the current scope. + +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 + +package P; + integer T = 10; +endpackage + +module test; + typedef integer T; + integer x; + initial begin + x = P::T; + `check(x, 10) + + if (!failed) begin + $display("PASSED"); + end + end +endmodule diff --git a/ivtest/regress-sv.list b/ivtest/regress-sv.list index 9e133585b..14a55b2f6 100644 --- a/ivtest/regress-sv.list +++ b/ivtest/regress-sv.list @@ -618,6 +618,9 @@ sv_port_default14 CE,-g2009 ivltests sv_ps_function1 normal,-g2009 ivltests sv_ps_function2 normal,-g2009 ivltests sv_ps_function3 normal,-g2009 ivltests +sv_ps_function4 normal,-g2009 ivltests +sv_ps_type1 normal,-g2009 ivltests +sv_ps_var1 normal,-g2009 ivltests sv_queue1 normal,-g2009 ivltests sv_queue2 normal,-g2009 ivltests sv_queue3 normal,-g2009 ivltests