Hardware interview practice
Constrain a Gray-adjacent sequence
Randomize 16 unique 4-bit values starting at zero so each adjacent pair differs in exactly one bit.
Reviewed example
Work through one case
Input
randomize 16 unique 4-bit values with values[0]=4'b0000Expected output
One valid result: [0000,0001,0011,0010,0110,0111,0101,0100,1100,1101,1111,1110,1010,1011,1001,1000]This complete Gray path visits every 4-bit value once and each constrained adjacent pair has Hamming distance one; the last-to-first transition is not constrained.
What to cover
Requirements
- Fix the first value at 4'b0000.
- Require a Hamming distance of one between neighbors.
- Use every 4-bit value at most once.
