How a Test Ends
A run can end in a pass, a fail, a hang or a false pass. The last looks just like the first. Learn how a test decides it is finished, why it needs a time limit, and why it must count what never arrived.
You Will Be Able To
- Name the four ways a run can end.
- Say what a test must check before it may print PASS.
- Explain what a time limit is for and what it does not prove.
- Lesson
- B2.5
- Time
- 18 min
- Runs on
- Your browser
- Check
- 5 questions
A test sends three requests, waits a while, finds no wrong answers and prints PASS. The design under test never answered at all. Every check the test made was right; it simply had nothing to check.
- Test
- Result
- Control
- Pass
Every expected answer arrived and every one was right. Only then is PASS true.
- Fail
A check saw a wrong answer. The honest ending: the test caught something.
- Hang
The design never answers and the test waits for ever. A time limit turns a hang into a failure with a reason.
- False pass
The test stopped before the answers came, or never checked them, and printed PASS anyway. It looks exactly like a real pass.
Read the diagram as text
- A test runs: stimulus sent, answers awaited
- Pass: every answer came, every answer right
- Fail: a check found a wrong answer
- Hang: waits for ever, unless a limit stops it
- False pass: stopped early, or checked nothing
- A test runs → Pass: all answers, all right
- A test runs → Fail: a mismatch
- A test runs → Hang: no answer
- Pass → False pass: looks the same
The four endings of a run. A test must be able to tell the top two apart.
Before You Start
Read The Simplest Test That Can Fail first. It showed that a test that cannot fail is worse than none. Where the Right Answer Comes From warned that a scoreboard must be empty at the end.
| Question | |
|---|---|
| 1 | What are the four ways a run can end? |
| 2 | What must be true before a test may print PASS? |
| 3 | What is a time limit for? |
| 4 | Why does a test that checks every answer still pass on a silent design? |
| 5 | What does the end of a test look at that the middle does not? |
The Idea: The End Is a Check Too
Most of a test is about answers that arrive: each one is compared, and a wrong one is counted. But some bugs produce no answer at all. A design that stops responding, drops a request, or locks up gives the checks nothing to compare. No comparison, no mismatch, no error.
So the end of a test needs its own checks. Did every expected answer arrive? Is anything still waiting in the scoreboard? Did the run end because the work was done, or because time ran out?
There is a second danger: waiting for ever. If the test waits for an answer that never comes, the run hangs. A time limit stops it and turns the hang into a failure with a clear reason. Nobody has to kill the job by hand.
New Words
| Word | Meaning |
|---|---|
| End-of-test condition | What must be true for a test to finish: all stimulus sent and all expected answers received. |
| Hang | A run that never finishes, usually because it waits for something that never happens. |
| Timeout | A limit on waiting. When it runs out, the test stops and reports a failure. |
| False pass | A run that reports PASS although the design was wrong or was never really checked. |
| Drain | Waiting, after the last stimulus, for answers still inside the design to come out. |
Four Endings, Decided by Hand
A test sends three requests to a design that should answer each one. Apply the end checks to four runs by hand.
| What happened | Answers arrived | Wrong answers | Honest verdict |
|---|---|---|---|
| Three right answers | 3 of 3 | 0 | pass |
| The second answer is wrong | 3 of 3 | 1 | fail |
| No answer ever comes; the test waits | 0 of 3 | 0 | hang, stopped by the timeout: fail |
| Two answers come, then nothing | 2 of 3 | 0 | timeout: fail (2 of 3) |
Look at the "wrong answers" column. Three of the four runs have zero. A test that looks only at that column passes three runs, two of them falsely. The "answers arrived" column is what tells them apart.
The Rules
Rule 1: PASS needs every expected answer to arrive and be right.
Zero errors alone is not enough: a silent design has zero errors.
Rule 2: Every wait has a time limit.
A timeout turns a hang into a failure with a reason.
Rule 3: A timeout is a failure, never a pass.
It means the work did not finish, whatever the error count says.
Rule 4: Drain, then sweep.
After the last stimulus, wait for answers in flight; then report anything still expected and never received.
Sources for These Rules
Spear and Tumbush (2012), section 1.12: the run phase waits for the test to complete. It uses time-out checkers so the DUT or bench cannot lock up. The wrap-up phase sweeps the final transactions out, then reports. Lost data can sit in the scoreboard.
The Lab: A Design That Never Answered
The lab's design is doubler: it answers each request with twice its data, three clocks later. A second copy is built to never answer. Two tests watch the same run of each design: a naive one and an honest one.
while (quiet < 20) begin
@(negedge clk);
if (ack) begin got++; quiet = 0; if (q !== want.pop_front()) errors++; end
else quiet++;
endEvery arriving answer is compared with the expected one, which waits in a queue. quiet counts clocks with no answer; 20 quiet clocks end the wait. The naive test then looks only at errors. The honest test also looks at got, the number of answers that arrived.
a design that answers: naive test says PASS
a design that answers: honest test says PASS
a design that never answers: naive test says PASS
a design that never answers: honest test says FAIL (timeout: 0 of 3 answers)On the working design both tests say PASS, and both are right. On the silent design the naive test still says PASS: zero answers, zero errors. That is a false pass, and rule 1 is what it broke. The honest test says FAIL with a reason: a timeout, with 0 of 3 answers.
Notice that the naive test made no wrong comparison. Every check it ran was correct. The bug was in deciding when it was finished, and what finished had to mean.
Why the Work Decides the End
Why not give every test a long fixed wait, then report? Because a fixed wait is wrong both ways. Too short, and it cuts off a slow but correct design. Too long, and every test wastes time after its work is done. Neither one counts missing answers.
A better end is driven by the work. Finish when every expected answer has arrived, after a short drain for stragglers. Keep a time limit only for the case where the work never finishes. Measure that limit from the last sign of progress, so a long but busy test is not cut off.
Traps
The first trap is the false pass in the lab: errors counted, arrivals not. It hides every bug that makes a design go quiet, which includes many of the worst ones.
The second trap is a timeout reported as a warning, or as a pass because no error was seen. A run that ran out of time did not finish its work. It is a failure, and its reason should say "timeout" so nobody mistakes it for a wrong answer.
The third trap is ending at the last stimulus. Answers are still inside the design, three clocks behind. A test that stops when it sends its last request never checks the last answers.
At Scale
This section looks ahead. Big benches have many parts, each with work in flight.
Everyone agrees to stop
Each part of the bench says when it is busy; the run ends only when all of them are done. UVM calls this raising and dropping objections.
Watchdogs everywhere
Large benches put a progress watchdog on each interface, so a hang is named where it happens.
Where This Goes Next
This lesson ended a test honestly. These lessons teach the tools for it.
| The idea from this page | Where it is taught |
|---|---|
| Running many tests every night, and sorting what failed | Regressions, Seeds and the Life of a Bug |
| Waiting for a response with a bound | A Bounded Response Wait |
| Running a watcher and a stimulus side by side | Fork, Join and Cancellation |
| Ending a UVM test: objections | Objections and Premature Completion |
| What the end of a run means for an assertion | Weak and Strong: What the End of a Test Means |
| Ending a chip-level test honestly | Ending a Test Honestly |
Try It
Run the lab. Compare the two verdicts for the silent design.
Build a design that answers only twice (MODE 2). Predict the honest verdict before you run it.
Lower the quiet limit to 2 clocks. What happens to the working design, and why?
a design that answers: naive test says PASS a design that answers: honest test says PASS a design that never answers: naive test says PASS a design that never answers: honest test says FAIL (timeout: 0 of 3 answers)Check Yourself
Common Mistakes
Wrong Print PASS when the error count is zero.
A design that never answers has zero errors.
Fix Print PASS only when every expected answer arrived and all were right.
Wrong Wait a fixed time, then report.
Too short cuts off correct answers; too long wastes time; neither counts missing answers.
Fix End when the work is done, after a drain, with a timeout from the last progress.
Wrong Treat a timeout as a warning.
The work did not finish, so nothing about it was shown.
Fix Report a timeout as a failure, with its reason.
Remember
- A run ends in a pass, a fail, a hang or a false pass, and a false pass looks like a pass.
- PASS needs every expected answer to arrive and be right; zero errors is not enough.
- Every wait needs a time limit, and a timeout is always a failure.
- End when the work is done: drain the answers in flight, then report what never arrived.