Constraint Question : Write a constraint to generate a random number with only 5 bits set and consecutively set for 80% of the time.

My solution: Fix the number of set bits and as soon as you see a set bit, AND the next 5 bits and use the **dist** keyword for the probability. Is this the best approach to solve this question?

```
class sample;
rand bit [31:0] x;
constraint c{
$countones(x) == 5;
foreach(x[i]){
if(x[i] && i<28){
(x[i]&&x[i+1]&&x[i+2]&&x[i+3]&&x[i+4]) dist {1:=80,0:=20};
}
}
}
endclass
module tb;
sample s = new();
initial begin
repeat(10) begin
s.randomize();
$display("%b",s.x);
end
end
endmodule
```