Weighted Distribution in Constraints in system verilog

The dist operator allows to create weighted distributions. Do I need to specify weight for all values?

Look at the code:
rand bit [7:0] a;
constraint dist1 {a dist {0:=20, [1:30]:=50};}

“a” can have 0 to 255 possible values. So do I need to specify weight for all values?

Same is the question when we apply “:/” operator.

In reply to Malyka:

Values not specified have a weight of 0 and excluded excluded from the solution space. You must give a weight for included values specified with := or :/.

An enhancement to the proposed 1800-2023 LRM would allow a default:/weight to be applied to all unspecified values as a group.

Hi Dave
thanks for clarification.
however, in section 18.5.4 the LRM says that “If no weight is specified for an item, the default weight is := 1”. how is that goes together?

Elad

The original questions was asking about specifying all values in the full range of a variable. You don’t have to provide for all values in the full range. The values you don’t provide get a weight of 0 which excludes them from the solution space.

Once you do provide a value as a item in the distribution, it either gets the weight you specify with :=, or /:, or as you correctly mention, gets a default weight of := 1.

ok, I understand now.
it seems to me a bit ambiguous though, since you can read the sentence also as:
if not weight is specified at all, the default weight is 1 (which will answer the original question)

thanks
Elad

The sentence says: “If no weight is specified for an item”. An item is something you have explicitly listed in the distribution. The default weight of :=1only applies to explicitly listed items. You can think of the values not listed as either having a default weight of 0, or not considered as a valid value in the distribution space.