If I have a packet that has:
class my_packet;
rand bit vector[31];
constraint c{....}
endclass
How do I write a constraint to limit the total number of ones for vector array to a certain range?
I tried to use vector.sum() > 8; vector.sum() <15; but the randomize() function fails to randomize for this.
Is this because sum() would only return a 1 bit answer to the constraint solver i.e 0 or 1?