Skip to the selected question
ASIC.FYI

ASIC Question Bank

1,000+ hardware interview questions
DescriptionQ695
Q695DVASIC interview problem

Constrain a bounded zig-zag address walk

TechniquesRandomizationAdjacent valuesZig-zag
DifficultyMedium
TopicConstraints
LanguageSystemVerilog
Requirements3 checkpoints
01

Problem

Randomize 20 addresses from 0 through 255 where every step is 1-8 and the step direction alternates up, down, up, down or vice versa.

Example input and output

Use this case to check your interpretation
Input
randomize 20 addresses in 0..255 with alternating step direction and magnitude 1..8
Output
One valid result: [100,104,102,108,105,110,109,117,112,118,114,121,115,120,116,123,119,125,122,127]
Explanation

Every adjacent value differs by 1..8, all values stay in range, and step signs alternate +,- throughout. Other walks are valid.

02

Requirements (3)

  • Adjacent addresses must never be equal.
  • The absolute difference of each step must be at most eight.
  • Starting with the third address, consecutive step directions must differ.