Write a constraint for a 10 bit variable en so that; → 10% of the time 1 bit in en is high → 10% of the time 2 bits in en are high … → 10% of the time all 10 bits in en are high.
class sample;
rand bit [10:1] en;
constraint x{
foreach(en[i])
{
$countones(en) == i dist {1:=10,0:=90};
}
}
endclass