Can someone help me to understand the basic concept of how packed array slicing works?
what i want to do is
i have an array lets say,
logic [100:0] A;
i want to slice A into particular set of bits lets say 10 bit makes one element, like this i have total 10 elements in A.
out of which few of them are supposed to value as all ones; (as one 10 bit value)
so basically out of 10 elements in “A” i want to set few 10bit wide elements as 'h3FF. that number is a randomly generated number and i want to generate random pattern in A.
thanks
one way i can think of is slice it down in 10 different elements and select randomly to which one i want to set it all 1’s.
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