Add regression tests for restricted type parameters
Check that enum, struct, union and class restricted type parameters are accepted. Check that mismatched default values and overrides are rejected. Signed-off-by: Lars-Peter Clausen <lars@metafoo.de>
This commit is contained in:
parent
46c0526dab
commit
08479888b1
|
|
@ -0,0 +1,35 @@
|
|||
// Check that restricted class type parameter defaults are supported.
|
||||
|
||||
class C0;
|
||||
bit [7:0] value;
|
||||
endclass
|
||||
|
||||
module M #(
|
||||
parameter type class T = C0
|
||||
);
|
||||
T x;
|
||||
endmodule
|
||||
|
||||
module test;
|
||||
|
||||
`define check(val, exp) \
|
||||
if (val !== exp) begin \
|
||||
$display("FAILED(%0d). '%s' expected %0d, got %0d", `__LINE__, `"val`", exp, val); \
|
||||
failed = 1'b1; \
|
||||
end
|
||||
|
||||
bit failed = 1'b0;
|
||||
|
||||
M i_m();
|
||||
|
||||
initial begin
|
||||
i_m.x = new;
|
||||
|
||||
`check($bits(i_m.x.value), 8)
|
||||
|
||||
if (!failed) begin
|
||||
$display("PASSED");
|
||||
end
|
||||
end
|
||||
|
||||
endmodule
|
||||
|
|
@ -0,0 +1,41 @@
|
|||
// Check that restricted class type parameter overrides are supported.
|
||||
|
||||
class C0;
|
||||
bit [7:0] value;
|
||||
endclass
|
||||
|
||||
class C1;
|
||||
bit [15:0] value;
|
||||
endclass
|
||||
|
||||
module M #(
|
||||
parameter type class T = C0
|
||||
);
|
||||
T x;
|
||||
endmodule
|
||||
|
||||
module test;
|
||||
|
||||
`define check(val, exp) \
|
||||
if (val !== exp) begin \
|
||||
$display("FAILED(%0d). '%s' expected %0d, got %0d", `__LINE__, `"val`", exp, val); \
|
||||
failed = 1'b1; \
|
||||
end
|
||||
|
||||
bit failed = 1'b0;
|
||||
|
||||
M #(
|
||||
.T(C1)
|
||||
) i_m();
|
||||
|
||||
initial begin
|
||||
i_m.x = new;
|
||||
|
||||
`check($bits(i_m.x.value), 16)
|
||||
|
||||
if (!failed) begin
|
||||
$display("PASSED");
|
||||
end
|
||||
end
|
||||
|
||||
endmodule
|
||||
|
|
@ -0,0 +1,11 @@
|
|||
// Check that a class restricted type parameter rejects non-class defaults.
|
||||
|
||||
module test #(
|
||||
parameter type class T = int
|
||||
);
|
||||
|
||||
initial begin
|
||||
$display("FAILED");
|
||||
end
|
||||
|
||||
endmodule
|
||||
|
|
@ -0,0 +1,21 @@
|
|||
// Check that a class restricted type parameter rejects non-class overrides.
|
||||
|
||||
class class_t;
|
||||
endclass
|
||||
|
||||
module M #(
|
||||
parameter type class T = class_t
|
||||
);
|
||||
endmodule
|
||||
|
||||
module test;
|
||||
|
||||
M #(
|
||||
.T(int)
|
||||
) i_m();
|
||||
|
||||
initial begin
|
||||
$display("FAILED");
|
||||
end
|
||||
|
||||
endmodule
|
||||
|
|
@ -0,0 +1,33 @@
|
|||
// Check that restricted enum type parameter defaults are supported.
|
||||
|
||||
typedef enum bit [2:0] {
|
||||
A0, B0
|
||||
} T0;
|
||||
|
||||
module M #(
|
||||
parameter type enum T = T0
|
||||
);
|
||||
T x;
|
||||
endmodule
|
||||
|
||||
module test;
|
||||
|
||||
`define check(val, exp) \
|
||||
if (val !== exp) begin \
|
||||
$display("FAILED(%0d). '%s' expected %0d, got %0d", `__LINE__, `"val`", exp, val); \
|
||||
failed = 1'b1; \
|
||||
end
|
||||
|
||||
bit failed = 1'b0;
|
||||
|
||||
M i_m();
|
||||
|
||||
initial begin
|
||||
`check($bits(i_m.x), $bits(T0))
|
||||
|
||||
if (!failed) begin
|
||||
$display("PASSED");
|
||||
end
|
||||
end
|
||||
|
||||
endmodule
|
||||
|
|
@ -0,0 +1,39 @@
|
|||
// Check that restricted enum type parameter overrides are supported.
|
||||
|
||||
typedef enum bit [2:0] {
|
||||
A0, B0
|
||||
} T0;
|
||||
|
||||
typedef enum bit [3:0] {
|
||||
A1, B1
|
||||
} T1;
|
||||
|
||||
module M #(
|
||||
parameter type enum T = T0
|
||||
);
|
||||
T x;
|
||||
endmodule
|
||||
|
||||
module test;
|
||||
|
||||
`define check(val, exp) \
|
||||
if (val !== exp) begin \
|
||||
$display("FAILED(%0d). '%s' expected %0d, got %0d", `__LINE__, `"val`", exp, val); \
|
||||
failed = 1'b1; \
|
||||
end
|
||||
|
||||
bit failed = 1'b0;
|
||||
|
||||
M #(
|
||||
.T(T1)
|
||||
) i_m();
|
||||
|
||||
initial begin
|
||||
`check($bits(i_m.x), $bits(T1))
|
||||
|
||||
if (!failed) begin
|
||||
$display("PASSED");
|
||||
end
|
||||
end
|
||||
|
||||
endmodule
|
||||
|
|
@ -0,0 +1,11 @@
|
|||
// Check that an enum restricted type parameter rejects non-enum defaults.
|
||||
|
||||
module test #(
|
||||
parameter type enum T = int
|
||||
);
|
||||
|
||||
initial begin
|
||||
$display("FAILED");
|
||||
end
|
||||
|
||||
endmodule
|
||||
|
|
@ -0,0 +1,22 @@
|
|||
// Check that an enum restricted type parameter rejects non-enum overrides.
|
||||
|
||||
typedef enum bit {
|
||||
ENUM_VALUE
|
||||
} enum_t;
|
||||
|
||||
module M #(
|
||||
parameter type enum T = enum_t
|
||||
);
|
||||
endmodule
|
||||
|
||||
module test;
|
||||
|
||||
M #(
|
||||
.T(int)
|
||||
) i_m();
|
||||
|
||||
initial begin
|
||||
$display("FAILED");
|
||||
end
|
||||
|
||||
endmodule
|
||||
|
|
@ -0,0 +1,33 @@
|
|||
// Check that restricted struct type parameter defaults are supported.
|
||||
|
||||
typedef struct packed {
|
||||
logic [3:0] x;
|
||||
} T0;
|
||||
|
||||
module M #(
|
||||
parameter type struct T = T0
|
||||
);
|
||||
T x;
|
||||
endmodule
|
||||
|
||||
module test;
|
||||
|
||||
`define check(val, exp) \
|
||||
if (val !== exp) begin \
|
||||
$display("FAILED(%0d). '%s' expected %0d, got %0d", `__LINE__, `"val`", exp, val); \
|
||||
failed = 1'b1; \
|
||||
end
|
||||
|
||||
bit failed = 1'b0;
|
||||
|
||||
M i_m();
|
||||
|
||||
initial begin
|
||||
`check($bits(i_m.x), $bits(T0))
|
||||
|
||||
if (!failed) begin
|
||||
$display("PASSED");
|
||||
end
|
||||
end
|
||||
|
||||
endmodule
|
||||
|
|
@ -0,0 +1,39 @@
|
|||
// Check that restricted struct type parameter overrides are supported.
|
||||
|
||||
typedef struct packed {
|
||||
logic [3:0] x;
|
||||
} T0;
|
||||
|
||||
typedef struct packed {
|
||||
logic [7:0] x;
|
||||
} T1;
|
||||
|
||||
module M #(
|
||||
parameter type struct T = T0
|
||||
);
|
||||
T x;
|
||||
endmodule
|
||||
|
||||
module test;
|
||||
|
||||
`define check(val, exp) \
|
||||
if (val !== exp) begin \
|
||||
$display("FAILED(%0d). '%s' expected %0d, got %0d", `__LINE__, `"val`", exp, val); \
|
||||
failed = 1'b1; \
|
||||
end
|
||||
|
||||
bit failed = 1'b0;
|
||||
|
||||
M #(
|
||||
.T(T1)
|
||||
) i_m();
|
||||
|
||||
initial begin
|
||||
`check($bits(i_m.x), $bits(T1))
|
||||
|
||||
if (!failed) begin
|
||||
$display("PASSED");
|
||||
end
|
||||
end
|
||||
|
||||
endmodule
|
||||
|
|
@ -0,0 +1,16 @@
|
|||
// Check that a struct restricted type parameter rejects non-struct defaults.
|
||||
|
||||
typedef union packed {
|
||||
logic [3:0] value;
|
||||
logic [3:0] other;
|
||||
} union_t;
|
||||
|
||||
module test #(
|
||||
parameter type struct T = union_t
|
||||
);
|
||||
|
||||
initial begin
|
||||
$display("FAILED");
|
||||
end
|
||||
|
||||
endmodule
|
||||
|
|
@ -0,0 +1,27 @@
|
|||
// Check that a struct restricted type parameter rejects non-struct overrides.
|
||||
|
||||
typedef struct packed {
|
||||
logic [3:0] value;
|
||||
} struct_t;
|
||||
|
||||
typedef union packed {
|
||||
logic [3:0] value;
|
||||
logic [3:0] other;
|
||||
} union_t;
|
||||
|
||||
module M #(
|
||||
parameter type struct T = struct_t
|
||||
);
|
||||
endmodule
|
||||
|
||||
module test;
|
||||
|
||||
M #(
|
||||
.T(union_t)
|
||||
) i_m();
|
||||
|
||||
initial begin
|
||||
$display("FAILED");
|
||||
end
|
||||
|
||||
endmodule
|
||||
|
|
@ -0,0 +1,34 @@
|
|||
// Check that restricted union type parameter defaults are supported.
|
||||
|
||||
typedef union packed {
|
||||
logic [3:0] x;
|
||||
logic [3:0] y;
|
||||
} T0;
|
||||
|
||||
module M #(
|
||||
parameter type union T = T0
|
||||
);
|
||||
T x;
|
||||
endmodule
|
||||
|
||||
module test;
|
||||
|
||||
`define check(val, exp) \
|
||||
if (val !== exp) begin \
|
||||
$display("FAILED(%0d). '%s' expected %0d, got %0d", `__LINE__, `"val`", exp, val); \
|
||||
failed = 1'b1; \
|
||||
end
|
||||
|
||||
bit failed = 1'b0;
|
||||
|
||||
M i_m();
|
||||
|
||||
initial begin
|
||||
`check($bits(i_m.x), $bits(T0))
|
||||
|
||||
if (!failed) begin
|
||||
$display("PASSED");
|
||||
end
|
||||
end
|
||||
|
||||
endmodule
|
||||
|
|
@ -0,0 +1,41 @@
|
|||
// Check that restricted union type parameter overrides are supported.
|
||||
|
||||
typedef union packed {
|
||||
logic [3:0] x;
|
||||
logic [3:0] y;
|
||||
} T0;
|
||||
|
||||
typedef union packed {
|
||||
logic [7:0] x;
|
||||
logic [7:0] y;
|
||||
} T1;
|
||||
|
||||
module M #(
|
||||
parameter type union T = T0
|
||||
);
|
||||
T x;
|
||||
endmodule
|
||||
|
||||
module test;
|
||||
|
||||
`define check(val, exp) \
|
||||
if (val !== exp) begin \
|
||||
$display("FAILED(%0d). '%s' expected %0d, got %0d", `__LINE__, `"val`", exp, val); \
|
||||
failed = 1'b1; \
|
||||
end
|
||||
|
||||
bit failed = 1'b0;
|
||||
|
||||
M #(
|
||||
.T(T1)
|
||||
) i_m();
|
||||
|
||||
initial begin
|
||||
`check($bits(i_m.x), $bits(T1))
|
||||
|
||||
if (!failed) begin
|
||||
$display("PASSED");
|
||||
end
|
||||
end
|
||||
|
||||
endmodule
|
||||
|
|
@ -0,0 +1,15 @@
|
|||
// Check that a union restricted type parameter rejects non-union defaults.
|
||||
|
||||
typedef struct packed {
|
||||
logic [3:0] value;
|
||||
} struct_t;
|
||||
|
||||
module test #(
|
||||
parameter type union T = struct_t
|
||||
);
|
||||
|
||||
initial begin
|
||||
$display("FAILED");
|
||||
end
|
||||
|
||||
endmodule
|
||||
|
|
@ -0,0 +1,27 @@
|
|||
// Check that a union restricted type parameter rejects non-union overrides.
|
||||
|
||||
typedef struct packed {
|
||||
logic [3:0] value;
|
||||
} struct_t;
|
||||
|
||||
typedef union packed {
|
||||
logic [3:0] value;
|
||||
logic [3:0] other;
|
||||
} union_t;
|
||||
|
||||
module M #(
|
||||
parameter type union T = union_t
|
||||
);
|
||||
endmodule
|
||||
|
||||
module test;
|
||||
|
||||
M #(
|
||||
.T(struct_t)
|
||||
) i_m();
|
||||
|
||||
initial begin
|
||||
$display("FAILED");
|
||||
end
|
||||
|
||||
endmodule
|
||||
|
|
@ -342,6 +342,22 @@ sv_queue_assign_op vvp_tests/sv_queue_assign_op.json
|
|||
sv_soft_packed_union vvp_tests/sv_soft_packed_union.json
|
||||
sv_soft_packed_union_fail1 vvp_tests/sv_soft_packed_union_fail1.json
|
||||
sv_super_member_fail vvp_tests/sv_super_member_fail.json
|
||||
sv_type_param_restrict_class1 vvp_tests/sv_type_param_restrict_class1.json
|
||||
sv_type_param_restrict_class2 vvp_tests/sv_type_param_restrict_class2.json
|
||||
sv_type_param_restrict_class_fail1 vvp_tests/sv_type_param_restrict_class_fail1.json
|
||||
sv_type_param_restrict_class_fail2 vvp_tests/sv_type_param_restrict_class_fail2.json
|
||||
sv_type_param_restrict_enum1 vvp_tests/sv_type_param_restrict_enum1.json
|
||||
sv_type_param_restrict_enum2 vvp_tests/sv_type_param_restrict_enum2.json
|
||||
sv_type_param_restrict_enum_fail1 vvp_tests/sv_type_param_restrict_enum_fail1.json
|
||||
sv_type_param_restrict_enum_fail2 vvp_tests/sv_type_param_restrict_enum_fail2.json
|
||||
sv_type_param_restrict_struct1 vvp_tests/sv_type_param_restrict_struct1.json
|
||||
sv_type_param_restrict_struct2 vvp_tests/sv_type_param_restrict_struct2.json
|
||||
sv_type_param_restrict_struct_fail1 vvp_tests/sv_type_param_restrict_struct_fail1.json
|
||||
sv_type_param_restrict_struct_fail2 vvp_tests/sv_type_param_restrict_struct_fail2.json
|
||||
sv_type_param_restrict_union1 vvp_tests/sv_type_param_restrict_union1.json
|
||||
sv_type_param_restrict_union2 vvp_tests/sv_type_param_restrict_union2.json
|
||||
sv_type_param_restrict_union_fail1 vvp_tests/sv_type_param_restrict_union_fail1.json
|
||||
sv_type_param_restrict_union_fail2 vvp_tests/sv_type_param_restrict_union_fail2.json
|
||||
sv_wildcard_import8 vvp_tests/sv_wildcard_import8.json
|
||||
sdf_header vvp_tests/sdf_header.json
|
||||
task_return1 vvp_tests/task_return1.json
|
||||
|
|
|
|||
|
|
@ -0,0 +1,9 @@
|
|||
{
|
||||
"type" : "normal",
|
||||
"source" : "sv_type_param_restrict_class1.v",
|
||||
"iverilog-args" : [ "-g2023" ],
|
||||
"vlog95" : {
|
||||
"__comment" : "Classes are not supported",
|
||||
"type" : "CE"
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,9 @@
|
|||
{
|
||||
"type" : "normal",
|
||||
"source" : "sv_type_param_restrict_class2.v",
|
||||
"iverilog-args" : [ "-g2023" ],
|
||||
"vlog95" : {
|
||||
"__comment" : "Classes are not supported",
|
||||
"type" : "CE"
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,5 @@
|
|||
{
|
||||
"type" : "CE",
|
||||
"source" : "sv_type_param_restrict_class_fail1.v",
|
||||
"iverilog-args" : [ "-g2023" ]
|
||||
}
|
||||
|
|
@ -0,0 +1,5 @@
|
|||
{
|
||||
"type" : "CE",
|
||||
"source" : "sv_type_param_restrict_class_fail2.v",
|
||||
"iverilog-args" : [ "-g2023" ]
|
||||
}
|
||||
|
|
@ -0,0 +1,5 @@
|
|||
{
|
||||
"type" : "normal",
|
||||
"source" : "sv_type_param_restrict_enum1.v",
|
||||
"iverilog-args" : [ "-g2023" ]
|
||||
}
|
||||
|
|
@ -0,0 +1,5 @@
|
|||
{
|
||||
"type" : "normal",
|
||||
"source" : "sv_type_param_restrict_enum2.v",
|
||||
"iverilog-args" : [ "-g2023" ]
|
||||
}
|
||||
|
|
@ -0,0 +1,5 @@
|
|||
{
|
||||
"type" : "CE",
|
||||
"source" : "sv_type_param_restrict_enum_fail1.v",
|
||||
"iverilog-args" : [ "-g2023" ]
|
||||
}
|
||||
|
|
@ -0,0 +1,5 @@
|
|||
{
|
||||
"type" : "CE",
|
||||
"source" : "sv_type_param_restrict_enum_fail2.v",
|
||||
"iverilog-args" : [ "-g2023" ]
|
||||
}
|
||||
|
|
@ -0,0 +1,5 @@
|
|||
{
|
||||
"type" : "normal",
|
||||
"source" : "sv_type_param_restrict_struct1.v",
|
||||
"iverilog-args" : [ "-g2023" ]
|
||||
}
|
||||
|
|
@ -0,0 +1,5 @@
|
|||
{
|
||||
"type" : "normal",
|
||||
"source" : "sv_type_param_restrict_struct2.v",
|
||||
"iverilog-args" : [ "-g2023" ]
|
||||
}
|
||||
|
|
@ -0,0 +1,5 @@
|
|||
{
|
||||
"type" : "CE",
|
||||
"source" : "sv_type_param_restrict_struct_fail1.v",
|
||||
"iverilog-args" : [ "-g2023" ]
|
||||
}
|
||||
|
|
@ -0,0 +1,5 @@
|
|||
{
|
||||
"type" : "CE",
|
||||
"source" : "sv_type_param_restrict_struct_fail2.v",
|
||||
"iverilog-args" : [ "-g2023" ]
|
||||
}
|
||||
|
|
@ -0,0 +1,5 @@
|
|||
{
|
||||
"type" : "normal",
|
||||
"source" : "sv_type_param_restrict_union1.v",
|
||||
"iverilog-args" : [ "-g2023" ]
|
||||
}
|
||||
|
|
@ -0,0 +1,5 @@
|
|||
{
|
||||
"type" : "normal",
|
||||
"source" : "sv_type_param_restrict_union2.v",
|
||||
"iverilog-args" : [ "-g2023" ]
|
||||
}
|
||||
|
|
@ -0,0 +1,5 @@
|
|||
{
|
||||
"type" : "CE",
|
||||
"source" : "sv_type_param_restrict_union_fail1.v",
|
||||
"iverilog-args" : [ "-g2023" ]
|
||||
}
|
||||
|
|
@ -0,0 +1,5 @@
|
|||
{
|
||||
"type" : "CE",
|
||||
"source" : "sv_type_param_restrict_union_fail2.v",
|
||||
"iverilog-args" : [ "-g2023" ]
|
||||
}
|
||||
Loading…
Reference in New Issue