I have the following code. I was trying to create a unique 3x3x3 matrix with unique elements. After randomization I am storing them into an associative array and later printing the elements of the associative array. I was expecting the size of associative array is 27. But I am seeing the size as 32.
Could some one explain this behavior of associative array?
class matrix;
rand int a [3][3][3];
rand int b [3][3][3];
int A[int] = '{default:0};
constraint c1 {
foreach(b[i,j,k])
b[i][j][k] inside {[1:35]};
unique{b};
}
function void post_randomize();
$display("%p", a);
foreach(b[i,j,k]) begin
$display("%d", b[i][j][k]);
A[b[i][j][k]]=1;
end
foreach(A[i])
$display("A[%d]= %d", i, A[i]);
$display("A.size:%d", A.size);
endfunction
endclass
module tb;
matrix C;
initial begin
C = new;
repeat(5)
C.randomize();
end
endmodule