A Chip You Cannot Patch

Software ships a fix overnight. A chip cannot. See why every chip is checked before it is built and how the price of a bug grows. Then see why "it compiles" proves almost nothing.

You Will Be Able To

  • Explain why hardware is verified before it is built.
  • Describe how the cost of a bug grows from code to silicon, as a shape.
  • Show that code which compiles and passes a few sums can still be wrong.
Lesson
B1.1
Time
18 min
Runs on
Your browser
Check
5 questions

A phone app ships with a bug on Monday and a fix on Tuesday. A chip ships with a bug, and the bug is in every copy, cut into silicon. There is no update button for a wire. So how do engineers find the bugs before the chip exists?

The Road from an Idea to a ChipStep along the road. Before tape-out, a bug is a change to a text file. After it, the same bug is a change to glass masks, or a product in someone's hand.
  • File
  • Design
  • Test
  • Tool
  • Result
  • Device
  • Measure
  • External
  • Data
The Road From an Idea to a ChipStep along the road. Before tape-out, a bug is a change to a text file. After it, the same bug is a change to glass masks, or a product in someone's hand. file Idea andspecification what the chip must do design RTL design the chip as code test Verification simulate and checkthe code tool Synthesis andlayout code becomes gates,then shapes result Tape-out the point of noreturn device Fabrication masks and wafers measure First silicon the real chip on a labbench external In customers'hands millions of copies writecheckbuildsendmaketestship
  1. file Idea and specificationwhat the chip must do
    • write → RTL design
  2. design RTL designthe chip as code
    • check → Verification
  3. test Verificationsimulate and check the code
    • build → Synthesis and layout
  4. tool Synthesis and layoutcode becomes gates, then shapes
    • send → Tape-out
  5. result Tape-outthe point of no return
    • make → Fabrication
  6. device Fabricationmasks and wafers
    • test → First silicon
  7. measure First siliconthe real chip on a lab bench
    • ship → In customers' hands
  8. external In customers' handsmillions of copies
  1. The cheap part of the road

    Everything up to layout is files. A bug found here is fixed by editing a line and running the checks again.

  2. Tape-out

    The finished layout goes to the factory. From here on, the design is no longer a file you can edit.

  3. The expensive part

    A bug found now needs new masks and another trip through the factory, or a software work-around, or a recall.

Read the diagram as text
  • Idea and specification: what the chip must do
  • RTL design: the chip as code
  • Verification: simulate and check the code
  • Synthesis and layout: code becomes gates, then shapes
  • Tape-out: the point of no return
  • Fabrication: masks and wafers
  • First silicon: the real chip on a lab bench
  • In customers' hands: millions of copies
  • Idea and specification → RTL design: write
  • RTL design → Verification: check
  • Verification → Synthesis and layout: build
  • Synthesis and layout → Tape-out: send
  • Tape-out → Fabrication: make
  • Fabrication → First silicon: test
  • First silicon → In customers' hands: ship

The flow of a chip project, drawn as a road. Verification sits before tape-out because that is the last place a fix is only an edit.

Before You Start

You need only basic digital logic: gates, a binary adder, a flip-flop. If an adder is new to you, start with Half Adders, Full Adders and Ripple Carry. You have seen a little Verilog or SystemVerilog, enough to read an assign. Nothing else is assumed. This is the first lesson of the Design Verification domain.

Five questions this page answers
Question
1Why must a chip be checked before it is built?
2Where on the road from idea to chip does a bug become expensive?
3Why do "it compiles" and a few correct sums prove so little?
4What does a check that tries every input find that a few hand checks miss?
5Who finds which bugs, and where?

The Idea: Find It While It Is Still Text

For most of a chip project, the chip is text. Engineers describe it in a hardware language, as RTL code. Tools turn that code into gates, and the gates into the shapes of a layout. While the chip is text, a bug costs an edit and a rerun.

Then comes tape-out. The layout goes to a factory, which makes glass masks and prints the chip onto silicon wafers. From that moment the design is physical. A wrong wire is wrong in every copy, and nothing you type will change it.

Design verification is the work of finding bugs in the design before tape-out. You simulate the RTL, drive its inputs, and check every output against what the chip is supposed to do. A verification engineer reads the same specification as the designer. Then they ask, on their own, "does this code really do that?"

New Words

New words on this page
WordMeaning
SpecificationThe document that says what the chip must do. Often shortened to "spec".
RTLRegister-transfer level: the chip written as code, flip-flops and the logic between them.
SynthesisThe tool step that turns RTL code into gates.
Design verificationChecking, before the chip is made, that the RTL does what the specification says.
SimulationRunning the RTL in a program, the simulator, that computes every signal, clock by clock.
TestbenchCode written around a design to drive its inputs and check its outputs. Often shortened to "bench".
Tape-outSending the finished layout to the factory. After it, the design can no longer be edited.
Smoke testA quick first check that a design works at all, usually a few inputs picked by hand.
RespinMaking the chip again with corrected masks, because the first silicon had a bug.
First siliconThe first real chips back from the factory, tested on a lab bench.

