Skip to question
asic.fyi
DesignVerificationSystemVerilogFirmwareArchitectureInterviews
asic.fyi/Interview questions/Find the longest unique token run

Hardware interview practice

Find the longest unique token run

MediumStreaming AlgorithmsSystemVerilog

For each bounded protocol-token frame, report the longest contiguous run containing no repeated token ID, including its inclusive start and end indices.

Try it in the question bankReason first. Then compare.

Keep this exact question selected while you check your answer and review the full solution.

Practice this question →
Reviewed example

Work through one case

Input
accepted token frame = [1, 2, 1, 3, 4, 3]
Expected output
best_start=1; best_end=4; best_length=4; run=[2, 1, 3, 4]

The repeated 1 advances the window start to index 1, and the later repeated 3 closes the longest unique run.

What to cover

Requirements

  1. Support token IDs 0 to 15 and frame lengths from 1 to 64.
  2. Track only accepted tokens; bubbles and downstream backpressure must not change indices.
  3. Never move the current window start backward when a repeated token lies before the active window.
  4. On equal maximum lengths, keep the run with the earliest start index.
  5. Clear or invalidate last-seen state between frames and hold the final result stable.
asic.fyi · Learn silicon end to end.info@asic.fyi