Constraint randomization of an array

The 1800-2012 LRM added the ability to use the array reduction methods in a constraint. This is already supported in recent releases of Questa. Be very careful using signed data types in a constraint to prevent unwanted negative numbers and overflow that will give you results that satisfy the constraints but not normally what you are expecting.

rand int arr[];
constraint c_arr{
   arr.size() < 10;
   arr.sum() inside {[1:1000]); // if you want a positive result
   foreach(arr[i]) arr[i] inside ([0:1000]};
}