Hardware interview practice
Do not repeat the previous five values
Randomize a four-bit value that differs from each of its five most recent successful values, then maintain that bounded history correctly.
Starting point
Question code
rand bit [3:0] value;
bit [3:0] history[$];Reviewed example
Work through one case
Input
history = {1, 2, 3, 4, 5}; randomize produces 9Expected output
value = 9; new history = {9, 1, 2, 3, 4}Values 1 through 5 are excluded during the solve, then post_randomize inserts 9 and removes the oldest entry.
What to cover
Requirements
- 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.
