Skip to the selected question
ASIC.FYI

ASIC Question Bank

1,000+ hardware interview questions
DescriptionQ466
Q466DVASIC interview problem

Do not repeat the previous five values

TechniquesSystemVerilogStateful randomizationpost_randomize
DifficultyMedium
TopicConstraints
LanguageSystemVerilog
Requirements4 checkpoints
01

Problem

Randomize a four-bit value that differs from each of its five most recent successful values, then maintain that bounded history correctly.

Starting declarationSystemVerilog
rand bit [3:0] value;
bit [3:0] history[$];

Example input and output

Use this case to check your interpretation
Input
history = {1, 2, 3, 4, 5}; randomize produces 9
Output
value = 9; new history = {9, 1, 2, 3, 4}
Explanation

Values 1 through 5 are excluded during the solve, then post_randomize inserts 9 and removes the oldest entry.

02

Requirements (4)

  • Exclude every value currently stored in the history queue.
  • Update history only after a successful solve.
  • Keep at most five prior values, newest first.
  • Check randomize() failure explicitly at the call site.