Dist inside set that is not consecutive

Obviously you can write constraints that give a weight to a consecutive range of values:


rand int value;
constraint dist_name {value dist { [0:5] :/ 50, [6:23] :/ 50}; }

But how could one go about creating a weighted distribution for a non-consecutive set of values?

Something like:


rand int value;
constraint dist_name {value dist { inside {0,4,7} :/ 50, inside {2,3,9}  :/ 50}; }

Obviously without some kind of “inside” operator, the {} are treated as concatenation… is there a way?

In reply to ce_2015:

This post:

https://verificationacademy.com/forums/systemverilog/distributed-weightage-constraint

gave me the idea to have another variable that is restricted to the amount of “sets” of numbers you want, then set the distribution on that variable rather than the variable that belongs to one of the sets:


rand bit [1:0] selector; // Range of variable values to represent number of sets
rand int value;
constraint set_dist  {selector dist { 2 := 20, 1 := 30, 0 := 50 };}
constraint dist_name {selector == 2 -> value inside {1,5};
                      selector == 1 -> value inside {0,4,7}; 
                      selector == 0 -> value inside {2,3,9}; }