Constraint randomization of an array

In reply to dave_59:

Hi Dave,

I’m trying to constrain an array that has a sum of 2048.

rand bit [11:0] vf;
constraint c_vf_queues {
vf.size == 248;
vf.sum == 2048;
foreach (vf[i]) vf[i] inside {[0:2048]};
}

I can’t get the individual values in the array to sum to 2048.
All the values are too large.

Thank you,
George