Add regression tests for dynamic array/queue type compatibility

Check for various dynamic array and queue types that their type
compatibility is handled correctly.

Signed-off-by: Lars-Peter Clausen <lars@metafoo.de>
This commit is contained in:
Lars-Peter Clausen 2022-10-01 17:40:02 +02:00
parent e897e3ab5f
commit 7896349380
18 changed files with 340 additions and 0 deletions

View File

@ -0,0 +1,28 @@
// Check that dynamic arrays with compatible packed base types can be assigned
// to each other. Even if the element types are not identical.
module test;
typedef bit [31:0] T1;
typedef bit [31:0] T2[];
// For two packed types to be compatible they need to have the same packed
// width, both be 2-state or 4-state and both be either signed or unsigned.
bit [32:1] d1[];
bit [7:0][3:0] d2[];
int unsigned d3[];
T1 d4[];
T2 d5;
initial begin
d1 = new[1];
d2 = d1;
d3 = d2;
d4 = d3;
d5 = d4;
d1 = d5;
$display("PASSED");
end
endmodule

View File

@ -0,0 +1,44 @@
// Check that dynamic arrays with compatible packed base types can be passed as
// task arguments. Even it the element types are not identical.
module test;
typedef logic [31:0] T[];
task t1(logic [31:0] d[]);
d[0] = 1;
endtask
task t2(logic [7:0][3:0] d[]);
d[0] = 1;
endtask
task t3([31:0] d[]);
d[0] = 1;
endtask
task t4(T d);
d[0] = 1;
endtask
// For two packed types to be compatible they need to have the same packed
// width, both be 2-state or 4-state and both be either signed or unsigned.
logic [31:0] d1[];
logic [7:0][3:0] d2[];
initial begin
d1 = new[1];
d2 = new[1];
t1(d1);
t1(d2);
t2(d1);
t2(d2);
t3(d1);
t3(d2);
t4(d1);
t4(d2);
$display("PASSED");
end
endmodule

View File

@ -0,0 +1,15 @@
// Check that it is not possible to assign a dynamic array with a 2-state
// element type to a dynamic array with 4-state element type. Even if they are
// otherwise identical.
module test;
logic [31:0] d1[];
bit [31:0] d2[];
initial begin
d1 = d2;
$dispaly("FAILED");
end
endmodule

View File

@ -0,0 +1,15 @@
// Check that it is not possible to assign a dynamic array with a signed element
// type to a dynamic array with a unsigned element type. Even if they are
// otherwise identical.
module test;
logic [31:0] d1[];
logic signed [31:0] d2[];
initial begin
d1 = d2;
$dispaly("FAILED");
end
endmodule

View File

@ -0,0 +1,14 @@
// Check that it is not possible to assign a dynamic array with different
// element type width.
module test;
int d1[];
shortint d2[];
initial begin
d1 = d2;
$dispaly("FAILED");
end
endmodule

View File

@ -0,0 +1,17 @@
// Check that it is not possible to assign a dynamic array with an enum
// element type to a dynamic array with a packed type. Even if the enum base
// type is the same as the packed type.
module test;
enum logic [31:0] {
A
} d1[];
logic [31:0] d2[];
initial begin
d1 = d2;
$dispaly("FAILED");
end
endmodule

View File

@ -0,0 +1,14 @@
// Check that it is not possible to assign a dynamic array with a real
// element type to a dynamic array with an int element type.
module test;
int d1[];
real d2[];
initial begin
d1 = d2;
$display("FAILED");
end
endmodule

View File

@ -0,0 +1,14 @@
// Check that it is not possible to assign a dynamic array with an int
// element type to a dynamic array with a real element type.
module test;
real d1[];
int d2[];
initial begin
d1 = d2;
$display("FAILED");
end
endmodule

View File

@ -0,0 +1,27 @@
// Check that queues with compatible packed base types can be assigned to each
// other. Even if the element types are not identical.
module test;
typedef bit [31:0] T1;
typedef bit [31:0] T2[$];
// For two packed types to be compatible they need to have the same packed
// width, both be 2-state or 4-state and both be either signed or unsigned.
bit [32:1] q1[$];
bit [7:0][3:0] q2[$];
int unsigned q3[$];
T1 q4[$];
T2 q5;
initial begin
q2 = q1;
q3 = q2;
q4 = q3;
q5 = q4;
q1 = q5;
$display("PASSED");
end
endmodule

View File

@ -0,0 +1,45 @@
// Check that queues with compatible packed base types can be passed as task
// arguments. Even it the element types are not identical.
module test;
typedef logic [31:0] T[$];
task t1(logic [31:0] q[$]);
q[0] = 1;
endtask
task t2(logic [7:0][3:0] q[$]);
q[0] = 1;
endtask
task t3([31:0] q[$]);
q[0] = 1;
endtask
task t4(T q);
q[0] = 1;
endtask
// For two packed types to be compatible they need to have the same packed
// width, both be 2-state or 4-state and both be either signed or unsigned.
logic [31:0] q1[$];
logic [7:0][3:0] q2[$];
initial begin
q1.push_back(1);
q2.push_back(2);
t1(q1);
t1(q2);
t2(q1);
t2(q2);
t3(q1);
t3(q2);
t4(q1);
t4(q2);
$display("PASSED");
end
endmodule

