This problem set closes the Simulation Timing & Testbenches chapter. Each article's practice exercise and drills cover one technique; in these 6 problems you write the parts of a testbench and put them together.

This time your code is the test. The grader connects it to a design that is right and to designs that are not, and tells you which faults it missed and what would have found them.

6 problems | Intermediate Level

What You'll Learn

  • Compare outputs so that unknown values count as mismatches
  • Drive a design without racing it
  • Make random stimulus with a range and a seed
  • Read a value when it is there
  • End every test, whatever the design does

What You'll Build

Across the set you build the testbench of a small FIFO as a set of modules: a checker, a driver, a generator of random gaps, a monitor and a watchdog.

The last problem puts them together into one test. It has to pass a correct FIFO and find 15 faulty ones, some of which show only with the right traffic.

OutputMeaningBuilt in
errorsMismatches found by the testProblems 1 and 6
wr, rd, dinThe inputs of the FIFOProblems 2 and 6
passed, timed_outThe verdict of a testProblem 5

The Problems

Work through the problems in order: later problems reuse what you built in earlier ones. Each starts with a short spec and a testbench you can run before you submit.

1

The checkerFix

A checker finds every fault in its bench test. Make it find any fault that shows on the ports.

Practise: Comparing outputs in a testbench
Builds on: Verilog Testbench

Open in ChipVerify Lab →
2

The driverFix

A driver sends four bytes, and other bytes come out of a FIFO that is right. Make the driver safe for any design and any simulator.

Practise: When a testbench changes its inputs
Builds on: Verilog Testbench Simulation, Verilog Testbench

Open in ChipVerify Lab →
3

Random gapsExtend

A generator makes random gaps between pulses, but not the right ones. Extend it to a range and a seed.

Practise: Random values in a range, repeatable
Builds on: Verilog $random

Open in ChipVerify Lab →
4

The monitorFix

A monitor reports the bytes that leave a FIFO and passes its bench test. Make it right for any bytes.

Practise: When a value can be read
Builds on: Verilog Testbench Simulation, Verilog Display Tasks

Open in ChipVerify Lab →
5

The watchdogFix

A watchdog gives its first test the right verdict and gets confused after that. Make it time every test.

Practise: Waiting for a level, and stopping a timer
Builds on: Verilog $stop $finish, Verilog Delay Control

Open in ChipVerify Lab →
6

The FIFO testWrite, final problem

Write a test that passes a correct FIFO and finds 15 faulty ones, some of which hide well.

Practise: A complete self-checking test
Builds on: Verilog Testbench, Verilog Testbench Simulation, Verilog $random, Verilog $stop $finish

Open in ChipVerify Lab →

How Your Solution Is Graded

Every problem has a visible testbench that you can run and edit. When you submit, a hidden grading testbench runs your module with a correct design and with faulty ones that the visible testbench does not contain, and watches when your module changes its outputs.

When a check fails, the console ends with a short list of what to look into. Each item explains the mistake, or the fault that was missed, and names the article section that covers it.

Before You Start

The problems use the ideas from the articles in this chapter, especially self-checking testbenches, the order of events in a time step, and $random. If a problem stops you, the article it builds on is the place to look.

After This Chapter

The FIFO here is the one from the Memory Elements Problem Set, where you build it. Run the test you wrote against your own FIFO from there.

Did you find what you were looking for?

Quiz

No quiz questions available for this article.