Skip to question
asic.fyi
DesignVerificationSystemVerilogFirmwareArchitectureInterviews
asic.fyi/Interview questions/Merge two sorted ready/valid streams

Hardware interview practice

Merge two sorted ready/valid streams

HardStreaming RTLSystemVerilog

Merge two nonempty finite streams of nondecreasing 16-bit values into one ordered ready/valid stream. Preserve duplicates and choose stream A first when both head values are equal.

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
stream A=[1,3,3]; stream B=[2,3]
Expected output
accepted output=[1(A),2(B),3(A),3(A),3(B)]; last=1 only on final B

Equal heads select A one beat at a time, preserving both duplicates and consuming exactly one stream per output handshake.

What to cover

Requirements

  1. Buffer only the current head of each input stream.
  2. Require at least one accepted item on each input; this data-plus-last interface does not encode an empty frame.
  3. Consume exactly one input for each accepted output and never discard both heads on a tie.
  4. Hold output valid, data, and last stable while the consumer stalls.
  5. Assert out_last only on the final item after both input streams have ended.
Continue practicing

Related questions

Streaming RTLValidate nested protocol delimiters→RTL DesignAbsorb ready/valid backpressure with a skid buffer→RTL DesignImplement a synchronous FIFO with exact boundary behavior→
asic.fyi · Learn silicon end to end.info@asic.fyi