Lesson 1: Why Verification Matters and How to Write a Plan

Verification is the work of showing that a design does what its specification says before it is built. It matters because a bug found in simulation costs an edit and a rerun, while the same bug found in a manufactured chip can cost a new set of masks, months of delay or a recall. A verification plan is how a team decides what "verified" means: it lists every feature of the specification, how each one will be checked, what coverage will show it was tested, and which tests exercise it. Without a plan, a passing test only proves that the test passed.

Learning objectives

  • Explain why designs are verified before they are built, and why a passing test is not the same as a verified design
  • Write a verification plan as rows of feature, check and coverage goal, from a specification
  • Measure which plan rows a test exercised, and find the rows it never touched
  • Say what sign-off means: every test passing, every coverage goal met and every planted bug found

Prerequisites

  • Writing a simple Verilog testbench: a clock, a reset and a few test inputs
  • The synchronous FIFO: read its specification once; the plan below is written from it
  • The running example is the synchronous FIFO: 16 entries of 8 bits, one clock, flags full and empty and an occupancy count; writes when full are dropped, reads when empty are ignored, and read data appears one clock after the read. Its shared testbench code is in the site's repository under scripts/verification/fifo, and every example runs in AMD Vivado xsim 2025.2.

Why verification matters

A design is code, and like all code it has bugs. The difference is what a bug costs once it escapes. Software can be patched; a chip's logic is fixed in silicon, so every bug left at tape-out is either worked around in software, lived with, or fixed with new masks. That is why a large share of a chip project's effort goes into verification, and why verification engineers plan their work before they write a testbench. The goal is not to run many tests. It is to show, with evidence, that every feature in the specification works, including the corners nobody thinks about until they fail.

What a verification plan contains

A verification plan has one row per feature of the specification. Each row says how the feature is checked (a scoreboard comparison, an assertion, or both), what coverage proves the feature was exercised, and which test exercises it. The plan is written from the specification, not from the design, so it does not inherit the designer's assumptions. It is agreed with the designers and reviewed as the project goes on.

Verification plan: specification to features, checks and coverage goals, then tests, scoreboard, covergroups and sign-off
How a plan turns a specification into sign-off. Each feature row names its check and its coverage goal; features are run as tests, checks are built as the scoreboard and assertions, and goals are measured by covergroups. Sign-off needs all three.

The FIFO's verification plan

Here is the plan this course follows for the FIFO, written from its specification: 16 entries of 8 bits, writes when full dropped, reads when empty ignored, read data one clock after the read. Later lessons build each check and each coverage goal; this lesson measures how much of it a test exercises.

RowFeatureHow it is checkedCoverage goal
F1Data comes out in the order it went in, unchangedScoreboard: queue model, every read comparedCorner values 0, 255, 0x55 and 0xAA written
F2empty is 1 exactly when the FIFO holds nothingScoreboard every clock; assertionCount 0 reached
F3full is 1 exactly when it holds 16Scoreboard every clock; assertionCount 16 reached
F4count equals writes accepted minus reads acceptedScoreboard every clockEvery count value 0 to 16
F5A write when full is dropped, also with a read in the same clockScoreboard; assertionWrite, and write with read, while full
F6A read when empty is ignored, rd_data holdsScoreboard; assertionRead, and read with write, while empty
F7Read data appears one clock after the readScoreboard timingRuns of 2 to 16 reads in a row
F8Reset empties the FIFO from any stateDirected reset test; assertionReset when empty, part full and full
F9Pointers wrap from slot 15 to slot 0Scoreboard over long runsBoth pointers wrap
F10full and empty are never both 1AssertionNone: an invariant

Measuring a test against the plan

A plan is only useful if you can tell which rows a test exercised. The module fifo_plan keeps one counter per row and is bound into the FIFO, the same way assertions are bound in Lesson 9. A row whose counter stays at 0 was never tested, however clean the scoreboard was. F10 is an invariant, so its counter must stay at 0.

