The Specification and the Design Under Test
Every check needs a reference, and the first reference is the specification. Learn what a specification promises and what it leaves out. Draw the edge of the design under test, and treat an ambiguous sentence as the first bug.
You Will Be Able To
- Say what a specification is and what it is not.
- List the features, interfaces and corner cases a specification implies.
- Mark the edge of a design under test: what a bench may drive and see.
- Raise an ambiguity as a question before writing any test.
- Lesson
- B1.3
- Time
- 20 min
- Runs on
- Your browser
- Check
- 5 questions
Three engineers get the same two-line specification for a counter. Each builds it, each tests it, and each design passes its own tests. Put the three side by side and they disagree within ten clocks. Nobody wrote a bug, and yet two of them are wrong.
- File
- Neutral
- Clock / reset
- I/O
- DUT
- Analysis
- Data
- Clock
- The words
A specification says what the design must do, in human language.
- The reading
Someone turns the words into behaviour. Two people can read the same sentence two ways.
- The box
The design under test is what was built. A bench may drive its input pins and watch its output pins.
Read the diagram as text
- Specification: "counts up when enable is high; after 9 back to 0"
- A reading: every clock? every press? after 9 what?
- clk, rst: input pins
- en: input pin
- Design under test: counter
- count[3:0]: output pins
- Specification → A reading: read
- A reading → Design under test: build
- clk, rst → Design under test: drive
- en → Design under test: drive
- Design under test → count[3:0]: observe
The specification of this lesson's counter, the box that was built from it, and the reading in between.
Before You Start
Read Verification, Validation and Test first: verification compares a design with its specification. You should know what a counter is; Modulo-N, Up/Down and Loadable Counters is a refresher.
| Question | |
|---|---|
| 1 | What does a specification promise, and what does it not say? |
| 2 | What three kinds of statement should you pull out of a specification? |
| 3 | What is the design under test, and where does it end? |
| 4 | Why is an ambiguous sentence a bug? |
| 5 | How can one sentence give three correct-looking designs? |
The Idea: The Reference Has to Be Read
Verification compares a design with its specification. But a specification is written in human language, and human language is loose. Before anyone can check a design, someone has to read the words and decide what behaviour they mean.
The designer reads the specification and builds. The verification engineer reads the same words separately and checks. That second reading is the whole point: two people catch misreadings that one would keep. When the two readings disagree, the specification itself is often the cause.
So the first job of verification starts before any code. Pull out what the document promises, mark what it leaves open, and ask about every gap.
New Words
| Word | Meaning |
|---|---|
| Design under test (DUT) | The design being checked. The bench drives its inputs and watches its outputs. |
| Feature | One thing the design must do, such as "counts up" or "wraps after 9". |
| Interface | The pins of the DUT and the rules for using them: names, widths, timing. |
| Corner case | An unusual input or moment where behaviour is easy to get wrong: a limit, a collision, a reset in the middle. |
| Ambiguity | A sentence that can honestly be read in more than one way. |
| Boundary | The edge of the DUT: what lies inside it, and what the bench supplies from outside. |
What a Specification Promises
A specification says what the design must do, seen from its pins. It names the interfaces and the behaviour at them. A good one also says what must never happen. It is not the RTL, and it should not say how to build the logic.
| Kind | What the two lines give | What they leave open |
|---|---|---|
| Feature | counts up; goes back to 0 "after 9" | after the value 9, or after nine counts? |
| Interface | an enable input and a count output | width of count; is there a reset, and is it synchronous? |
| Timing | "when enable is high" | once per clock while high, or once per press? |
| Corner case | none stated | enable low: hold? reset while counting? enable high for a long time? |
Two short lines leave six questions. That is normal. A verification engineer writes each question down and gets an answer from the person who owns the specification. The answer goes into the document, so the next reader does not need to ask.
The Boundary of the DUT
The design under test is a box. Its pins are the only things a bench can touch: it drives the inputs and watches the outputs. Everything the DUT needs from outside is the bench's job. That includes clock, reset and stimulus (the input values it applies), plus models of any neighbours.
Drawing that edge is a decision. Test the counter alone, and the bench drives en directly. Test it inside a bigger block, and en comes from other logic you do not control. Same counter, different edge, different checks. Later lessons look inside the box. For now, the box is closed and only its pins count.
The Rules
Rule 1: A specification says what, at the pins.
It is the reference for verification, so its gaps become gaps in every check.
Rule 2: Pull out features, interfaces and corner cases.
Each becomes a question, then a check.
Rule 3: An ambiguity is the first bug.
Raise it with whoever owns the specification and get the answer written into the document.
Rule 4: Never resolve a question by reading the RTL.
That copies the designer's reading into the check, and the check can no longer disagree.
Rule 5: Draw the DUT boundary first.
Decide what the bench drives, what it watches, and what lies outside.
Sources for These Rules
Spear and Tumbush (2012), section 1.1: a specification can be ambiguous, incomplete or conflicting. The designer interprets it, and the verifier reads it separately. Section 1.1.1: two designers reading one description differently at a block boundary.
Spear and Tumbush (2012), section 1.9: the testbench wraps around the DUT and supplies its stimulus.
Mehta (2018), section 15.2.1: the design specification follows the product requirements. Section 15.5.1: the test plan is formed from it.
The Lab: One Sentence, Three Counters
The lab builds the counter three times. Each module matches the two lines as one engineer read them. Reading 1 counts on every clock while enable is high and wraps after the value 9. Reading 2 takes "after 9" to mean "after nine counts", so it wraps after 8. Reading 3 counts once each time enable goes high, like a button counter.
en_was <= en;
if (en && !en_was) count <= (count == 9) ? 0 : count + 1;The <= arrow updates a flip-flop at the clock edge. The ? : picks between two values: 0 if count is 9, otherwise count + 1. All three designs get the same enable pattern: high for 13 clocks, low for 2, then high again.
enable : 1 1 1 1 1 1 1 1 1 1 1 1 1 0 0 1
reading 1 : 1 2 3 4 5 6 7 8 9 0 1 2 3 3 3 4
reading 2 : 1 2 3 4 5 6 7 8 0 1 2 3 4 4 4 5
reading 3 : 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 2
final : reading 1 = 4, reading 2 = 5, reading 3 = 2One column per clock, recorded from the lab on Icarus. Each count is the value after that clock.
Read the rows side by side. Reading 1 goes 8, 9, 0. Reading 2 goes 7, 8, 0, a clock earlier. Reading 3 counts once and then waits, because enable stayed high. It counts again only when enable rises at the end. The last row shows three different answers: 4, 5 and 2.
Each design is a faithful reading of the same two lines. A test written by its own author passes. Only a check against an agreed reading can tell which one the product needs, so rule 3 comes first.
Traps
The first trap is the obvious reading. Each engineer was sure the sentence meant one thing. Ambiguity is invisible to the person who reads it one way. That is why the question list is written down and sent, not kept in your head.
The second trap is asking the designer and taking their answer as the specification. The designer has already built one reading. Ask whoever owns the specification, and have the answer added to it.
The third trap is the missing sentence. Nothing in the two lines says what happens at reset, or with enable low. Silence is also ambiguity. The corner-case row of the table is where most real bugs live.
At Scale
This section looks ahead. A real specification runs to hundreds of pages.
Review meetings
Designers, verification engineers and architects read the specification together and log every question.
From questions to a plan
Each answered feature becomes rows of a verification plan: what to drive, what to check, how to know it was covered.
Where This Goes Next
This lesson read the reference. These lessons turn it into checks.
| The idea from this page | Where it is taught |
|---|---|
| Writing a self-checking test against the agreed reading | The Simplest Test That Can Fail |
| Finding corner cases on purpose | Corner Cases and How to Think of Them |
| A specification turned into rules and a test plan, for a FIFO | Start From the FIFO Rules |
| Writing a specification's rules as checks that run on every clock | An Assertion Plan |
| A chip specification that is data, not prose | The Specification Is Data |
Try It
Run the lab and compare the three rows clock by clock.
Hold enable high for 10 clocks (change the pattern to ten 1s). Predict the last line.
Make enable alternate 1, 0, 1, 0. Which readings agree now, and why?
enable : 1 1 1 1 1 1 1 1 1 1 1 1 1 0 0 1 reading 1 : 1 2 3 4 5 6 7 8 9 0 1 2 3 3 3 4 reading 2 : 1 2 3 4 5 6 7 8 0 1 2 3 4 4 4 5 reading 3 : 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 2 final : reading 1 = 4, reading 2 = 5, reading 3 = 2Check Yourself
Common Mistakes
Wrong Pick the reading that seems obvious and start testing.
An ambiguity is invisible to whoever reads it one way, so the test may check the wrong behaviour.
Fix Write down every open question and get answers from the owner of the specification.
Wrong Read the RTL to find out what the specification meant.
The check then copies the designer's reading and cannot disagree with it.
Fix Resolve the meaning from the specification and its owner, independently of the code.
Wrong Ignore what the specification does not mention.
Reset, limits and collisions are where bugs hide, and silence is ambiguity too.
Fix List the corner cases the specification implies and ask about each one.
Remember
- A specification says what the design must do at its pins; it is the reference for verification.
- Pull out features, interfaces and corner cases, and turn each gap into a written question.
- An ambiguity is the first bug: one sentence can give several correct-looking designs.
- The DUT is a box; the bench drives its inputs, watches its outputs and supplies everything outside.