Home / Learn Verilog / Structure of a Testbench

Structure of a Testbench

DUT, stimulus, clock, checks.

The short versionDUT, stimulus, clock, checks.

Theory in plain words

Testbench parts1. signals (reg for inputs, wire for outputs)2. DUT instance3. clock and reset generation4. stimulus5. checks and $finish
Testbench parts

Definition

A testbench instantiates the design under test (DUT), generates a clock, applies stimulus and checks results.

Why you need this

Hardware cannot be debugged with a debugger; the testbench is your instrument.

How it works

Declare regs for inputs, wires for outputs, instantiate the DUT, add initial blocks.

Where you'll see this

  • Everyday RTL design
  • FPGA and ASIC projects
  • Testbenches and debugging

Try it

Complete small testbenchVerilog: edit and run

Five parts in one file.

Test what you just read

1. Testbench inputs are declared as...