fifo/fifo_plan.sv: one counter per plan row
  always @(posedge clk) begin
    if (rst && !was_rst) f8_resets++;                         // F8: a reset after the run started
    was_rst = rst;
    if (!rst) begin
      clocks++;
      if (rd_en && !empty) begin f1_reads++; reads_in_row++; end else reads_in_row = 0;
      if (reads_in_row == 2) f7_back_to_back++;               // F7: two accepted reads in a row
      if (empty) f2_empty++;
      if (full) f3_full++;
      f4_counts[count] = 1;
      if (full && wr_en) f5_write_full++;
      if (empty && rd_en) f6_read_empty++;
      if (wr_en && !full && ++writes % 16 == 0) f9_wraps++;   // F9: the write pointer passes slot 15
      if (full && empty) f10_both++;
    end
  end
fifo_plan_tb.sv: bind
bind sync_fifo         fifo_plan plan (.*);
bind sync_fifo_planted fifo_plan plan (.*);

Worked example: a passing test against the plan

The same testbench runs twice: once with the 13-transaction directed test from Lesson 2 (four writes, four reads, three writes with reads, two more reads) and once with the phased random traffic from Lesson 7. The scoreboard checks every clock in both runs.

xsim output: +TRAFFIC=directed
17 clocks checked, 7 writes, 7 reads, 0 errors: PASS
directed: 17 clocks
  F1 data in order             7 reads compared
  F2 empty flag                7 clocks empty
  F3 full flag                 0 clocks full
  F4 count values              5 of 17 seen
  F5 write when full           0
  F6 read when empty           2
  F7 back-to-back reads        2
  F8 reset after the start     0
  F9 write pointer wraps       0
  F10 full and empty both      0 (must stay 0)
  rows exercised: 4 of 9
xsim output: +TRAFFIC=random
664 clocks checked, 288 writes, 286 reads, 0 errors: PASS
random: 664 clocks
  F1 data in order           286 reads compared
  F2 empty flag              150 clocks empty
  F3 full flag                48 clocks full
  F4 count values             17 of 17 seen
  F5 write when full          40
  F6 read when empty         105
  F7 back-to-back reads       61
  F8 reset after the start     0
  F9 write pointer wraps      18
  F10 full and empty both      0 (must stay 0)
  rows exercised: 8 of 9
FIFO plan rows exercised: a directed test reached 4 of 9 rows, random traffic reached 8
Plan rows exercised by each test, from the two runs. The directed test passed with 0 errors but never filled the FIFO, saw 5 of 17 count values, never wrapped a pointer and never reset mid-run. Random traffic reached 8 rows; reset after the start stayed at 0 in both.

Both runs pass, and both are incomplete. The directed test checked 7 reads and never came near full, so F3, F4, F5 and F9 were never exercised: planted bug 1, which only affects slots 8 to 15, cannot show up in it (Exercise 2). Random traffic reached 8 of 9 rows, but nothing in it resets the FIFO after the start, so F8 is still untested. The plan turns "the test passed" into a precise list of what is still unproven.

Common mistakes

  • Writing the plan from the design instead of the specification, so it inherits the designer's assumptions and their bugs.
  • Treating a passing test as done. The directed test above passed with 4 of 9 rows exercised.
  • Listing features without saying how each one is checked, so nobody knows which check would catch a failure.
  • Listing checks without coverage goals, so a check whose trigger never happens looks like a pass.
  • Writing the plan once and never updating it as the specification and the bugs found change.

Quick check

1. What three things does each row of a verification plan say about a feature?

How it is checked (scoreboard or assertion), what coverage shows it was exercised, and which test exercises it.

2. The directed test passed with 0 errors. Why is the FIFO not verified?

It exercised only 4 of the 9 testable plan rows. It never filled the FIFO, wrapped a pointer or reset mid-run, so bugs in those features could not show up.

3. Why is F10 an assertion with no coverage goal?

full and empty both high is never allowed, so there is nothing to reach: the rule is checked on every clock instead, and its counter must stay at 0.

Exercises

Graded from easy to hard. Try each one before you open the solution; every solution was run in xsim 2025.2, and its output is shown.

E1 (easy). Write a directed test that fills the FIFO and empties it again, and report the plan rows it exercises.

Sixteen writes and sixteen reads reach full, every count value and one wrap of each pointer: 6 of 9 rows, against 4 for the 13-transaction test.

