I have tried the following code
class random_test;
randc bit [1:0][1:0] a;
randc bit [1:0] b [1:0];
endclass
module test_top;
random_test t = new();
int i;
initial begin
repeat(20) begin
void'(t.randomize());
$display("No.%0d random value a = (%p, %p), b = %p", i, t.a[0], t.a[1], t.b);
i++;
end
end
endmodule
and got the similar result from vcs, questa, xcelium
No.0 random value a = (1, 0), b = '{'h1, 'h1}
No.1 random value a = (2, 0), b = '{'h0, 'h2}
No.2 random value a = (0, 0), b = '{'h2, 'h3}
No.3 random value a = (0, 1), b = '{'h3, 'h0}
No.4 random value a = (3, 0), b = '{'h3, 'h1}
No.5 random value a = (3, 3), b = '{'h0, 'h3}
No.6 random value a = (1, 2), b = '{'h1, 'h2}
No.7 random value a = (2, 3), b = '{'h2, 'h0}
No.8 random value a = (2, 2), b = '{'h1, 'h0}
No.9 random value a = (0, 2), b = '{'h3, 'h3}
No.10 random value a = (0, 3), b = '{'h2, 'h1}
No.11 random value a = (3, 2), b = '{'h0, 'h2}
No.12 random value a = (1, 3), b = '{'h3, 'h3}
No.13 random value a = (1, 1), b = '{'h0, 'h1}
No.14 random value a = (2, 1), b = '{'h1, 'h2}
No.15 random value a = (3, 1), b = '{'h2, 'h0}
No.16 random value a = (2, 0), b = '{'h0, 'h3}
No.17 random value a = (1, 0), b = '{'h3, 'h0}
No.18 random value a = (0, 0), b = '{'h2, 'h2}
No.19 random value a = (3, 0), b = '{'h1, 'h1}
It seems that the element in a is repeated with the whole solution space, as the Dave stated in Randc in an variable within an array of objects - #3 by dave_59, which means the value of a could be the same until 16 randomize, while the value in b is repeated with each element itself, so it could be the same after 4 randomize.
I saw the description from LRM that
Arrays can be declared rand or randc, in which case all of their member elements are treated as
rand or randc.
and
An unpacked structure can be declared rand, in which case all of that structure’s random members
are solved concurrently using one of the rules listed in this subclause. Unpacked structures shall not
be declared randc.
From these description I would expect that unpacked array b got compile error and packed array a behaved like what array b did, yet they didn’t.
I would like to know where to find the definition of random behavior that packed and unpacked array declared as randc.
Thanks