Skip to question
asic.fyi
DesignVerificationSystemVerilogFirmwareArchitectureInterviews
asic.fyi/Interview questions/Measure the maximum gain in a sample stream

Hardware interview practice

Measure the maximum gain in a sample stream

HardStreaming RTLSystemVerilog

For each framed stream of unsigned samples, report the maximum nonnegative later-minus-earlier gain and its endpoints. Return zero and indices (0,0) when no positive gain exists.

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 sample frame=[7,1,5,2,6]
Expected output
max_gain=5; start_index=1; end_index=4

The running minimum becomes value 1 at index 1, and later value 6 gives the largest strictly later gain.

What to cover

Requirements

  1. Support frames of one through MAX_SAMPLES accepted samples.
  2. Use strictly earlier and later endpoints for every positive result.
  3. Break gain ties by earliest start index and then earliest end index.
  4. Advance the sample index only on a handshake and hold all result fields stable under backpressure.
Continue practicing

Related questions

Reference ModelsVerify a longest rising-trend accelerator→
asic.fyi · Learn silicon end to end.info@asic.fyi