Ending a Test Honestly
A firmware test that writes 0x900D has not necessarily passed. Learn the five ways soc_tb ends a run, in order of authority, and the false pass each rule stops. The bench's own gate shows each one.
You Will Be Able To
- List the five ways a soc_tb run ends, in order of authority.
- Name the false pass each rule prevents.
- Explain why the first status word is the end of a test.
- Tell a hang from a legal sleep, and say what the no-progress limit counts.
- Lesson
- V3.7
- Time
- 26 min
- Runs on
- Your browser
- Check
- 5 questions
Picture a log that says PASS in green. The firmware wrote 0x900D and the console is tidy. Two screens up sits a bus checker's line: a rule broken early in the run. The test passed on a broken chip, because nobody decided who has the last word.
- Test
- Control / FSM
- Clock / reset
- Result
- Control
- The bench speaks first
A checker error ends the run whatever the firmware says.
- Then the test
The first fail word ends it; nothing after it counts.
- Then the limits
A run that never ends, or stops moving, is ended and called a fail.
- Only then a pass
A pass word with main entered, no errors and, with the core, at least one compared record.
Read the diagram as text
- 1. A checker error: a bus rule, a monitor, the model, a bench check
- 2. A fail word: the first status word that counts
- 3. The cycle limit: +max, 400,000 by default
- 4. No progress: nothing retired or transferred
- 5. A pass word: and main entered, zero errors
- 1. A checker error → 2. A fail word: else
- 2. A fail word → 3. The cycle limit: else
- 3. The cycle limit → 4. No progress: else
- 4. No progress → 5. A pass word: else
The order of soc_tb (README, "The end of a test"; plan §3.5).
Before You Start
Read Passive Checkers: Bind and Listen and The First Run first.
| Question | |
|---|---|
| 1 | In what order does soc_tb decide how a run ended? |
| 2 | Why does a checker error outrank a pass word? |
| 3 | Why is the first status word the end? |
| 4 | How does the bench tell a hang from a sleep? |
| 5 | What must be true besides the pass word for a pass? |
The Idea: The Bench Keeps the Last Word
Self-checking firmware is convenient: it writes a pass word when its checks hold. But firmware sees only what it reads back. A bus rule broken on the way, a byte that never reached the pad, a run that never ended. None of these reaches the firmware's checks.
So the bench keeps the last word. It asks a fixed list of questions in a fixed order, and the pass word is only the last of them. Each question stops one way a test can pass falsely. One of them was learned the hard way. Until the bench's own gate tested it, a fail word followed by a pass word counted as a pass.
New Words
| Word | Meaning |
|---|---|
| Pass word | TB_STATUS = 0x900D, written by the test to say it passed. |
| Fail word | TB_STATUS = 0xBAD0_0000 plus a code, written by the test to say it failed. |
| False pass | A run reported as a pass while the chip or the test did something wrong. |
| Cycle limit | The most cycles a run may take (+max); a budget, not a measurement of the chip. |
| No-progress limit | The most cycles with nothing retired (with the processor) or nothing transferred (with the seat). |
| Order of authority | The order in which the bench's end rules are asked; the first that applies decides. |
| Objection | UVM's way of ending a phase: components raise objections while they work and drop them when done. |
The Smallest Example: Decide Three Runs by Hand
Apply the order to three runs. Ask the five questions top to bottom and stop at the first yes.
| What happened | First yes | Verdict |
|---|---|---|
| A bus rule broke; later the firmware wrote 0x900D | 1: a checker error | fail (checker) |
| The firmware wrote 0xBAD0_0007, then 0x900D | 2: the first status word was a fail word | fail (status_fail) |
| The firmware wrote 0x900D but never TB_STATUS = 2 | none of 1 to 4; the pass lacks main entered | fail (pass_without_main) |
The Rules
Rule 1: A checker error ends the run, whatever the test says.
A broken bus rule, a block monitor, a model mismatch, a failed bench check. It stops "the firmware passed, but the chip broke a rule".
Rule 2: The first status word is the end.
A fail word ends the test; a pass word written after it changes nothing. It stops "fail, carry on, pass".
Rule 3: The cycle limit ends a run that does not end.
It stops a hung test from passing by timeout in a script that only greps for errors.
Rule 4: No progress ends a run that stopped moving.
Nothing retired for +noretire cycles is a hang, unless the core sleeps in wfi with an interrupt enabled. It finds a hang long before the cycle limit.
Rule 5: A pass needs more than the pass word.
Main entered, zero checker errors, zero mismatches, and with the core at least one compared record. It stops "a pass word from code that never ran the test".
Sources for These Rules
The order, each rule and the result reasons: tools/soc/ap_soc/bench/soc_tb/README.md, "The end of a test"; soc_tb.sv; plan §3.5.
The nine cases: check-soc-bench.mjs, step ends (stage E7 of plan §3.10).
UVM ends a run phase when every objection has been dropped: UVM Cookbook, End of Test Mechanisms (UVM-CB). See also IEEE 1800.2-2020 clause 10.5 (uvm_objection).
The Lab: Nine Runs That Would Pass Falsely
while (!stop) begin
@(posedge clk_sys);
if (checker_errors != 0) begin stop = 1'b1; end_reason = "checker"; end
else if (done) stop = 1'b1;
else if ((cycles >= max_cycles) || (ticks >= max_cycles)) begin stop = 1'b1; end_reason = "cycle_limit"; end
else if (idle >= no_retire) begin stop = 1'b1; end_reason = "no_progress"; end
endEach of the nine cases is a run that would have passed if its rule were missing. They ran again on the site's pre-built chip bench for this lesson.
checker_bus verdict=fail reason=checker status=0000900d cycles=19
checker_bench verdict=fail reason=checker status=0000900d cycles=71
table_left verdict=fail reason=checker status=0000900d cycles=325checker_bus: RULE align broken at edge 28: a 4-byte transfer at 0x40000002 is not aligned to its size
checker_bench: BENCH 63: row 0: no byte came on the UART pad, expected 41
table_left: BENCH 317: table: the test ended at row 0 of 2In checker_bus the bus-manager seat made a word transfer at an address that is not a multiple of 4. Every answer was the expected one, so the table alone would have written 0x900D. The AHB checker ended the run at cycle 19. In checker_bench and table_left the firmware passed, but the bench's own side had not finished: a byte never came, rows never ran.
fail_then_pass verdict=fail reason=status_fail status=bad00007 cycles=25
cycle_limit verdict=fail reason=cycle_limit status=00000002 cycles=2008
cycle_limit_off verdict=pass reason=pass status=0000900d cycles=6024fail_then_pass wrote 0xBAD0_0007 and then 0x900D; the status that counts is bad00007. cycle_limit is a slow program with +max=2000: it stopped at 2008 cycles with only "main entered" written. The same program passed with the default limit, at 6024 cycles. The limit measured the budget, not the chip.
no_progress verdict=fail reason=no_progress status=00000002 cycles=3027
wfi_armed verdict=pass reason=pass status=0000900d cycles=5053
no_main verdict=fail reason=pass_without_main status=0000900d cycles=21no_progress sleeps in wfi with no interrupt enabled: found at 3027 cycles of a 200,000 limit. wfi_armed sleeps for 5,000 cycles with the timer armed, longer than the no-progress limit of 3,000. It passes, because the bench counts an armed sleep as waiting. no_main writes 0x900D and nothing else, and the bench calls it pass_without_main.
Why It Is Built This Way
Why put the checkers above the test? Because the test is the thing under suspicion. A checker has no stake in passing. A test that breaks a bus rule but writes 0x900D anyway is the case the bench exists to catch.
UVM solves the same problem differently: a run ends when every component has dropped its objection, and the report server counts errors. soc_tb's UVM front end keeps both. A UVM test writes the pass word only when UVM counted no error, and the bench's order still decides.
Traps
The first trap is a test that keeps going after a failure. A helper writes the fail word on a bad value and returns. The test runs on to print "done" and write 0x900D. The console looks perfect. The bench reports the first word, so read the status, not the console.
The second trap is a limit set too tight. Raise the clock divider in a test and its UART bytes take twice as long. The run now ends at its cycle limit. Read the reason before the verdict: cycle_limit says "the budget ran out", not "the chip is wrong".
At Scale
This section looks ahead. One soc_tb run gives one result block.
Regression triage
Thousands of runs a night are sorted by reason first: checker, status_fail, limits. Each reason has an owner.
Watchdogs everywhere
Large benches add a watchdog per bus and per protocol model. A hang is then named at its place, long before the run limit.
Signed results
Farms check that the result block belongs to this run; soc_tb repeats the run's own word for it. So no test can print a fake pass.
Try It
Run it: the order of authority applied to what happened in each of the nine cases, against the reason the bench gave.
Swap rules 1 and 2 in decide. Which case changes, and what false result would it give?
Change no_main's facts so main is entered. What does the rule now say?
checker_bus rule: checker, bench: checker checker_bench rule: checker, bench: checker table_left rule: checker, bench: checker fail_then_pass rule: status_fail, bench: status_fail cycle_limit rule: cycle_limit, bench: cycle_limit cycle_limit_off rule: pass, bench: pass no_progress rule: no_progress, bench: no_progress wfi_armed rule: pass, bench: pass no_main rule: pass_without_main, bench: pass_without_main 9 of 9 agree with the benchCheck Yourself
Common Mistakes
Wrong Grep the log for PASS.
A pass word can follow a fail word or a broken bus rule.
Fix Read the result block's verdict and reason; the bench decides.
Wrong Treat a cycle-limit failure as a chip bug.
The same program can pass with a larger budget.
Fix Read the reason first; size the limit from the test.
Wrong Let a helper write the fail word and return to the test.
The test runs on, and its later output misleads whoever reads the console.
Fix Write the fail word and stop, or let the start-up code report main's return value.
Remember
- Order of authority: checker error, fail word, cycle limit, no progress, pass word.
- Each rule stops one kind of false pass.
- The first status word is the end; a later pass word does not mend a fail.
- A pass also needs main entered, zero errors, zero mismatches and, with the core, a compared record.