Add regression tests for scoped type identifier references
Check that it is possible to have scoped reference to a type identifier in a package. * As part of variable declarations * As an argument to a system function * As the type in a type cast Signed-off-by: Lars-Peter Clausen <lars@metafoo.de>
This commit is contained in:
parent
998d0c655d
commit
b9bc06951a
|
|
@ -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
|
||||
|
|
@ -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
|
||||
|
|
@ -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
|
||||
|
|
@ -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
|
||||
|
|
@ -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
|
||||
|
|
@ -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
|
||||
|
|
@ -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
|
||||
|
|
@ -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
|
||||
|
|
|
|||
|
|
@ -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
|
||||
|
|
|
|||
Loading…
Reference in New Issue