Skip to the selected question
ASIC.FYI

ASIC Question Bank

1,000+ hardware interview questions
DescriptionQ888
Page ↗
Q888DVASIC interview problem

Debug a signed sliding-window peak

TechniquesSliding windowSigned arithmeticDifferential checkingTie-breaking
DifficultyMedium
TopicReference Models
LanguageSystemVerilog
Requirements5 checkpoints
01

Problem

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.

Example input and output

Use this case to check your interpretation
Input
signed samples=[-8,-3,-5]; window_len=2
Output
best_sum=-8; best_start=1
Explanation

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

02

Requirements (5)

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