Add regression tests for dynamic array and queue out-of-bounds access

Check that out-of-bounds access on a dynamic array or queue works and
returns the correct value.

  * 2-state vectors: '0 with the element width
  * 4-state vectors: 'x with the element width
  * reals: 0.0
  * strings: ""

Note that the 2-state test currently still fails as out-of-bounds access on
a 2-state vector incorrectly returns 'x.

Signed-off-by: Lars-Peter Clausen <lars@metafoo.de>
This commit is contained in:
Lars-Peter Clausen 2022-05-14 13:57:18 +02:00
parent abc3ad95e6
commit b83daa3ae3
11 changed files with 160 additions and 0 deletions

View File

@ -0,0 +1,18 @@
// Check that out-of-bounds access on a real typed dynamic array works and
// returns the correct value.
module test;
real d[];
real x;
initial begin
x = d[1];
if (x == 0.0) begin
$display("PASSED");
end else begin
$display("FAILED. Expected 0.0, got %f", x);
end
end
endmodule

View File

@ -0,0 +1,18 @@
// Check that out-of-bounds access on a string typed dynamic array works and
// returns the right value.
module test;
string d[];
string x;
initial begin
x = d[1];
if (x == "") begin
$display("PASSED");
end else begin
$display("FAILED. Expected '', got '%s'", x);
end
end
endmodule

View File

@ -0,0 +1,18 @@
// Check that out-of-bounds access on a 2-state vector dynamic array works and
// returns the correct value.
module test;
bit [7:0] d[];
logic [7:0] x;
initial begin
x = d[1];
if (x === 8'h00) begin
$display("PASSED");
end else begin
$display("FAILED. Expected 00000000, got %b",x);
end
end
endmodule

View File

@ -0,0 +1,18 @@
// Check that out-of-bounds access on a 4-state vector dynamic array works and
// returns the correct value.
module test;
logic [7:0] d[];
logic [7:0] x;
initial begin
x = d[1];
if (x === 8'hxx) begin
$display("PASSED");
end else begin
$display("FAILED. Expected xxxxxxxx, got %b", x);
end
end
endmodule

View File

@ -0,0 +1,18 @@
// Check that out-of-bounds access on a real typed queue works and returns the
// correct value.
module test;
real q[$];
real x;
initial begin
x = q[1];
if (x == 0.0) begin
$display("PASSED");
end else begin
$display("FAILED. Expected 0.0, got %f", x);
end
end
endmodule

View File

@ -0,0 +1,18 @@
// Check that out-of-bounds access on a string typed queue works and returns the
// right value.
module test;
string q[$];
string x;
initial begin
x = q[1];
if (x == "") begin
$display("PASSED");
end else begin
$display("FAILED. Expected '', got '%s'", x);
end
end
endmodule

View File

@ -0,0 +1,18 @@
// Check that out-of-bounds access on a 2-state vector queue works and returns
// the correct value.
module test;
bit [7:0] q[$];
logic [7:0] x;
initial begin
x = q[1];
if (x === 8'h00) begin
$display("PASSED");
end else begin
$display("FAILED. Expected 00000000, got %b",x);
end
end
endmodule

View File

@ -0,0 +1,18 @@
// Check that out-of-bounds access on a 4-state vector queue works and returns
// the correct value.
module test;
logic [7:0] q[$];
logic [7:0] x;
initial begin
x = q[1];
if (x === 8'hxx) begin
$display("PASSED");
end else begin
$display("FAILED. Expected xxxxxxxx, got %b", x);
end
end
endmodule

View File

@ -129,6 +129,7 @@ sv_darray_nest1 normal ivltests
sv_darray_nest2 normal ivltests
sv_darray_nest3 normal ivltests
sv_darray_nest4 normal ivltests
sv_darray_oob_vec2 normal ivltests
sv_deferred_assert1 normal ivltests
sv_deferred_assert2 normal ivltests
sv_deferred_assume1 normal ivltests
@ -137,3 +138,4 @@ sv_queue_nest1 normal ivltests
sv_queue_nest2 normal ivltests
sv_queue_nest3 normal ivltests
sv_queue_nest4 normal ivltests
sv_queue_oob_vec2 normal ivltests

View File

@ -531,6 +531,9 @@ sv_darray_args3 normal,-g2009 ivltests
sv_darray_args4 normal,-g2009 ivltests
sv_darray_decl_assign normal,-g2009 ivltests
sv_darray_function normal,-g2009 ivltests
sv_darray_oob_real normal,-g2009 ivltests
sv_darray_oob_string normal,-g2009 ivltests
sv_darray_oob_vec4 normal,-g2009 ivltests
sv_darray_signed normal,-g2009 ivltests
sv_darray_word_size normal,-g2005-sv ivltests
sv_default_port_value1 normal,-g2009 ivltests
@ -589,6 +592,9 @@ sv_queue2 normal,-g2009 ivltests
sv_queue3 normal,-g2009 ivltests
sv_queue_function1 normal,-g2009 ivltests
sv_queue_function2 normal,-g2009 ivltests
sv_queue_oob_real normal,-g2009 ivltests
sv_queue_oob_string normal,-g2009 ivltests
sv_queue_oob_vec4 normal,-g2009 ivltests
sv_queue_parray normal,-g2009,-pfileline=1 ivltests gold=sv_queue_parray.gold
sv_queue_parray_bounded normal,-g2009,-pfileline=1 ivltests gold=sv_queue_parray_bounded.gold
sv_queue_parray_fail CE,-g2009 ivltests gold=sv_queue_parray_fail.gold

View File

@ -342,6 +342,10 @@ sv_darray_args3 CE,-g2009,-pallowsigned=1 ivltests
sv_darray_args4 CE,-g2009,-pallowsigned=1 ivltests # Also string
sv_darray_decl_assign CE,-g2009,-pallowsigned=1 ivltests
sv_darray_function CE,-g2009,-pallowsigned=1 ivltests
sv_darray_oob_real CE,-g2009 ivltests
sv_darray_oob_string CE,-g2009 ivltests # Also string
sv_darray_oob_vec2 CE,-g2009 ivltests # Also 2-state
sv_darray_oob_vec4 CE,-g2009 ivltests
sv_darray_signed CE,-g2009,-pallowsigned=1 ivltests # Also string
sv_darray_word_size CE,-g2009 ivltests
sv_new_array_error CE,-g2009, ivltests
@ -475,6 +479,10 @@ pr3390385d CE,-g2009 ivltests # ++
pr3462145 CE,-g2009 ivltests # ++
sv_queue_function1 CE,-g2009,-pallowsigned=1 ivltests # queue
sv_queue_function2 CE,-g2009,-pallowsigned=1 ivltests # queue
sv_queue_oob_real CE,-g2009 ivltests # queue
sv_queue_oob_string CE,-g2009 ivltests # queue, string
sv_queue_oob_vec2 CE,-g2009 ivltests # queue, 2-state
sv_queue_oob_vec4 CE,-g2009 ivltests # queue
sv_typedef_darray_base1 CE,-g2009 ivltests # Dyanmic array
sv_typedef_darray_base2 CE,-g2009 ivltests # Dyanmic array
sv_typedef_darray_base3 CE,-g2009 ivltests # Dyanmic array