View File

@ -0,0 +1,14 @@
// Check that it is not possible to assign a queue with a 2-state element type
// to a queue with 4-state element type. Even if they are otherwise identical.
module test;
logic [31:0] q1[$];
bit [31:0] q2[$];
initial begin
q1 = q2;
$dispaly("FAILED");
end
endmodule

View File

@ -0,0 +1,14 @@
// Check that it is not possible to assign a queue with a signed element type to
// a queue with a unsigned element type. Even if they are otherwise identical.
module test;
logic [31:0] q1[$];
logic signed [31:0] q2[$];
initial begin
q1 = q2;
$dispaly("FAILED");
end
endmodule

View File

@ -0,0 +1,14 @@
// Check that it is not possible to assign a queue to another queue with a
// different element width.
module test;
int q1[$];
shortint q2[$];
initial begin
q1 = q2;
$dispaly("FAILED");
end
endmodule

View File

@ -0,0 +1,17 @@
// Check that it is not possible to assign a queue with an enum element type to
// a queue with a packed type. Even if the enum base type is the same as the
// packed type.
module test;
enum logic [31:0] {
A
} q1[$];
logic [31:0] q2[$];
initial begin
q1 = q2;
$dispaly("FAILED");
end
endmodule

View File

@ -0,0 +1,14 @@
// Check that it is not possible to assign a queue with a real element type to a
// queue with an int element type.
module test;
int q1[$];
real q2[$];
initial begin
q1 = q2;
$display("FAILED");
end
endmodule

View File

@ -0,0 +1,14 @@
// Check that it is not possible to assign a queue with an int element type to a
// queue with a real element type.
module test;
real q1[$];
int q2[$];
initial begin
q1 = q2;
$display("FAILED");
end
endmodule

View File

@ -553,6 +553,14 @@ sv_darray_args2 normal,-g2009 ivltests
sv_darray_args2b normal,-g2009 ivltests
sv_darray_args3 normal,-g2009 ivltests
sv_darray_args4 normal,-g2009 ivltests
sv_darray_assign1 normal,-g2009 ivltests
sv_darray_assign2 normal,-g2009 ivltests
sv_darray_assign_fail1 CE,-g2009 ivltests
sv_darray_assign_fail2 CE,-g2009 ivltests
sv_darray_assign_fail3 CE,-g2009 ivltests
sv_darray_assign_fail4 CE,-g2009 ivltests
sv_darray_assign_fail5 CE,-g2009 ivltests
sv_darray_assign_fail6 CE,-g2009 ivltests
sv_darray_copy_empty1 normal,-g2009 ivltests
sv_darray_copy_empty2 normal,-g2009 ivltests
sv_darray_copy_empty3 normal,-g2009 ivltests
@ -621,6 +629,14 @@ sv_ps_function3 normal,-g2009 ivltests
sv_queue1 normal,-g2009 ivltests
sv_queue2 normal,-g2009 ivltests
sv_queue3 normal,-g2009 ivltests
sv_queue_assign1 normal,-g2009 ivltests
sv_queue_assign2 normal,-g2009 ivltests
sv_queue_assign_fail1 CE,-g2009 ivltests
sv_queue_assign_fail2 CE,-g2009 ivltests
sv_queue_assign_fail3 CE,-g2009 ivltests
sv_queue_assign_fail4 CE,-g2009 ivltests
sv_queue_assign_fail5 CE,-g2009 ivltests
sv_queue_assign_fail6 CE,-g2009 ivltests
sv_queue_copy_empty1 normal,-g2009 ivltests
sv_queue_copy_empty2 normal,-g2009 ivltests
sv_queue_function1 normal,-g2009 ivltests

View File

@ -345,6 +345,8 @@ sv_darray_args2 CE,-g2009,-pallowsigned=1 ivltests
sv_darray_args2b CE,-g2009,-pallowsigned=1 ivltests
sv_darray_args3 CE,-g2009,-pallowsigned=1 ivltests
sv_darray_args4 CE,-g2009,-pallowsigned=1 ivltests # Also string
sv_darray_assign1 CE,-g2009 ivltests
sv_darray_assign2 CE,-g2009 ivltests
sv_darray_copy_empty1 CE,-g2009 ivltests
sv_darray_copy_empty2 CE,-g2009 ivltests
sv_darray_copy_empty3 CE,-g2009 ivltests
@ -486,6 +488,8 @@ pr3390385b CE,-g2009 ivltests # ++
pr3390385c CE,-g2009 ivltests # ++
pr3390385d CE,-g2009 ivltests # ++
pr3462145 CE,-g2009 ivltests # ++
sv_queue_assign1 CE,-g2009 ivltests # queue
sv_queue_assign2 CE,-g2009 ivltests # queue
sv_queue_copy_empty1 CE,-g2009 ivltests # queue
sv_queue_copy_empty2 CE,-g2009 ivltests # queue
sv_queue_function1 CE,-g2009,-pallowsigned=1 ivltests # queue