Skip to question
asic.fyi
DesignVerificationSystemVerilogFirmwareArchitectureInterviews
asic.fyi/Interview questions/Debug a signed sliding-window peak

Hardware interview practice

Debug a signed sliding-window peak

MediumReference ModelsSystemVerilog

Write an independent exact-sum oracle for a fixed-window peak detector that fails on some all-negative traces, plus a rolling-update helper that can be cross-checked against it.

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
signed samples=[-8,-3,-5]; window_len=2
Expected output
best_sum=-8; best_start=1

Legal window sums are -11 and -8; initializing best to zero would incorrectly report a nonexistent nonnegative window.

What to cover

Requirements

  1. Sign-extend every 12-bit sample before addition and initialize the legal best from the first window rather than zero.
  2. Use independent O(n x k) recomputation as the trusted oracle; a rolling sum may be cross-checked but must not replace it.
  3. Compare integer sums instead of real-number averages because every candidate has the same denominator.
  4. Return request_error with result_valid=0 when window_len is zero, exceeds sample_count, or sample_count exceeds 32.
  5. Choose the lowest start for equal sums and explain tests for signed extrema, all-negative data, tied maxima, window boundaries, and each invalid class.
Continue practicing

Related questions

Reference ModelsVerify a minimum energy-window engine→Reference ModelsVerify a longest rising-trend accelerator→Reference ModelsScoreboard a maximum-interval accelerator→
asic.fyi · Learn silicon end to end.info@asic.fyi