Module 1: SystemVerilog for UVM | Beginner UVM

Assertions for Beginners

Learn how SystemVerilog assertions automatically detect incorrect behavior and turn protocol requirements into executable checks.

Learning objectives

  • Explain what an assertion is and why verification environments use them.
  • Write simple immediate assertions using assert.
  • Understand the difference between immediate and concurrent assertions.
  • Write basic temporal properties using SystemVerilog Assertions (SVA).
  • Use implication operators to describe protocol relationships.
  • Use $past to check behavior across clock cycles.
  • Disable assertions during reset using disable iff.
  • Recognize how assertions complement UVM monitors, scoreboards, and reports.

Step 1: Why verification needs assertions

A testbench does not only generate stimulus. It must also determine whether the DUT behaved correctly.

One simple way to check behavior is with procedural code:

if (data !== expected_data) begin
  $error("Data mismatch");
end

This works, but many hardware requirements are naturally expressed as rules about values and time:

  • A request must eventually receive a response.
  • A signal must remain stable while valid is asserted.
  • A FIFO must never report empty and full at the same time.
  • A request must not occur while reset is active.
  • When valid && ready is true, a transfer occurs.

Assertions allow these requirements to become executable checks.

Big idea: An assertion describes something that should always be true. Simulation then tells you when that expectation is violated.

Step 2: Your first assertion

The simplest SystemVerilog assertion checks a Boolean expression.

assert (data == expected_data);

If the expression is true, the assertion passes. If it is false, the assertion fails.

You can provide an explicit failure message:

assert (data == expected_data)
else
  $error("Data mismatch: expected=%0h actual=%0h",
         expected_data,
         data);

This is called an immediate assertion because it evaluates the expression when the statement executes.

Step 3: Immediate assertions

Immediate assertions are procedural statements. They are useful when the testbench already has a specific point in time at which it wants to check a condition.

task check_result(
  bit [31:0] actual,
  bit [31:0] expected
);

  assert (actual == expected)
  else
    $error(
      "Mismatch: actual=%0h expected=%0h",
      actual,
      expected
    );

endtask

You can use immediate assertions inside procedures, classes, functions where appropriate, and other procedural code.

Use an immediate assertion when: you want to check a condition right now, at the point where the procedural code executes.

Step 4: Assertions for simple protocol rules

Suppose a protocol says that valid and ready must not both be unknown.

assert (!$isunknown({valid, ready}))
else
  $error("Protocol signals contain X or Z");

Another example is checking that a counter does not exceed its maximum value:

assert (count <= MAX_COUNT)
else
  $error("Counter exceeded maximum value");

These checks are useful because they automatically detect failures during simulation rather than relying on a human to inspect every waveform.

Step 5: The limitation of immediate assertions

Immediate assertions are excellent for checking a condition at one point in time, but hardware protocols often describe relationships between multiple clock cycles.

Consider this requirement:

Requirement: Whenever req is asserted, ack must be asserted on the next clock cycle.

This is a temporal requirement. It describes what should happen now and what should happen later.

This is where concurrent assertions become useful.

Step 6: Concurrent assertions

A concurrent assertion evaluates behavior in relation to a clock.

property req_ack;
  @(posedge clk)
    req |-> ##1 ack;
endproperty

assert property (req_ack);

Read this as:

On every rising edge of clk, if req is true, then ack must be true one clock cycle later.

This is much closer to the way hardware engineers naturally describe synchronous protocol requirements.

Step 7: Understanding the property

Break the assertion into pieces:

property req_ack;
  @(posedge clk)
    req |-> ##1 ack;
endproperty
  • property req_ack gives the property a name.
  • @(posedge clk) defines the clock used to evaluate it.
  • req is the condition that starts the check.
  • |-> is an implication operator.
  • ##1 means one clock tick later.
  • ack is the expected result.

Step 8: Implication

Implication is one of the most useful ideas in assertions.

It lets you express:

IF this happens
THEN this must happen

For example:

req |-> ack

This means that when the antecedent req is true, the consequent ack must satisfy the property.

You will commonly see two implication operators:

Operator Meaning
|-> Overlapped implication; the consequent can begin in the same clock cycle.
|=> Non-overlapped implication; the consequent begins on the following clock cycle.

For example:

req |=> ack

means that if req is true on one clock edge, ack must be true on the next clock edge.

Beginner tip: Do not memorize implication syntax without drawing the timing. Write the clock cycles on paper and identify exactly when the antecedent and consequent are evaluated.

