Randc type to packed and unpacked array

Hi Dave,

So the word “unpacked structure” is refer to 7.2 Structures, rath than unpacked array, right?

And according to LRM

Arrays can be declared rand or randc, in which case all of their member elements are treated as rand or randc.

It already explained the random behavior of unpacked array, which cyclically random each element.

And for packed array,

A packed structure can be declared rand or randc, in which case that structure is treated as an integral type

If this concept of packed structure also applied to packed arrays, which interpreted it as an integer, then the random behavior would be cyclically random to this integer.

And one more question,

is the answer here correct?

randc int unsigned array1[6];

constraint c{
    foreach(array1[i])
      array1[i] < 7;
}

the array1 is an unpacked array, so its random behavior would be cyclically random to each element.

Therefore, we won’t got the following result

array1 = '{'h0, 'h0, 'h0, 'h0, 'h0, 'h0}
array1 = '{'h0, 'h0, 'h0, 'h0, 'h0, 'h1}
array1 = '{'h0, 'h0, 'h0, 'h0, 'h1, 'h0}
array1 = '{'h0, 'h0, 'h0, 'h0, 'h0, 'h2}

because array1[0] should be cyclic itself in each randomize, which means it couldn’t get 'h0 in 2nd randomize.

I tried the similar code

randc int unsigned f[2];

constraint c {
    foreach(f[i])
      f[i] inside {[0:3]};
}

and I get

No.0 random value f = (3, 3)
No.1 random value f = (2, 1) 
No.2 random value f = (1, 0)
No.3 random value f = (0, 2) 
No.4 random value f = (3, 0) 
No.5 random value f = (1, 2) 
No.6 random value f = (2, 1) 
No.7 random value f = (0, 3) 
No.8 random value f = (2, 1)
No.9 random value f = (3, 3) 
No.10 random value f = (0, 0)
No.11 random value f = (1, 2)

Thank you for clarification.