The Price of a Bug, as a Shape

The same bug costs very different amounts depending on where it is found. Read the table from top to bottom. The work grows at each step, and it jumps at tape-out.

One bug, found at different places on the road
Found duringWhat the fix takesWho usually finds it
Writing the RTLEdit one line, run the block againThe designer, in a quick test
Block verificationEdit, rerun the tests that touch itThe verification engineer
Chip-level verificationFind which block, edit, rerun many testsThe chip verification team
After tape-out, before masks are madeChange the layout, redo the late checksA late review, or a simulation of the gates
First silicon in the labNew masks and a respin, or a software work-aroundThe lab bring-up team
In customers' handsA work-around, a recall, a lost customerThe customer

No row has a number, on purpose. Costs depend on the chip, the factory and the market. The shape is what matters: cheap and fast before tape-out, slow and expensive after it. One textbook gives a rough rule for that shape; the sources below name it.

The Rules

  1. Rule 1: A chip cannot be patched.

    After tape-out every copy carries the same wires. A design bug is fixed only by new masks, or worked around.

  2. Rule 2: Find bugs while the chip is text.

    Before tape-out a fix is an edit. Verification exists to move bug finding to this side of the road.

  3. Rule 3: Compiling proves syntax, not behaviour.

    A tool accepts any legal code, right or wrong. Only a check against the specification shows the code does the job.

  4. Rule 4: A few right answers prove very little.

    Each check covers the inputs it tried and nothing else. Untried inputs are unknown, not correct.

Sources for These Rules

Spear and Tumbush, SystemVerilog for Verification, 3rd ed. (2012), section 1.1: the verifier makes an independent reading of the specification; section 1.1.1: bugs found at block, integration and system level.

Spear and Tumbush (2012), section 1.15, gives a rough rule for the shape. The cost of a fix grows about tenfold at each step, from specification to the field. That is the book's figure, not a measurement on this site.

Mehta, ASIC/SoC Functional Design Verification (2018), section 1.1: verification takes a large share of project effort. Section 1.2 shows a market study from 2002 and 2004. In it, logic and functional flaws lead the causes of respins.

Mehta (2018), section 15.2: the product flow from specification to release. Section 15.5: verification should drive the design, not follow it.

The Lab: One Wrong Line

The lab holds adder4, a 4-bit adder written one bit at a time. Each bit adds a, b and the carry from the bit below. One line has a mistake. Here is the carry into bit 3:

The carry into bit 3. A full adder's carry has three terms; this one has two.
assign c3 = (a[2] & b[2]) | (a[2] & c2);   // one term is missing

An assign connects a wire to a logic expression, here an OR of ANDs. The line is legal code, so it compiles with no error and no warning. Nothing about it looks wrong at a glance.

Around the adder sits a testbench, the bench for short. It first does what people often do: a smoke test. It tries three sums by hand, to see that the design works at all. Then it tries all 256 pairs of 4-bit inputs and compares each sum with the right answer.

Printed by the lab (Icarus).
smoke test: 1 + 1 = 2
smoke test: 3 + 4 = 7
smoke test: 5 + 5 = 10
all 256 input pairs: 24 wrong; the first is 1 + 7 = 0

Read the first three rows: 1 + 1 = 2, 3 + 4 = 7 and 5 + 5 = 10. All correct. Rule 4 says what they prove: those three sums, and nothing more. The last row tells the real story. 24 of the 256 sums are wrong, and the first is 1 + 7, which the adder says is 0.

Why did the hand checks miss it? The missing term matters only when bit 2 of a is 0, bit 2 of b is 1, and a carry arrives from below. None of the three hand-picked sums does all three at once.

Why Every Input Was Possible Here, and Rarely Is

This adder has 256 input pairs, so the bench could try them all in a blink. A 32-bit adder has about 18 billion billion pairs. No simulator can try them all before the chip is due.

So real verification cannot be "try everything". It is a set of methods for choosing what to try, knowing the right answer, and measuring what was missed. The rest of this track teaches those methods. The next lesson starts by separating verification from two jobs that sound like it.

Traps

The first trap is trusting the tools. The code compiled, the linter (a tool that flags risky coding style) was quiet, and the synthesis report looked normal. Each of those tools checks that the code is legal and buildable. None of them knows what an adder is for.

The second trap is the friendly test. A designer writes a quick test with the cases they were thinking about when they wrote the code. The test passes, because it shares the designer's blind spot. This is why verification is often done by a second person, reading the specification on their own.

