The following code fragment
reg [7:0] Data[0:3][0:15];
integer i;
integer j;
initial begin
for (i = 0; i < 4; i = i + 1) begin
for (j = 0; j < 16; j = j + 1) begin
Data[i][j] = j;
end
end
for (j = 0; j < 16; j = j + 1) begin
$display("%h", Data[0][j]);
end
end
generates the output
00
01
02
03
04
05
06
07
00
01
02
03
04
05
06
07
The problem seems to be that when using the literal 0 as the major index, insufficient bits are used to calculate the offset into the array. The problem can be worked round by using an intermediate variable, e.g.
i = 0;
for (j = 0; j < 16; j = j + 1) begin
$display("%h", Data[i][j]);
end
A more complete test suitable for inclusion in the test suite is attached.
I will probably look at this later in the week unless anyone beats me to it.
Regression test for test suite
Patch submitted to patch tracker.