Step 9: Checking behavior one cycle later

The $past() system function lets an assertion refer to a value from a previous clock cycle.

assert property (
  @(posedge clk)
  valid |-> $past(request)
);

A more intuitive example is a register update:

assert property (
  @(posedge clk)
  enable |-> data == $past(data) + 1
);

The exact property you write depends on the DUT specification, but the key idea is that $past() lets an assertion reason about previous sampled values.

Step 10: Checking signal stability

Many protocols require a signal to remain stable while another condition is active.

For example:

Requirement: While valid is asserted and ready is low, the transaction data must remain unchanged.

One way to express this is:

property data_stable;
  @(posedge clk)
    valid && !ready |=> $stable(data);
endproperty

assert property (data_stable);

The $stable() system function checks whether the sampled value has remained unchanged.

This kind of property is extremely useful for handshake protocols.

Step 11: Assertions and reset

Assertions often should not check normal protocol behavior while the DUT is being reset.

SystemVerilog provides disable iff for this purpose.

assert property (
  @(posedge clk)
  disable iff (!reset_n)
  valid |-> ready
);

Here, the property is disabled whenever reset_n is low.

Why this matters: During reset, many DUT signals may intentionally be changing or invalid. Assertions should normally focus on the behavior that matters outside the reset interval.

Step 12: Assertion pass and failure messages

An assertion is most useful when a failure tells you what went wrong.

assert property (
  @(posedge clk)
  disable iff (!reset_n)
  req |=> ack
)
else
  $error("REQ was asserted without ACK on the next cycle");

The failure message should describe the violated requirement rather than simply saying "assertion failed."

Good verification message: Tell the engineer what requirement failed, and include useful context such as addresses, transaction IDs, or signal values when appropriate.

Step 13: A small FIFO example

Assertions become especially useful when checking simple hardware invariants.

Suppose a FIFO has full and empty status signals. They should never both be asserted at the same time.

assert property (
  @(posedge clk)
  !(full && empty)
)
else
  $error("FIFO cannot be full and empty simultaneously");

Another requirement might be that a read should not occur while the FIFO is empty:

assert property (
  @(posedge clk)
  read |-> !empty
)
else
  $error("FIFO read attempted while empty");

These checks run automatically throughout the simulation.

Step 14: Assertions vs. procedural checks

Assertions do not replace every other verification technique. Different checks are useful for different problems.

Technique Good for
Immediate assertion Checking a condition at a specific procedural point.
Concurrent assertion Checking temporal and clock-based behavior.
Scoreboard Comparing actual transactions against expected transactions.
Coverage Measuring whether important scenarios were exercised.
Waveform Debugging what happened during simulation.
Verification mindset: Good verification uses multiple forms of evidence. An assertion checks a rule; a scoreboard checks functional results; coverage tells you what you exercised.

Step 15: Assertions and UVM

Assertions are part of SystemVerilog, not UVM itself. UVM provides the framework for organizing the verification environment, while SystemVerilog assertions provide powerful behavioral checks.

Later in the course, you will see assertions used alongside:

  • UVM monitors.
  • UVM drivers.
  • Scoreboards.
  • Reference models.
  • Coverage collectors.
  • UVM reporting.

A useful mental model is:

              Verification Environment
                         |
          +--------------+--------------+
          |              |              |
       Stimulus       Observation     Checking
          |              |              |
       Driver         Monitor       Assertions
          |              |          Scoreboard
          v              v              |
                         DUT            |
                          |             |
                          +-------------+

Assertions are especially good at detecting local protocol and temporal violations close to the signals being checked.

Key idea: UVM organizes the verification environment. Assertions provide executable specifications for many rules inside that environment.

Step 16: A practical protocol example

Consider a simple valid/ready interface:

interface stream_if(input logic clk);

  logic        reset_n;
  logic        valid;
  logic        ready;
  logic [31:0] data;

endinterface

Suppose the protocol has these requirements:

  1. A transfer occurs when valid && ready is true.
  2. If valid is high and ready is low, data must remain stable.
  3. Neither valid nor ready should contain unknown values during normal operation.

These requirements can become assertions:

assert property (
  @(posedge clk)
  disable iff (!reset_n)
  valid && !ready |=> $stable(data)
);

assert property (
  @(posedge clk)
  disable iff (!reset_n)
  !$isunknown({valid, ready})
);

Now the protocol specification is executable. If the DUT violates one of these rules during simulation, the simulator can report it immediately.

