Hardware interview practice
Deduplicate a sorted register bank
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.
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
- Support an active count from zero through N, including both endpoints.
- Read only entries below in_count and preserve sorted order.
- Keep exactly one copy of each repeated run.
- Accept start only when start_ready is high; reject in_count greater than N with count_error.
- Pulse done when the replacement prefix or invalid-count result is ready.
