Randomizing packed array

In reply to Blitzz0418:

There are a couple of ways of approaching this depending on how you want to constrain the number of elements that have all ones set, and what you want the elements that do not have all ones.

class myclass;
  rand bit [99:0] A; // assumes you wanted an exact multiple of 10
    constraint all_ones { foreach (A[i]) 
      i % 10 == 0 -> A[i+:10] == '1 dist {1:=25,0:=75}; //25% 
                        }
endclass
class myclass;
  rand bit [9:0][9:0] A; // 2-D packed array
    constraint all_ones { foreach (A[i]) 
      A[i] == '1 dist {1:=25,0:=75}; //25% 
                        }
endclass