Module 1: SystemVerilog for UVM | Beginner UVM

Verification Mindset and Testbenches

Learn how verification engineers think, what a testbench does, and why reusable verification environments are needed.

Learning objectives

By the end of this lesson, you should be able to:

  • Explain what hardware verification means.
  • Explain the difference between a DUT and a testbench.
  • Describe the three fundamental jobs of a testbench: stimulate, observe, and check.
  • Explain why verification engineers test normal, boundary, and unexpected scenarios.
  • Understand the difference between directed and randomized testing at a high level.
  • Explain why large verification environments need reusable structure.
  • Understand the problem that UVM will eventually solve.

Step 1: What is verification?

Imagine that a hardware designer has created an adder. The RTL compiles successfully, and the design looks correct.

But there is an important question:

How do we know that the hardware actually works correctly?

This is where verification comes in.

Hardware verification is the process of providing evidence that a design behaves according to its specification.

A verification engineer does not simply test one input and conclude that the design works.

Instead, we ask questions such as:

  • What should happen for a normal input?
  • What should happen for the smallest possible input?
  • What should happen for the largest possible input?
  • What happens when inputs change quickly?
  • What happens at boundary conditions?
  • What happens when an unexpected operation occurs?
  • How can we automatically detect an incorrect result?

This way of thinking is the beginning of the verification mindset.

Step 2: Design versus verification

To understand a testbench, we first need to separate two things:

  • The design — the hardware we want to verify.
  • The testbench — the environment used to verify it.

The hardware being verified is commonly called the Design Under Test, or DUT.

For example, if we are verifying an adder, the adder is the DUT.

        Verification Environment
    -------------------------

         Stimulus
             |
             v
         +-------+
    a -->|       |
    b -->|  DUT  |----> sum
         |       |
         +-------+
             |
             v
          Checker

The basic idea is simple:

The testbench controls what goes into the DUT and determines whether the DUT produced the correct result.

This simple idea will remain important throughout your entire UVM journey.

Step 3: What does a testbench do?

At its most basic level, a verification testbench performs three fundamental jobs:

  1. Stimulate the DUT.
  2. Observe the DUT.
  3. Check the DUT's behavior.

You can remember this as:

Stimulate → Observe → Check

These three ideas appear again and again in UVM. The difference is that UVM provides reusable components to organize them in large environments.

Step 4: Build a tiny testbench

Let's start with something simple.

Suppose our DUT is an 8-bit adder.

module adder (
input  logic [7:0] a,
input  logic [7:0] b,
output logic [8:0] sum


);


assign sum = a + b;


endmodule

The DUT has two inputs and one output.

  • a — first operand
  • b — second operand
  • sum — result

Now let's create a very small testbench.

module tb;

logic [7:0] a;
logic [7:0] b;
logic [8:0] sum;

adder dut (
    .a   (a),
    .b   (b),
    .sum (sum)
);

initial begin

    a = 10;
    b = 20;

    #1;

    if (sum == 30)
        $display("PASS");
    else
        $display(
            "FAIL: expected 30, got %0d",
            sum
        );

    $finish;

end


endmodule

This is a very small testbench, but it already demonstrates the basic verification process.

Step 5: Understand the testbench code

Let's break the example into smaller pieces.

1. Create signals

logic [7:0] a;


logic [7:0] b;
logic [8:0] sum;

These signals are used by the testbench to communicate with the DUT.

2. Instantiate the DUT

adder dut (
.a   (a),
.b   (b),
.sum (sum)


);

The testbench creates an instance of the adder and connects its signals.

The instance is called dut.

3. Apply stimulus

a = 10;


b = 20;

The testbench tells the DUT what inputs to process.

This is called stimulus.

4. Check the result

if (sum == 30)
$display("PASS");


else
$display("FAIL");

The testbench compares the actual DUT result with the expected result.

This is the beginning of a checker.

5. End the simulation

$finish;

