Skip to the selected question
ASIC.FYI

ASIC Question Bank

1,000+ hardware interview questions
DescriptionQ695
Page ↗
Q695DVASIC interview problem

Pick a weighted random enum

TechniquesRandomizationProbability
DifficultyEasy
TopicConstraints
LanguageSystemVerilog
Requirements2 checkpoints
01

Problem

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

Example input and output

Use this case to check your interpretation
Input
draw one uniformly random integer with $urandom_range(6,1); map 1->LOW, 2..3->MED, 4..6->HIGH
Output
One valid draw: 4, producing HIGH
Explanation

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.

02

Requirements (2)

  • Map six equally likely integer outcomes.
  • Give LOW one outcome, MED two, and HIGH three.