VLSI DV Interview Puzzles · All levels

Loaded Die with Mixed Granularity

What is P(face==6) and P(face==3)?

Puzzle

Difficulty: Easy · Puzzle 3 of 6 · Topic: Distribution Puzzles (`dist`, `:=` vs `:/`)

What is P(face==6) and P(face==3)?

Code

systemverilog
class loaded_die;
  rand int unsigned face;
  constraint c_dom { face inside {[1:6]}; }
  constraint c_dist {
    face dist { 6 := 5, [1:5] :/ 5 };
  }
endclass

Hint

The [1:5] bucket gets total weight 5 split over five values.

Step-by-step solution

diagram
1) face=6 has weight 5.
2) face 1..5 each has weight 5/5=1.
3) Total weight = 5 + 5*1 = 10.
4) P(6)=5/10=1/2.
5) P(3)=1/10.

Answer

Answer: P(face==6)=50% and each of 1..5 has 10%.

Why candidates get it wrong

A common error is treating [1:5] :/ 5 as each value weight 5 instead of total range weight 5.

Interviewer follow-up

How would you set constraints so P(6)=2x P(any single value from 1..5)?

Related topics