Once the test is complete, the simulation can end.

Step 6: The expected result is important

Look carefully at this line:

if (sum == 30)

Where did 30 come from?

We calculated it from the inputs:

10 + 20 = 30

This gives us an important verification concept:

A testbench needs a way to determine what the correct result should be.

In a simple testbench, we might calculate the expected result directly.

In larger verification environments, this responsibility may be handled by more sophisticated checking mechanisms.

You will learn about those mechanisms later in the course.

Step 7: Don't test only the happy path

Our first test used:

a = 10;


b = 20;

The test passes.

But does that prove the adder is correct?

No.

One successful test only proves that the design worked for that particular scenario.

A verification engineer starts thinking about other scenarios.

Normal case

a = 10;


b = 20;

Zero values

a = 0;


b = 20;

Both inputs are zero

a = 0;


b = 0;

Maximum input values

a = 8'hFF;


b = 8'hFF;

These are examples of different verification scenarios.

The goal is not simply to run more tests. The goal is to deliberately explore situations that could expose bugs.

Step 8: Think like a verification engineer

A useful verification mindset is to continuously ask:

"What could go wrong?"

Then ask: "How can I create a test that exposes it?"

For an adder, we might ask:

  • What happens when an input is zero?
  • What happens when both inputs are maximum values?
  • What happens when the result requires an extra bit?
  • What happens when inputs change repeatedly?
  • Can the checker detect an incorrect result?

For a FIFO, the questions become different:

  • What happens when the FIFO is empty?
  • What happens when it becomes full?
  • What happens when we read from an empty FIFO?
  • What happens when we write to a full FIFO?
  • Does data come out in the correct order?

The DUT changes, but the verification mindset remains:

Understand the specification → identify interesting scenarios → generate stimulus → observe behavior → check the result.

Step 9: Directed testing

One way to create tests is to explicitly choose the values we want to test.

This is called directed testing.

initial begin

// Test 1
a = 10;
b = 20;

#1;

if (sum == 30)
    $display("PASS");
else
    $display("FAIL");

// Test 2
a = 0;
b = 25;

#1;

if (sum == 25)
    $display("PASS");
else
    $display("FAIL");


end

Directed tests are useful because the engineer knows exactly which scenario is being tested.

They are especially useful for important corner cases and specific requirements.

Step 10: Randomized testing

Now imagine that we want to test thousands of different combinations of inputs.

Writing every combination manually would be inefficient.

SystemVerilog provides randomization features that can help generate different values automatically.

You will learn the details of randomization in Lesson 5, followed by constraints and distributions in Lesson 6.

For now, remember only this:

Directed testing chooses specific scenarios. Randomized testing explores many possible scenarios automatically.

In real verification environments, both approaches are useful.

Step 11: Why simple testbenches become difficult

Our adder testbench is easy to understand because it is tiny.

Real designs are much more complicated.

Imagine verifying a system with:

  • Multiple interfaces.
  • Many different transaction types.
  • Hundreds of test scenarios.
  • Randomized stimulus.
  • Multiple checkers.
  • Functional coverage.
  • Assertions.
  • Different configurations.
  • Multiple engineers working on the same environment.

If everything is placed inside one giant testbench module, the environment becomes difficult to maintain.

For example:

module huge_testbench;

// stimulus

// DUT connections

// protocol handling

// checking

// coverage

// configuration

// logging

// randomization

// many more things...


endmodule

This approach might work for a very small experiment, but it does not scale well.

Step 12: Reuse becomes important

Imagine that you have built a testbench for an interface.

Now your project requires ten different tests to use the same interface.

You don't want to rewrite the interface verification code ten times.

Instead, you want to build reusable pieces.

Build once. Reuse many times.

This idea of reuse is one of the major reasons verification environments are built using structured architectures.

UVM is one such architecture.

But don't learn UVM yet.

First, build the SystemVerilog knowledge needed to understand the architecture.

Step 13: Where UVM fits

