Skip to content
DenseChip
Learn
PracticeCode labInterview

DenseChip

Navigate

Menu

LearnPracticeCode labInterview

Tools

All toolsSV editorCode repoResume
DenseChip

Practice, courses, and chip-design tools in one focused workspace.

LearnPracticeCode labInterviewToolsLearning paths

© 2026 DenseChip

AboutRoadmapCareersInternshipsFAQContactPrivacyTerms
Skip to lesson

Course contents

  • Start Here5
  • SystemVerilog Language Foundations28
  • Object-Oriented SystemVerilog for Verification30
  • Constraint Randomization — Interview-Critical Deep Dive39
  • SystemVerilog Assertions — Interview-Critical Deep Dive41
  • Functional Coverage in SystemVerilog25
  • Testbench Architecture in SystemVerilog24
  • Advanced Language & Integration26
  • Senior & Interview Preparation23
  • Principal-Level Verification34
    • Reusable Testbench Architecture
    • Checking Out-of-Order Traffic
      • ID-Tagged Scoreboard
      • Multi-Stream Scoreboard
      • Drain and Leak Accounting
      • Leak and Hang Bench
      • Memory-Model Checker
    • Assertion Depth
    • Coverage Modelling for Real Features
    • Capstone: Out-of-Order Memory Controller
    • Principal Judgment
Loading lesson

←Checking Out-of-Order Traffic
  1. Topics
  2. SystemVerilog
  3. Principal-Level Verification
  4. Checking Out-of-Order Traffic
  5. Drain and Leak Accounting
On this page

    Part 9 of 9, lesson 8 of 34Part 9 of 9/Principal-Level Verification/Lesson 8 of 34Advanced

    Drain and Leak Accounting

    End-of-test accounting: issue times, in-flight watchdogs, bounded drain, and a report that names leaked tags and hung streams.

    Most escaped checking bugs are at the end

    A scoreboard that compares every response it sees can still pass a broken design. If a request is never answered, there is nothing to compare. The test ends, the queues are not empty, and nobody looks. End-of-test accounting closes that hole.

    Three faults need three different reports:

    Fault

    What you see

    Report

    Leak

    One request never answered; the DUT keeps working

    The ID or tag, when it was issued, and how long the DUT ran past it

    Hang (stuck stream)

    No responses at all for a long time while work is outstanding

    Time since last progress and the IDs waiting

    Drop with in-order IDs

    A later response on the same ID mismatches

    Data mismatch on that ID (the previous lessons)

    The third row is why this lesson uses unique tags. With a pool of tags, each tag has at most one request outstanding, so a dropped request shows up as a missing response instead of shifting every later comparison on that ID.

    What to record

    • Issue time per outstanding item, in a queue shaped like the expected queue.

    • Last progress time: the cycle of the most recent response of any kind.

    • A watchdog that warns once when an item passes the maximum latency. It finds the leak at the time it happens, not 10,000 cycles later.

    • A bounded drain: after stimulus stops, wait until nothing is outstanding or a limit passes. Never wait forever.

    The drivers must not hang either. A driver that waits forever for a free tag turns a DUT leak into a simulator timeout with no message. The driver in the bench lesson gives up after 100 cycles and says so.

    Leak or hang: one rule

    At the end of the drain, classify every item still outstanding:

    • If the DUT kept answering other requests for more than the maximum latency after this item was issued (last_progress - issued_at > max_lat), the item was leaked. The DUT was alive and skipped it.

    • Otherwise the item is stuck behind a hang. If nothing has come back for longer than the stall limit, the stream is stuck.

    Measuring against last_progress, not against the current time, is the whole trick. Every item looks old once the stream hangs; only the leaked one was old while the DUT was still working.

    Checking only outstanding() == 0 at the end, with a drain that waits forever. A leak then becomes a global timeout, and the log shows nothing but the timeout. Bound every wait and print what is left, by name.

    Choosing the limits

    • max_lat comes from the spec or the design's worst case under the test's traffic, plus margin. Here the worst case is about 16 cycles (9 cycles of latency plus seven tags ahead), so 40 is safe.

    • stall_limit is longer than any legal quiet period: refresh, power state exits, back-pressure the test applies on purpose.

    • Scale both with configuration. A fixed number tuned on one config gives false leaks on a slower one.

    Question: "Your regression times out once a week with no error. How do you make the bench tell you why?" Answer: record issue time per outstanding item, add a watchdog against the maximum latency, bound the drain, and at the end print every outstanding item with its ID, issue time and age, split into leaked items (the DUT kept working) and stuck items (the DUT stopped).

    A timeline of the two faults

    The bench in the next lesson plants two faults in one engine. Reading them on a timeline shows why the report needs both rules.

    Cycle

    Event

    What the accounting records

    23

    The third request on tag 5 is accepted and never answered

    Issue time 23 joins the outstanding list for tag 5

    63

    Tag 5 has waited 40 cycles, the maximum latency

    The watchdog warns once, long before the end

    About 100

    The engine stops sending any response

    Last progress is about cycle 100; every other tag still outstanding is now only waiting

    End of drain

    The drain limit passes with items left

    Tag 5 was outlived by more than 40 cycles of progress: leaked. The others are stuck behind the hang, and the stream has been quiet for 301 cycles

    Related topics

    • Previous: Multi-Stream Scoreboard

    • Next: Leak and Hang Bench

    • Compare and End-of-Test Checks (Part 5)

    • Debugging the Testbench

    Previous

    249 / 275

    Next: Leak and Hang Bench

    Up next

    Up nextLeak and Hang Bench

    Sign in to save progress

    Practice this lessonPrevious lessonReport an error

    See also

    • ID-Tagged Scoreboard
    • Memory-Model Checker