The third trap is believing a bug is rare, so it does not matter. A wrong sum in 24 of 256 cases will appear the first time real software adds those numbers. A chip runs billions of operations a second, so a rare case comes up very soon.

At Scale

ap_soc~12 blocks
Phone-class SoChundreds of blocks

This section looks ahead. One adder is small; a real chip has thousands of blocks.

  1. Many teams

    Designers, verification engineers, layout engineers and software teams all work on one chip. Each hand-off is a place where a misunderstanding can hide.

  2. Many layers of checks

    Tests in simulation, rules checked on every clock, measures of what was tested, and mathematical proofs each catch bugs the others miss. This track meets each one in turn.

Where This Goes Next

This lesson named the problem. These lessons teach the tools and the language behind it.

Where each idea is taught in depth
The idea from this pageWhere it is taught
Simulating code and reading what it printsFour-State vs Two-State Types
Writing the self-checking test of this lab yourselfThe Simplest Test That Can Fail
Proving a property for every input instead of trying inputsSimulation Covers Paths, Formal Covers States
How a whole chip is checked before tape-outWhat the Block Bench Already Proved

Try It

Run the lab. Read the three smoke tests, then the last line.

Add the missing term (b[2] & c2) to the carry into bit 3. Predict the last line before you run it.

Put the bug back and change a smoke test to 3 + 5. What does it print now?

RUNIcarus Verilog · in your browser
Edit the code, then run it
Expected: smoke test: 1 + 1 = 2 smoke test: 3 + 4 = 7 smoke test: 5 + 5 = 10 all 256 input pairs: 24 wrong; the first is 1 + 7 = 0

Check Yourself

Predict the outputThe bench now tries 1 + 1 and 3 + 5 by hand, then all 256 pairs, on the same buggy adder. What does the second line print?
// adder4: a 4-bit adder, written one bit at a time (a ripple-carry adder).
module adder4 (input logic [3:0] a, b, output logic [3:0] sum, output logic cout);
  logic c1, c2, c3;
  assign sum[0] = a[0] ^ b[0];
  assign c1     = a[0] & b[0];
  assign sum[1] = a[1] ^ b[1] ^ c1;
  assign c2     = (a[1] & b[1]) | (a[1] & c1) | (b[1] & c1);
  assign sum[2] = a[2] ^ b[2] ^ c2;
  assign c3     = (a[2] & b[2]) | (a[2] & c2);           // one term is missing
  assign sum[3] = a[3] ^ b[3] ^ c3;
  assign cout   = (a[3] & b[3]) | (a[3] & c3) | (b[3] & c3);
endmodule

module tb;
  logic [3:0] a, b, sum;
  logic cout;
  int wrong = 0, fa = -1, fb = -1, fs = 0;
  adder4 dut (.a, .b, .sum, .cout);
  initial begin
    // A few sums by hand: the kind of check that says "it works".
    a = 1; b = 1; #1 $display("smoke test: 1 + 1 = %0d", {cout, sum});
    a = 3; b = 5; #1 $display("smoke test: 3 + 5 = %0d", {cout, sum});
    // Every one of the 256 input pairs, each compared with the right answer.
    for (int i = 0; i < 16; i++)
      for (int j = 0; j < 16; j++) begin
        a = i; b = j; #1;
        if ({cout, sum} !== i + j) begin
          wrong++;
          if (fa < 0) begin fa = i; fb = j; fs = {cout, sum}; end
        end
      end
    $display("all 256 input pairs: %0d wrong; the first is %0d + %0d = %0d", wrong, fa, fb, fs);
  end
endmodule
ConceptWhy is a design bug found after tape-out so much more expensive than one found before?
ConceptThe adder compiled with no warnings and passed 1 + 1, 3 + 4 and 5 + 5. What has been shown?
ConceptIn the lab, why did all three hand-picked sums pass?
ConceptWho should check a design, and why?

Common Mistakes

Wrong Treat a clean compile as evidence the design works.

A compiler checks that the code is legal, not that it does the job.

Fix Check the behaviour against the specification, with a test that can fail.

Wrong Stop after a few correct hand-picked results.

They prove only those inputs; the bug may need a combination nobody picked.

Fix Try many inputs, chosen on purpose, and measure which ones were never tried.

Wrong Leave the checking to whoever wrote the code.

Their tests share their reading of the specification, and its blind spots.

Fix Have a second person read the specification and check the design independently.

Remember

  • A chip cannot be patched: after tape-out every copy carries the same wires.
  • The cost of a bug grows along the road and jumps at tape-out; find bugs while the chip is text.
  • Compiling proves syntax; a few right answers prove only those inputs.
  • Verification checks the design against the specification, independently of the designer.

Practice

Report a problem with this page