Multiple dist constraints

Hi Forum,

Consider the following constraint

class Dist;

 rand bit [3:0] dst;

 constraint DIST1 { dst dist { 5:=1 , [12:15]:=1 }; }

 //constraint DIST2 { dst dist { 10:=1 }; }

 //constraint DIST3 { dst dist { 15:=2 }; }

endclass

On randomizing an object of Dist, 20 times I observe ::

(1) On uncommenting DIST2 there is a constraint failure as the value of 10 isn’t legal as per DIST1

(2) On uncommenting DIST3 I observe that dst always takes value as 15 ( all 20 times )

[Q] Shouldn’t dst also be randomized ( with lesser probability ) to value of 5 / 12 / 13 / 14 ?

Thanks

A dist is a hard constraint that encompasses all the values with non-zero weighted in the bracketed set. As soon as you introduce the DIST2 constraint, you’re faced with a conflicting set of values. This is essentially the same as applying an inside constraint; the result is the intersection of the values in the two lists. If instead of adding the DIST2 constraint, you have the DIST1 and DIST3 values, the intersection of these values is only 15.