Skip to the selected question
ASIC.FYI

ASIC Question Bank

1,000+ hardware interview questions
DescriptionQ868
Q868DVASIC interview problem

Forbid consecutive POP commands

TechniquesRandomizationSequence constraintforeach
DifficultyEasy
TopicConstraints
LanguageSystemVerilog
Requirements3 checkpoints
01

Problem

Randomize a 20-command PUSH/POP sequence that never contains two adjacent POP commands.

Example input and output

Use this case to check your interpretation
Input
randomize exactly 20 commands, each PUSH or POP
Output
One valid result: [POP,PUSH,POP,PUSH,PUSH,POP,PUSH,POP,PUSH,PUSH,POP,PUSH,POP,PUSH,PUSH,POP,PUSH,POP,PUSH,POP]
Explanation

The first command may be POP, all entries use the two legal enum values, and no POP directly follows another POP.

02

Requirements (3)

  • Allow either command at index 0.
  • Check every later element against its predecessor.
  • Do not procedurally repair the randomized sequence.