At this point, you already understand the fundamental verification flow:

        Stimulus
        |
        v
       DUT
        |
        v
     Observe
        |
        v
      Check

UVM does not change this fundamental idea.

Instead, UVM provides a standard way to organize a larger verification environment into reusable components.

Later in this course, you will learn concepts such as:

  • Transactions
  • Sequences
  • Drivers
  • Monitors
  • Scoreboards
  • Agents
  • Environments
  • Tests

For now, don't memorize those names.

The important thing is to understand the problem:

As verification environments become larger, we need a way to organize, reuse, and connect verification functionality.

That is the problem UVM helps solve.

The verification loop

You will see this pattern throughout UVM Arena.

        +-------------------+
    |  Verification     |
    |  Scenario         |
    +---------+---------+
              |
              v
    +-------------------+
    |     Stimulus      |
    +---------+---------+
              |
              v
    +-------------------+
    |       DUT         |
    +---------+---------+
              |
              v
    +-------------------+
    |     Observation   |
    +---------+---------+
              |
              v
    +-------------------+
    |      Check        |
    +---------+---------+
              |
              v
         PASS / FAIL

A strong verification environment repeatedly executes this loop across many scenarios.

Try it yourself

Create a small SystemVerilog testbench for an adder.

Your testbench should:

  1. Instantiate an adder DUT.
  2. Apply at least five different input combinations.
  3. Calculate the expected result for each test.
  4. Compare the expected result with the DUT output.
  5. Print a clear PASS or FAIL message.

Include at least one boundary test.

Challenge:

Try to test the largest values that can be represented by the 8-bit inputs.

Common beginner mistakes

Mistake 1: Testing only one input

One passing test does not prove that the design is correct. Verification requires multiple meaningful scenarios.

Mistake 2: Generating stimulus without checking it

A test that generates many inputs but never determines whether the outputs are correct provides very little verification evidence.

Mistake 3: Testing only normal behavior

Bugs frequently appear at boundaries, unusual combinations, and unexpected conditions.

Mistake 4: Learning UVM classes before understanding verification

Don't start by memorizing UVM class names. First understand what a verification environment needs to do. The UVM architecture will make much more sense afterward.

Quick knowledge check

Question 1

What is the DUT?

  1. The simulator
  2. The design being verified
  3. The test result
  4. The verification engineer
Show answer

Answer: B. DUT means Design Under Test. It is the hardware design being verified.

Question 2

What are the three basic jobs of a testbench?

  1. Compile, synthesize, and place
  2. Stimulate, observe, and check
  3. Design, code, and synthesize
  4. Reset, compile, and finish
Show answer

Answer: B. A basic testbench stimulates the DUT, observes its behavior, and checks the result.

Question 3

Why isn't one passing test enough to prove that a design is correct?

Show answer

Because the test only demonstrates that the design behaved correctly for that particular scenario. Other scenarios may still contain bugs.

Question 4

What is one major reason we need reusable verification components?

Show answer

Reuse allows verification functionality to be developed once and used across multiple tests and environments, making large projects easier to maintain.

Key takeaways

  • Verification provides evidence that a design behaves according to its specification.
  • The DUT is the hardware design being verified.
  • A testbench stimulates the DUT, observes its behavior, and checks the result.
  • One passing test does not prove that a design is correct.
  • Verification engineers deliberately explore normal, boundary, and unexpected scenarios.
  • Directed testing targets specific scenarios, while randomized testing can explore many possible scenarios.
  • Large verification environments need structure and reuse.
  • UVM provides a standardized architecture for building reusable verification environments.

What's next?

You now understand the basic verification problem: generate stimulus, observe the DUT, and determine whether the result is correct.

The next question is:

What SystemVerilog features do we need to build better verification environments?

In Lesson 2: SystemVerilog Data Types, we begin building that foundation.

You will learn the SystemVerilog data types that are commonly used when creating verification code and UVM transactions.