Skip to question
asic.fyi
DesignVerificationSystemVerilogFirmwareArchitectureInterviews
asic.fyi/Interview questions/Deduplicate a sorted register bank

Hardware interview practice

Deduplicate a sorted register bank

MediumRTL DatapathsSystemVerilog

Given a sorted active prefix of a bounded tag array, emit one copy of each adjacent run, report the unique count, and zero the unused output suffix.

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
in_count=6; sorted active prefix=[1,1,2,2,2,5]
Expected output
N=8; unique_count=3; output=[1,2,5,0,0,0,0,0]

One value is retained from each adjacent run and the unused bounded suffix is deterministically zeroed.

What to cover

Requirements

  1. Support an active count from zero through N, including both endpoints.
  2. Read only entries below in_count and preserve sorted order.
  3. Keep exactly one copy of each repeated run.
  4. Accept start only when start_ready is high; reject in_count greater than N with count_error.
  5. Pulse done when the replacement prefix or invalid-count result is ready.
asic.fyi · Learn silicon end to end.info@asic.fyi