Add regression tests for continuous array assign compatibility

Check various different scenarios for array compatibility in continuous
array assign. Both testing cases that should work and cases that should
fail.

Signed-off-by: Lars-Peter Clausen <lars@metafoo.de>
This commit is contained in:
Lars-Peter Clausen 2022-10-15 15:40:09 +02:00
parent 5ec72f4cc8
commit 4ef5b02bcd
18 changed files with 271 additions and 0 deletions

View File

@ -0,0 +1,14 @@
// Check that continuous assignment of two compatible arrays is supported
module test;
wire [1:0] x[1:0];
wire [1:0] y[1:0];
assign x = y;
initial begin
$display("PASSED");
end
endmodule

View File

@ -0,0 +1,16 @@
// Check that continuous assignment of two compatible arrays is supported, even
// if the upper and lower bounds of the arrays are not identical, as long as the
// size is the same.
module test;
wire [1:0] x[1:0];
wire [1:0] y[2:1];
assign x = y;
initial begin
$display("PASSED");
end
endmodule

View File

@ -0,0 +1,15 @@
// Check that continuous assignment of two compatible arrays is supported, even
// if the element types are not identical, but just equivalent.
module test;
wire [1:0] x[1:0];
wire [2:1] y[1:0];
assign x = y;
initial begin
$display("PASSED");
end
endmodule

View File

@ -0,0 +1,16 @@
// Check that continuous assignment of two compatible arrays is supported, even
// if the element types are not identical and one is a built-in integer and the
// other a equivalent packed type.
module test;
wire signed [31:0] x[1:0];
wire integer y[1:0];
assign x = y;
initial begin
$display("PASSED");
end
endmodule

View File

@ -0,0 +1,16 @@
// Check that continuous assignment of two compatible arrays is supported, even
// if the element types have different number of dimensions, but have the same
// packed width.
module test;
wire [3:0] x[1:0];
wire [1:0][1:0] y[1:0];
assign x = y;
initial begin
$display("PASSED");
end
endmodule

View File

@ -0,0 +1,15 @@
// Check that it is an error if the element type is not the same in a
// continuous array assignment.
module test;
wire [3:0] x[1:0];
reg [1:0] y[1:0];
assign x = y;
initial begin
$display("FAILED");
end
endmodule

View File

@ -0,0 +1,18 @@
// Check that it is an error trying to continuously assign an unpacked array
// with an enum element type to another unpacked array with an element type that
// is not the same enum type, even if the two element types are the same size.
module test;
wire integer x[1:0];
enum integer {
A
} y[1:0];
assign x = y;
initial begin
$display("FAILED");
end
endmodule

View File

@ -0,0 +1,18 @@
// Check that it is an error to continuously assign an unpacked array with an
// enum element type if the other unpacked array element type is not the same
// enum type, even if the two element types are the same size.
module test;
wire enum integer {
A
} x[1:0];
integer y[1:0];
assign x = y;
initial begin
$display("FAILED");
end
endmodule

View File

@ -0,0 +1,15 @@
// Check that it is an error if the array size is not the same in a continuous
// unpacked array assignment.
module test;
wire [1:0] x[2:0];
reg [1:0] y[1:0];
assign x = y;
initial begin
$display("FAILED");
end
endmodule

View File

@ -0,0 +1,16 @@
// Check that it is an error if the number of unpacked dimensions do not match
// in an continuous array assignment, even if the canonical size of the array is
// the same.
module test;
wire [1:0] x[1:0][1:0];
reg [1:0] y[3:0];
assign x = y;
initial begin
$display("FAILED");
end
endmodule

View File

@ -0,0 +1,16 @@
// Check that it is an error if the element type is not the same in a
// continuous array assignment, even if the difference is just 2-state vs.
// 4-state.
module test;
wire [1:0] x[1:0];
bit [1:0] y[1:0];
assign x = y;
initial begin
$display("FAILED");
end
endmodule

View File

@ -0,0 +1,16 @@
// Check that it is an error if the element type is not the same in a
// continuous array assignment, even if one of the types is a packed type and
// the other is a real type.
module test;
wire [1:0] x[1:0];
real [1:0] y[1:0];
assign x = y;
initial begin
$display("FAILED");
end
endmodule

View File

@ -0,0 +1,14 @@
// Check that it is an error trying to continuously assign a scalar expression
// to a unpacked array.
module test;
wire [1:0] x[1:0];
assign x = 1'b1 + 1'b1;
initial begin
$display("FAILED");
end
endmodule

View File

@ -0,0 +1,15 @@
// Check that it is an error trying to continuously assign a scalar variable to
// an unpacked array.
module test;
wire [1:0] x[1:0];
reg [1:0] y;
assign x = y;
initial begin
$display("FAILED");
end
endmodule

View File

@ -0,0 +1,15 @@
// Check that it is an error trying to continuously assign a scalar net to an
// unpacked array.
module test;
wire a[1:0];
wire x;
assign a = x;
initial begin
$display("FAILED");
end
endmodule

View File

@ -0,0 +1,15 @@
// Check that it is an error trying to continuously assign an element of an
// unpacked array to another unpacked array as a whole.
module test;
wire a[1:0];
wire x[1:0];
assign a = x[0];
initial begin
$display("FAILED");
end
endmodule

View File

@ -500,6 +500,22 @@ sv_assign_pattern_func normal,-g2005-sv ivltests
sv_assign_pattern_op normal,-g2005-sv ivltests
sv_assign_pattern_part normal,-g2005-sv ivltests
sv_array_assign_pattern2 normal,-g2009 ivltests
sv_array_cassign1 normal,-g2005-sv ivltests
sv_array_cassign2 normal,-g2005-sv ivltests
sv_array_cassign3 normal,-g2005-sv ivltests
sv_array_cassign4 normal,-g2005-sv ivltests
sv_array_cassign5 normal,-g2005-sv ivltests
sv_array_cassign_fail1 CE,-g2005-sv ivltests
sv_array_cassign_fail2 CE,-g2005-sv ivltests
sv_array_cassign_fail3 CE,-g2005-sv ivltests
sv_array_cassign_fail4 CE,-g2005-sv ivltests
sv_array_cassign_fail5 CE,-g2005-sv ivltests
sv_array_cassign_fail6 CE,-g2005-sv ivltests
sv_array_cassign_fail7 CE,-g2005-sv ivltests
sv_array_cassign_fail8 CE,-g2005-sv ivltests
sv_array_cassign_fail9 CE,-g2005-sv ivltests
sv_array_cassign_fail10 CE,-g2005-sv ivltests
sv_array_cassign_fail11 CE,-g2005-sv ivltests
sv_array_query normal,-g2005-sv ivltests
sv_cast_integer normal,-g2005-sv ivltests
sv_cast_integer2 normal,-g2005-sv ivltests

View File

@ -257,6 +257,11 @@ scan-invalid CE ivltests
sel_rval_bit_ob CE ivltests
sel_rval_part_ob CE ivltests
signed_net_display CE,-pallowsigned=1 ivltests
sv_array_cassign1 CE,-g2005-sv ivltests
sv_array_cassign2 CE,-g2005-sv ivltests
sv_array_cassign3 CE,-g2005-sv ivltests
sv_array_cassign4 CE,-g2005-sv ivltests
sv_array_cassign5 CE,-g2005-sv ivltests
sv_unpacked_port CE,-g2009 ivltests
sv_unpacked_port2 CE,-g2009,-pallowsigned=1 ivltests
sv_unpacked_wire CE,-g2009 ivltests