Skip to question
asic.fyi
DesignVerificationSystemVerilogFirmwareArchitectureInterviews
asic.fyi/Interview questions/Validate nested protocol delimiters

Hardware interview practice

Validate nested protocol delimiters

HardStreaming RTLSystemVerilog

Consume a framed stream containing two kinds of open and close delimiters. Report whether nesting is balanced and return the first mismatch, underflow, overflow, or unfinished-open error.

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 frame=[OPEN_A,OPEN_B,CLOSE_B,CLOSE_A] with one stall between the middle tokens
Expected output
balanced=1; error=NONE

Parser state advances only on accepted tokens, and each close matches the most recent open type in strict stack order.

What to cover

Requirements

  1. Assume the producer ends each frame within 16 accepted tokens; enforce a nesting depth of at most eight.
  2. Update parser state only on an accepted token and keep consuming after the first error.
  3. Each close must match the most recent open of the same type.
  4. Hold the final result stable until it is accepted.
Continue practicing

Related questions

Streaming RTLMerge two sorted ready/valid streams→RTL DesignRoute a shared read bus without internal tri-states→RTL DesignAbsorb ready/valid backpressure with a skid buffer→
asic.fyi · Learn silicon end to end.info@asic.fyi