Capstone: Verify a Small Design End to End
Put the whole track together on one small design: a plan, a self-checking bench, two checks, hit counts and a sign-off. Then do it yourself for a FIFO with hidden bugs.
You Will Be Able To
- Write plan rows for a small design, each with stimulus, check and coverage.
- Build a self-checking bench with directed and random stimulus.
- Use two checks of different kinds, and hit counts for the plan's situations.
- Sign off against the plan, and say plainly when the answer is "not yet".
- Lesson
- B4.6
- Time
- 30 min
- Runs on
- Your browser
- Check
- 5 questions
The directed tests passed, every one. Then two hundred random cycles ran, and the first check reported 44 errors. Each one was a cycle where up and down arrived together, the one row of the plan that only random stimulus reached.
- Design
- Step
- Driver
- Test
- Result
- Control / FSM
- Data
- Plan
Read the specification into rows: what must be shown, how, and how to know it ran.
- Bench
Directed stimulus for the ends; random stimulus for everything else.
- Checks
Two checks look at every cycle: one against a model, one a rule that always holds.
- Coverage
Hit counts show which plan situations the stimulus really reached.
- Sign-off
Done means every check passed and every bin was hit, against the plan.
Read the diagram as text
- Specification: sat_counter: up, down, stop at 0 and 15, both = hold
- Plan rows: P1 to P5
- Bench: directed and random stimulus
- Two checks: the model's value; never a jump of 2
- Hit counts: top, bottom, both
- Sign-off: every row closed, every bin hit
- Specification → Plan rows: read into
- Plan rows → Bench: drives
- Bench → Two checks: checked by
- Bench → Hit counts: counted by
- Two checks → Sign-off: all pass
- Hit counts → Sign-off: no holes
An idea drawing of the lab below. Your capstone problem does the same for a FIFO.
Before You Start
This capstone uses the whole track. The design is the counter from Code Coverage: What Ran; the method is the plan from The Verification Plan.
| Question | |
|---|---|
| 1 | What goes into the plan of a small design? |
| 2 | Why does the bench need both directed and random stimulus? |
| 3 | Why two checks, and of what kinds? |
| 4 | What do the hit counts add to passing checks? |
| 5 | When is a design signed off, and what does "not yet" mean? |
The Idea: One Design, the Whole Method
Each lesson so far took one idea and one tiny design. A real verification task uses them all at once, in a fixed order. First the plan says what must be shown. Then the bench drives the design and checks it. Then the results and the coverage say whether the plan was met.
The order matters. A bench written before the plan tests what was easy to write. A plan with no coverage cannot tell a passing row from one that was never reached. Sign-off is not a feeling at the end. It is a check of every plan row against what the run produced.
The design here is the saturating counter from Code Coverage: What Ran. There, full code coverage missed its bug. Here, the full method finds it, and shows exactly which row did.
New Words
| Word | Meaning |
|---|---|
| Self-checking bench | A bench that decides pass or fail by itself, with no person reading waves. |
| End to end | From the specification to sign-off, every step done on one design. |
| Hit count | The number of times a plan situation happened during the run: plain functional coverage. |
| Sign-off | The decision that verification is done, made against the plan. |
| Saturating counter | A counter that stops at its smallest and largest values instead of wrapping round. |
The Smallest Example: The Counter's Plan
The specification: count up or down by one; stop at 0 and at 15; up and down together hold the count. Read it into rows.
| Row | Feature | Stimulus | Check | Coverage |
|---|---|---|---|---|
| P1 | Counts up by one | directed: 16 ups from 0 | model value | - |
| P2 | Stops at 15 | directed: up past the top | model value; never a jump of 2 | top: up while at 15 |
| P3 | Counts down, stops at 0 | directed: 16 downs | model value | bottom: down while at 0 |
| P4 | Up and down together hold | random up and down | model value | both: up and down together |
| P5 | Any mix of moves | random, 200 cycles, seed 3 | both checks every cycle | all three bins above |
Each row has a way to reach it and a way to check it. Where it matters, a count proves it was reached. Row P4 is the one the code coverage lesson missed. Here it has its own bin, so it cannot be skipped quietly.
The Rules
Rule 1: Plan first.
Write the rows from the specification before the bench. The bench then serves the plan.
Rule 2: Directed for the ends, random for the rest.
Directed stimulus hits the exact corners; random stimulus reaches what nobody listed.
Rule 3: Two checks of different kinds.
A model comparison catches wrong values. A rule that must always hold catches what a model shares with the design.
Rule 4: Count the plan's situations.
A hit count per coverage row shows the stimulus reached it.
Rule 5: Sign off against the plan.
Done when every check passed and every bin was hit. Otherwise the answer is "not yet", with a reason.
Sources for These Rules
Basic testbench steps, from generating stimulus to measuring progress against the goals: Spear and Tumbush, section 1.3.
The plan and its parts: Mehta, ASIC/SoC Functional Design Verification, section 2.2.
The Lab: The Counter, End to End
The bench drives sat_counter with 16 ups and 16 downs, then 200 random cycles from seed 3. On every cycle it updates a model, runs both checks and updates the hit counts.
if (cnt !== want) begin err_value++; want = cnt; end // check 1: the model
if (cnt > prev + 1 || prev > cnt + 1) err_step++; // check 2: never a jump of 2
if (u && want == 15 && !d) hit_top++; // coverage: up at the top
if (u && d) hit_both++; // coverage: up and down togetherdirected: value errors 0, step errors 0
random: value errors 44, step errors 0
hits: top 8, bottom 1, both 44
sign-off: not yetRead it top to bottom, as a sign-off review would. The directed part passed. The random part found 44 value errors and no step errors: up won every time up and down arrived together. Rule 3 at work: the step check stayed silent, because the bug never jumps by two. Only the model saw it.
Rule 5 at work: "not yet". The specification says hold; the design says up. Fix the design, run the same bench and seed, and the review reads differently:
directed: value errors 0, step errors 0
random: value errors 0, step errors 0
hits: top 1, bottom 4, both 44
sign-off: every check passed and every bin was hitEvery check passed and every bin was hit. The bin counts changed too, because the fixed counter follows a different path through the same random moves. That is why sign-off reads the numbers of the final run, not of an earlier one.
Why Two Checks and Hit Counts
Why two checks if the model already caught the bug? Because a model is written by a person who may misread the specification in the same way as the designer. A rule that must always hold is a second opinion that does not depend on the model. Here that rule is "never a jump of two".
Why count hits when the checks already pass? Because a check can only fail on situations that happen. If the random part had never pressed up and down together, P4 would pass by never being tested. The count is what turns "no errors" into "no errors, and every row was reached".
Traps
The first trap is signing off on checks alone. Zero errors with an empty bin means that situation was never tested. Read the coverage before the word "pass".
The second trap is a bench that follows the design. If the model copies the design's value after every cycle without counting a difference, it can never report one. Count a difference before you resynchronise, as this bench does.
The third trap is a capstone without its hidden bugs. A bench is only as good as the bugs it catches. Your problem checks your bench against a correct FIFO and against several broken ones. Each broken one must make your bench fail.
Your Turn: A FIFO with Hidden Bugs
The two problems of this lesson ask you to do the same for a FIFO four entries deep. First you write its plan rows. Then you write a self-checking bench with directed and random tests, two checks and two hit counts.
Your bench runs against a correct FIFO and against several FIFOs with hidden bugs. It must stay silent on the correct one and fail on every broken one. The corners of Corner Cases and How to Think of Them are a good start, and you may reuse its ideas.
Where This Goes Next
You have walked the whole method once. These tracks turn each step into a craft.
| The idea from this page | Where it is taught |
|---|---|
| A layered FIFO bench in SystemVerilog, step by step | Build the Generator and Driver |
| The complete layered testbench | The Complete Layered Testbench |
| The same bench built with UVM | From a Layered Bench to UVM |
| A coverage model capstone | Capstone: A Coverage Model That Finds Holes |
| Signing off with formal | The Sign-Off Argument |
Try It
Run it: directed then random stimulus, two checks, three hit counts, and a sign-off line.
Fix sat_counter so up and down together hold the count. Predict the last line.
Remove the random part. Which bin stays at 0, and what does the sign-off line say?
directed: value errors 0, step errors 0 random: value errors 44, step errors 0 hits: top 8, bottom 1, both 44 sign-off: not yetCheck Yourself
Common Mistakes
Wrong Write the bench first and the plan afterwards.
The bench then tests what was easy, and the plan is written to match.
Fix Write plan rows from the specification first.
Wrong Sign off because the checks report zero errors.
A situation that never happened cannot fail.
Fix Sign off only when every check passed and every bin was hit.
Wrong Use one check for everything.
A model can share a misreading with the design.
Fix Add a second check of a different kind, such as a rule that must always hold.
Remember
- End to end means plan, bench, results and coverage, in that order, on one design.
- Directed stimulus hits the corners; random stimulus reaches what nobody listed.
- Two checks of different kinds, plus hit counts for the plan's situations.
- Sign off against the plan: every check passed and every bin hit, or "not yet".