diff --git a/ivtest/ivltests/sv_ps_type_cast1.v b/ivtest/ivltests/sv_ps_type_cast1.v new file mode 100644 index 000000000..305b05326 --- /dev/null +++ b/ivtest/ivltests/sv_ps_type_cast1.v @@ -0,0 +1,26 @@ +// Check that it is possible to reference a package scoped type identifier as +// the type in a type cast expression. + +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 integer T; +endpackage + +module test; + integer x; + initial begin + x = P::T'(-1024.123); + `check(x, -1024) + + if (!failed) begin + $display("PASSED"); + end + end +endmodule diff --git a/ivtest/ivltests/sv_ps_type_cast2.v b/ivtest/ivltests/sv_ps_type_cast2.v new file mode 100644 index 000000000..61ea62bb7 --- /dev/null +++ b/ivtest/ivltests/sv_ps_type_cast2.v @@ -0,0 +1,28 @@ +// Check that it is possible to reference a package scoped type identifier as +// the type in a type cast expression, even if there is a identifier of the same +// name in the local 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 integer T; +endpackage + +module test; + localparam T = 2; + integer x; + initial begin + x = P::T'(-1024.123); + `check(x, -1024) + + if (!failed) begin + $display("PASSED"); + end + end +endmodule diff --git a/ivtest/ivltests/sv_ps_type_class1.v b/ivtest/ivltests/sv_ps_type_class1.v new file mode 100644 index 000000000..4742a8c8e --- /dev/null +++ b/ivtest/ivltests/sv_ps_type_class1.v @@ -0,0 +1,39 @@ +// Check that class types declared in a package can be referenced using a scoped +// type identifier. + +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; + + localparam A = 8; + + class C; + logic [A-1:0] x; + + task t; + `check($bits(x), 8) + if (!failed) begin + $display("PASSED"); + end + endtask + endclass + +endpackage + +module test; + + localparam A = 4; + P::C c; + + initial begin + c = new; + c.t(); + end + +endmodule diff --git a/ivtest/ivltests/sv_ps_type_enum1.v b/ivtest/ivltests/sv_ps_type_enum1.v new file mode 100644 index 000000000..4745a218f --- /dev/null +++ b/ivtest/ivltests/sv_ps_type_enum1.v @@ -0,0 +1,38 @@ +// Check that enum types declared in a package can be referenced using a scoped +// type identifier. + +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; + + localparam X = 8; + + typedef enum logic [X-1:0] { + A, B = X + } T; + +endpackage + +module test; + localparam X = 4; + + typedef int T; + + P::T x = P::B; + + initial begin + `check(x, P::B) + `check(x, 8) + `check($bits(x), 8); + if (!failed) begin + $display("PASSED"); + end + end + +endmodule diff --git a/ivtest/ivltests/sv_ps_type_expr1.v b/ivtest/ivltests/sv_ps_type_expr1.v new file mode 100644 index 000000000..7ce97f2f7 --- /dev/null +++ b/ivtest/ivltests/sv_ps_type_expr1.v @@ -0,0 +1,24 @@ +// Check that it is possible to reference a package scoped type identifier in an +// expression. + +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 integer T; +endpackage + +module test; + initial begin + `check($bits(P::T), $bits(integer)) + + if (!failed) begin + $display("PASSED"); + end + end +endmodule diff --git a/ivtest/ivltests/sv_ps_type_expr2.v b/ivtest/ivltests/sv_ps_type_expr2.v new file mode 100644 index 000000000..30ca5b246 --- /dev/null +++ b/ivtest/ivltests/sv_ps_type_expr2.v @@ -0,0 +1,26 @@ +// Check that it is possible to reference a package scoped type identifier in an +// expression, even if there is a non 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; + typedef integer T; +endpackage + +module test; + integer T; + initial begin + `check($bits(P::T), $bits(integer)) + + if (!failed) begin + $display("PASSED"); + end + end +endmodule diff --git a/ivtest/ivltests/sv_ps_type_struct1.v b/ivtest/ivltests/sv_ps_type_struct1.v new file mode 100644 index 000000000..3ec1b545d --- /dev/null +++ b/ivtest/ivltests/sv_ps_type_struct1.v @@ -0,0 +1,40 @@ +// Check that struct types declared in a package can be referenced using a +// scoped type identifier. + +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; + + localparam A = 8; + + typedef struct packed { + logic [A-1:0] x; + } T; + +endpackage + +typedef int T; + +module test; + localparam A = 4; + + typedef int T; + + P::T x; + + initial begin + x = 8'hff; + `check(x, 8'hff) + `check($bits(x), 8) + if (!failed) begin + $display("PASSED"); + end + end + +endmodule diff --git a/ivtest/regress-sv.list b/ivtest/regress-sv.list index 930cd8487..4c8042ba9 100644 --- a/ivtest/regress-sv.list +++ b/ivtest/regress-sv.list @@ -633,6 +633,13 @@ 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_type_cast1 normal,-g2009 ivltests +sv_ps_type_cast2 normal,-g2009 ivltests +sv_ps_type_class1 normal,-g2009 ivltests +sv_ps_type_enum1 normal,-g2009 ivltests +sv_ps_type_expr1 normal,-g2009 ivltests +sv_ps_type_expr2 normal,-g2009 ivltests +sv_ps_type_struct1 normal,-g2009 ivltests sv_ps_var1 normal,-g2009 ivltests sv_queue1 normal,-g2009 ivltests sv_queue2 normal,-g2009 ivltests diff --git a/ivtest/regress-vlog95.list b/ivtest/regress-vlog95.list index 97ad90d58..c4628ebd2 100644 --- a/ivtest/regress-vlog95.list +++ b/ivtest/regress-vlog95.list @@ -437,6 +437,7 @@ sv_port_default6 CE,-g2009,-pallowsigned=1 ivltests sv_port_default7 CE,-g2009,-pallowsigned=1 ivltests sv_port_default8 CE,-g2009,-pallowsigned=1 ivltests sv_port_default9 CE,-g2009 ivltests +sv_ps_type_class1 CE,-g2009 ivltests sv_root_class CE,-g2009 ivltests sv_typedef_scope3 CE,-g2009 ivltests sv_unit2b CE,-g2009 ivltests