fifo_plan_ex_tb.sv: E1
        1, 2: begin                                    // fill to full, then read everything back
          for (int i = 0; i < 16; i++) begin add(1, 0, 8'(i * 10)); end
          repeat (16) add(0, 1);
        end
xsim output: the rows that changed
36 clocks checked, 16 writes, 16 reads, 0 errors: PASS
  F3 full flag                 1 clocks full
  F4 count values             17 of 17 seen
  F9 write pointer wraps       1
  rows exercised: 6 of 9
E2 (easy). Run the E1 test on planted bug 1, which the 13-transaction directed test passed. What happens, and which plan row predicted it?

It fails with 8 errors: the reads from slots 8 to 15 return slots 0 to 7. F9, the pointer wrap, and F4, every count value, were the rows the short test never reached; a test that reaches them reaches the bug.

the run
DEFINES="-d BUG=1" PLUSARGS="-testplusarg EX=2" ./runfifo.sh fifo_plan_ex_tb
xsim output
clock 27: read 0, expected 80
clock 28: read 10, expected 90
clock 29: read 20, expected 100
36 clocks checked, 16 writes, 16 reads, 8 errors: FAIL
E3 (medium). F5 has two halves: a write when full alone, and with a read in the same clock. Write a test for both and count each half.

Fill the FIFO, then one write alone and one write with a read. Count the two halves apart, because a bug can live in only one of them, as planted bug 2 does in Lesson 7.

fifo_plan_ex_tb.sv: E3
  // E3: the two halves of plan row F5, counted apart.
  always @(posedge clk) if (!vif.rst && vif.full && vif.wr_en) begin
    if (vif.rd_en) full_wr_rd++; else full_wr++;
  end

        3: begin                                       // fill, then a write alone and a write with a read
          for (int i = 0; i < 16; i++) begin add(1, 0, 8'(i)); end
          add(1, 0, 99); add(1, 1, 98);
          repeat (16) add(0, 1);
        end
xsim output
38 clocks checked, 16 writes, 16 reads, 0 errors: PASS
  F3 full flag                 2 clocks full
  F5 write when full           2
  rows exercised: 8 of 9
E3: write when full alone 1, with a read 1
E4 (hard). Close F8: reset the FIFO when it is empty, half full and full, and check it is empty after each reset.

The environment's scoreboard model does not know about a reset in the middle of a run, so drive the pins directly for this test. Each reset is counted by the plan, and the check after it reads the flags.

fifo_plan_ex_tb.sv: E4
    if (ex == 4) begin
      // E4: reset at three levels, then check the FIFO is empty after each reset.
      int levels[3] = '{0, 8, 16};
      foreach (levels[k]) begin
        int level = levels[k];
        for (int i = 0; i < level; i++) drive(1, 0, 8'(i));
        drive(0, 0);
        @(negedge clk) vif.rst = 1;
        @(negedge clk) vif.rst = 0;
        @(posedge clk) $display("E4: reset at level %0d: empty %0d, count %0d", level, vif.empty, vif.count);
      end
      dut.plan.report("E4");
xsim output
E4: reset at level 0: empty 1, count 0
E4: reset at level 8: empty 1, count 0
E4: reset at level 16: empty 1, count 0
  F8 reset after the start     3
  rows exercised: 5 of 9

Interview questions

  • Q1. What goes into a verification plan? Answer: one row per feature from the specification, with how it is checked (scoreboard, assertion), what coverage proves it was exercised, and which test exercises it, plus the exit criteria for sign-off: all tests passing, coverage goals met and planted bugs found.
  • Q2. Your regression passes. How do you know you are done? Answer: compare it with the plan. A passing test only says nothing it checked failed; coverage of every plan row says what was actually exercised. Here a directed test passed with 4 of 9 rows exercised.
  • Q3. Why write the plan from the specification rather than the RTL? Answer: the RTL contains the designer's interpretation, including any misunderstanding. A plan written from the specification can catch a design that faithfully implements the wrong thing.

Summary

  • Bugs that escape to silicon are expensive, so verification shows with evidence that every feature works before tape-out.
  • A verification plan has one row per feature: how it is checked, what coverage shows it was exercised and which test runs it.
  • Measure tests against the plan: the FIFO's directed test passed but exercised 4 of 9 rows; random traffic exercised 8.
  • Sign-off needs every test passing, every coverage goal met and every planted bug found.

Related

Sources

Last verified

Run in Vivado xsim 2025.2 on 26 November 2026: the plan counters with the directed and the random traffic, and all four exercise solutions. Outputs are copied from those runs and kept in scripts/verification/results; lib/verificationCourse.test.js checks them against this page.

Keep going