Skip to question
asic.fyi
DesignVerificationSystemVerilogFirmwareArchitectureInterviews
asic.fyi/Interview questions/Pick a weighted random enum

Hardware interview practice

Pick a weighted random enum

EasyConstraintsSystemVerilog

Return LOW, MED, or HIGH randomly with weights 1:2:3.

Try it in the question bankReason first. Then compare.

Keep this exact question selected while you check your answer and review the full solution.

Practice this question →
Reviewed example

Work through one case

Input
draw one uniformly random integer with $urandom_range(6,1); map 1->LOW, 2..3->MED, 4..6->HIGH
Expected output
One valid draw: 4, producing HIGH

The six equiprobable outcomes allocate one slot to LOW, two to MED, and three to HIGH, giving a 1:2:3 weighting. Any individual draw is non-unique.

What to cover

Requirements

  1. Map six equally likely integer outcomes.
  2. Give LOW one outcome, MED two, and HIGH three.
Continue practicing

Related questions

ConstraintsBias burst lengths by range→Constrained RandomWeighted random values without dist→
asic.fyi · Learn silicon end to end.info@asic.fyi