Step 17: Common mistakes

Mistake 1: Checking the wrong clock

A concurrent assertion must use a clock that represents the timing of the behavior being checked.

Mistake 2: Misreading implication timing

|-> and |=> have different timing semantics. Draw the clock cycles when you are learning them.

Mistake 3: Forgetting reset

A property that is valid during normal operation may produce meaningless failures during reset. Consider whether disable iff is appropriate.

Mistake 4: Writing assertions without a specification

An assertion should represent a real design requirement. Do not write checks simply because the syntax looks interesting.

Mistake 5: Using assertions for everything

A temporal assertion is not always the right tool for transaction comparison. A scoreboard may be much better for comparing complex expected and actual transactions.

Mistake 6: Ignoring the failure message

A useful assertion should help the verification engineer understand the failure quickly.

Step 18: Your assertion-writing workflow

When writing a new assertion, use this process:

  1. Write the requirement in plain English.
  2. Identify the clock.
  3. Identify the triggering condition.
  4. Identify what must happen afterward.
  5. Determine whether reset should disable the check.
  6. Write the property.
  7. Add a useful failure message.
  8. Create a test that intentionally violates the rule.
Best practice: Always try to make an assertion fail intentionally at least once. A check that has never been observed failing has not been thoroughly validated.

Try it yourself

Create assertions for a simple valid/ready protocol.

  1. Assert that valid and ready never contain unknown values during normal operation.
  2. Assert that when valid is high and ready is low, data remains stable on the next clock.
  3. Add disable iff (!reset_n) to both properties.
  4. Add an else $error(...) message to each assertion.
  5. Create a testbench scenario that intentionally violates one of the properties.
  6. Observe the assertion failure in the simulator output and waveform.

Bonus: Write an assertion for a request/acknowledge protocol where req must be followed by ack on the next clock cycle.

Quick check

  1. What is an assertion?
  2. What is the difference between an immediate and concurrent assertion?
  3. Why do concurrent assertions normally use a clock?
  4. What does |-> mean?
  5. What does |=> mean?
  6. What does $past() allow an assertion to do?
  7. What does $stable() check?
  8. Why is disable iff commonly used with reset?
  9. Why might a scoreboard be more appropriate than an assertion for comparing complex transactions?
  10. Why should you intentionally make an assertion fail during verification?
Show answers
  1. An executable check that verifies a condition or behavioral requirement.
  2. An immediate assertion checks a condition when procedural code executes it; a concurrent assertion checks behavior over clocked simulation time.
  3. Because many hardware requirements describe relationships between clock cycles.
  4. Overlapped implication; the consequent can begin in the same clock cycle as the antecedent.
  5. Non-overlapped implication; the consequent begins on the following clock cycle.
  6. It allows an assertion to reference a previously sampled value.
  7. It checks whether a value has remained unchanged.
  8. To prevent normal reset activity from producing irrelevant assertion failures.
  9. Scoreboards are generally better suited to comparing complete or complex transaction objects.
  10. To verify that the assertion actually detects the failure it was designed to catch.

Module 1 checkpoint

You have now completed the SystemVerilog foundation needed to begin learning UVM.

Before moving on, make sure you can explain this chain:

Verification problem
       |
       v
SystemVerilog data types
       |
       v
Classes and objects
       |
       v
Randomization and constraints
       |
       v
Queues and collections
       |
       v
Tasks and concurrency
       |
       v
Interfaces and timing
       |
       v
Assertions
       |
       v
UVM

UVM will build on these concepts rather than replace them.

Ready for UVM? If you understand transactions, objects, randomization, collections, concurrency, interfaces, timing, and assertions, you have the SystemVerilog foundation needed to understand why UVM exists and what problems it solves.

Key takeaways

  • An assertion turns a verification requirement into an executable check.
  • Immediate assertions check conditions at a specific procedural point.
  • Concurrent assertions are designed to check temporal behavior relative to a clock.
  • Implication expresses "if this happens, then that must happen."
  • $past() allows properties to reason about previous clock cycles.
  • $stable() is useful for checking that signals remain unchanged.
  • disable iff is commonly used to disable properties during reset.
  • Assertions complement, rather than replace, scoreboards, monitors, coverage, and other verification techniques.
  • Assertions are part of SystemVerilog; UVM provides the framework for organizing the broader verification environment.
  • You should validate an assertion by intentionally creating the failure it is supposed to detect.