Module 3: Checking Architecture | Intermediate UVM

Error Handling Strategies

Design UVM error handling so failures are classified correctly, diagnostics remain useful, and the test can continue far enough to expose related problems.

Learning objectives

  • Distinguish between verification failures, warnings, expected errors, and unrecoverable conditions.
  • Choose appropriate UVM report severities for different failure conditions.
  • Design checkers that report useful context without hiding the original failure.
  • Handle multiple failures without turning a single defect into a confusing cascade of messages.
  • Recognize when a checker should continue, stop checking one transaction, reset its state, or terminate the test.
  • Understand how error handling interacts with scoreboards, resets, timeouts, and end-of-test behavior.

Why error handling is part of checker architecture

By this point, the environment can compare transactions, correlate responses, and coordinate multiple streams. A checker can therefore detect many different kinds of problems:

  • an actual response does not match the prediction,
  • a response arrives with an unknown ID,
  • the same response appears twice,
  • a protocol rule is violated,
  • an expected response never arrives, or
  • the verification environment itself has become inconsistent.

These conditions should not all be handled identically.

For example, a data mismatch normally means the test should record a verification failure and continue. An invalid configuration that makes the environment unusable may justify immediate termination. A known negative test may deliberately generate a protocol error and should not automatically be treated as an unexpected failure.

Core idea: Error handling is not just choosing between `uvm_error and `uvm_fatal. It is deciding what the detected condition means, what evidence should be recorded, and whether verification should continue.

Step 1: Classify the condition before choosing a response

A useful first question is:

“What does this condition tell me about the correctness or validity of the test?”

Unexpected verification failure

Use an error when the DUT violates behavior that the testbench expected.

if (!actual.compare(expected)) begin


`uvm_error("SB_MISMATCH",
$sformatf("ID=%0d: actual does not match expected",
actual.id))
end

The checker records the failure, but other transactions can continue to expose additional problems.

Warning

A warning indicates something noteworthy that is not necessarily a verification failure.

if (outstanding_count > HIGH_WATERMARK) begin


`uvm_warning("SB_DEPTH",
$sformatf("Outstanding transactions=%0d",
outstanding_count))
end

A warning should not become a substitute for an actual correctness check. If the condition violates a required specification rule, use an appropriate error instead.

Fatal environment failure

A fatal report is appropriate when continuing would make the remaining simulation meaningless or unsafe.

if (cfg == null) begin


`uvm_fatal("CFG",
"Required scoreboard configuration was not provided")
end

For example, a checker that cannot initialize because a required configuration object is missing may have no meaningful way to verify subsequent traffic.

Informational diagnostics

Useful diagnostic information does not necessarily indicate a failure.

`uvm_info("SB",
      $sformatf("Matched response ID=%0d", actual.id),
      UVM_HIGH)

Keep routine information at an appropriate verbosity so that failures remain visible in normal regressions.

Step 2: Do not confuse an error with a reason to stop

A common beginner assumption is:

failure detected -> stop immediately

Reusable verification environments usually benefit from a different approach:

failure detected
  |
  +-- record useful evidence
  |
  +-- update checker state if necessary
  |
  +-- continue when the environment remains valid
  |
  +-- terminate only when continuing is no longer meaningful

Suppose an out-of-order scoreboard detects a mismatched response:

if (!actual.compare(expected)) begin


`uvm_error("SB_MISMATCH",
$sformatf(
"ID=%0d mismatch: expected=%s actual=%s",
actual.id,
expected.sprint(),
actual.sprint()))
end

expected_by_id.delete(actual.id);

Deleting the matched ID is important. Otherwise the same outstanding expectation could remain in the scoreboard and create misleading secondary failures later.

The correct state update depends on the checker architecture. The important point is that reporting the error and maintaining checker state are separate responsibilities.

Step 3: Distinguish primary failures from cascading failures

One DUT defect can generate many observations.

Imagine that a DUT produces an incorrect response for ID 17. A poor checker might subsequently report:

  • response mismatch for ID 17,
  • unexpected response for ID 17,
  • missing response for ID 17,
  • three ordering failures, and
  • end-of-test outstanding transaction errors.

Some of those may be real consequences of the first failure rather than independent defects.

Good error handling therefore includes deliberate state transitions.

actual response
  |
  v


Does the correlation key exist?
|
+--+--+
|     |
no    yes
|     |
unexpected  compare
response      |
+--+--+
|     |
match mismatch
|     |
delete  report
entry   failure
|
delete/
quarantine
according to
checker policy

The checker should leave itself in a well-defined state after each event, including failure events.

Step 4: Handle different scoreboard failure modes

Consider an out-of-order scoreboard from Lesson 25.

typedef int unsigned id_t;


packet expected_by_id[id_t];

Case A: Unexpected response

if (!expected_by_id.exists(actual.id)) begin


`uvm_error("SB_UNEXPECTED",
$sformatf(
"No expected transaction for response ID=%0d",
actual.id))
end

This can indicate an unexpected DUT response, a duplicate response, an ID reuse problem, or a testbench correlation bug. The message should therefore provide enough context to investigate which explanation is correct.

Case B: Mismatched response

else begin


expected = expected_by_id[actual.id];

if (!actual.compare(expected)) begin
`uvm_error("SB_MISMATCH",
$sformatf(
"ID=%0d mismatch\nEXPECTED:\n%s\nACTUAL:\n%s",
actual.id,
expected.sprint(),
actual.sprint()))
end

expected_by_id.delete(actual.id);
end

The transaction was correlated successfully, so this is a data/behavior mismatch, not a correlation failure.

Case C: Duplicate response

If the first response consumed the expected entry, a second response with the same ID will no longer find an expectation:

if (!expected_by_id.exists(actual.id))


`uvm_error("SB_UNEXPECTED",
$sformatf(
"Response ID=%0d has no outstanding expectation",
actual.id))

Whether this is specifically classified as a duplicate requires additional context, such as remembering recently completed IDs or relying on protocol rules. Do not automatically label every unknown ID as a duplicate.

Case D: Outstanding transactions at shutdown

if (expected_by_id.size() != 0) begin


`uvm_error("SB_DRAIN",
$sformatf(
"%0d expected responses remain at end of test",
expected_by_id.size()))
end

This is evidence that something remains unresolved, but it is not necessarily a timeout. Lesson 28 will address how to detect a missing response within a defined time or cycle limit.

Step 5: Expected errors need an explicit policy

Verification environments often test error behavior deliberately. Examples include:

  • illegal protocol accesses,
  • unsupported commands,
  • parity or CRC errors,
  • malformed packets,
  • overflow conditions, and
  • explicit fault injection.

If the DUT is supposed to reject an injected error, the resulting DUT error is not necessarily a testbench failure.

For example, suppose a transaction deliberately requests an unsupported operation and the specification requires an error response. The predictor should predict that error response, and the scoreboard should compare it like any other expected behavior.

request = unsupported_request;


expected = predictor.predict(request);

// Expected behavior:
// status == ERROR

if (!actual.compare(expected)) begin
`uvm_error("SB",
"DUT did not produce the expected error response")
end

This is preferable to simply suppressing all errors generated during a negative test. The verification environment should still prove that the DUT produced the correct error behavior.

Important distinction: “An error condition occurred” and “the verification failed” are not synonymous. A negative test can expect the DUT to report or handle an error correctly.

Step 6: Separate report severity from failure classification

UVM report severity is useful, but the severity alone should not be the entire error strategy.

For example, these two failures may both use `uvm_error while representing very different problems:

// DUT behavior problem


`uvm_error("SB_MISMATCH", "Response data is incorrect")

// Testbench correlation problem
`uvm_error("SB_CORR", "Response ID was never predicted")

The report IDs, message content, transaction context, and checker state can distinguish them during triage.

Useful information often includes:

  • component name or checker instance,
  • transaction ID or composite correlation key,
  • stream or channel,
  • expected and actual values,
  • simulation time or cycle,
  • relevant protocol state, and
  • outstanding transaction count.

Lesson 30 will develop this diagnostic discipline further.

Step 7: Know when the testbench itself is broken

Not every checker failure should be blamed on the DUT.

A useful debugging classification is:

Observation Possible source First thing to inspect
Wrong expected value Predictor/reference model Prediction inputs and model state
Wrong actual value DUT or monitor Monitor reconstruction and waveform
Unknown response ID DUT, monitor, predictor, or correlation logic Accepted request and ID propagation
Many missing responses DUT, reset, monitor, or testbench shutdown Response observation and drain behavior
Checker stops unexpectedly Fatal/report configuration Report severity and action configuration

The goal is to classify the failure before modifying the DUT or checker.

Step 8: Use a small, deterministic failure first

Error handling is easiest to debug when the failure is intentional and reproducible.

Start with three transactions:

REQ  ID=10  DATA=AAAA


REQ  ID=11  DATA=BBBB
REQ  ID=12  DATA=CCCC

RESP ID=10  DATA=AAAA   // match
RESP ID=11  DATA=1234   // mismatch
RESP ID=99  DATA=9999   // unexpected

A useful checker should produce evidence similar to:

ID=10  MATCH


ID=11  ERROR
Expected DATA=BBBB
Actual   DATA=1234

ID=99  ERROR
No outstanding expectation exists

Then verify the scoreboard state after each response. In particular, determine which entries remain outstanding and whether the mismatch consumed the expected transaction according to your chosen policy.

Common mistakes

  • Using `uvm_fatal for every mismatch: one DUT defect can prevent the environment from revealing additional failures.
  • Using `uvm_warning for real specification violations: important failures can disappear into normal regression noise.
  • Suppressing expected errors: a negative test should verify the required error response, not simply ignore error traffic.
  • Leaving stale scoreboard state after a failure: one bad transaction can produce many misleading secondary errors.
  • Reporting without context: “mismatch” is much less useful than ID, stream, expected value, actual value, and timing.
  • Assuming every unknown ID is a DUT bug: the predictor, monitor, reset handling, or ID interpretation may be wrong.
  • Using end-of-test checks as timeout detection: a missing response should be detected according to the protocol's timing requirement. That is the focus of Lesson 28.
  • Changing checker logic immediately after seeing a failure: first reproduce the failure and determine whether the evidence points to the DUT, monitor, predictor, or checker.

Debugging strategy: classify before fixing

  1. Capture the first meaningful failure. Do not begin with the final cascade of messages.
  2. Identify the failure category. Is it mismatch, correlation, ordering, reset, timeout, or environment configuration?
  3. Inspect the transaction boundary. Confirm when the monitor considered the request/response accepted.
  4. Trace the transaction. Follow monitor → predictor → expected state → actual monitor → checker.
  5. Check state after the failure. Look for stale or accidentally deleted expectations.
  6. Use the waveform only after understanding the transaction-level failure. Then inspect the relevant protocol handshakes and signals.
  7. Re-run with the same seed. A reproducible failure is much easier to classify.
Debug rule: Do not “fix” a checker merely because it reports a failure. First determine whether the checker is exposing a DUT defect, a monitor defect, a predictor defect, or a checker-state defect.

Exercise 1: Classify the failures

For each condition, choose whether the environment should normally use an informational message, warning, error, or fatal response:

  1. A response data field does not match the prediction.
  2. A required configuration object is null during environment construction.
  3. The number of outstanding transactions exceeds a performance guideline but remains within the legal protocol limit.
  4. A negative test deliberately sends an unsupported command, and the DUT returns the required error status.
  5. The DUT returns a response for an ID that has no outstanding expectation.

For each answer, explain whether verification should continue and what information should be included in the diagnostic.

Exercise 2: Make a scoreboard failure useful

Take an out-of-order scoreboard and improve its error messages.

For a mismatch, include:

  • transaction ID,
  • expected data,
  • actual data,
  • simulation time, and
  • number of outstanding transactions after processing.

Then intentionally inject one mismatch and one unexpected response. Confirm that the checker remains usable after both failures.

Exercise 3: Expected error behavior

Create a negative test in which the DUT is required to reject an invalid request.

Do not suppress the resulting error traffic. Instead:

  1. represent the invalid request explicitly,
  2. predict the required error response,
  3. observe the actual response, and
  4. let the scoreboard determine whether the DUT handled the error correctly.

Advanced challenge: prevent error cascades

Extend an out-of-order scoreboard so that it distinguishes:

  • unknown response ID,
  • data mismatch,
  • duplicate response,
  • reset-related stale expectation, and
  • unresolved expectation at end of test.

For each failure, decide what happens to the internal scoreboard state.

Then create a scenario where one DUT defect could generate multiple observations. Design the checker so that the resulting messages help identify the primary problem instead of producing an uncontrolled cascade.

Success criterion: after every failure, you can explain exactly which expected entries remain, which were consumed, and why verification continues or stops.

Knowledge check

  1. Why is `uvm_error usually more appropriate than `uvm_fatal for an ordinary scoreboard mismatch?
  2. Why should a negative test verify an expected error response instead of simply suppressing the error?
  3. What is the difference between a DUT behavior failure and a testbench correlation failure?
  4. Why can stale scoreboard state create secondary failures?
  5. Why is an unresolved transaction at end of test not automatically a timeout?
  6. What information makes a scoreboard error substantially easier to debug?
  7. When is terminating the simulation justified?
Answers
  1. A mismatch normally does not make the verification environment unusable; continuing can expose additional failures.
  2. Negative tests must prove that the DUT handles the invalid condition according to the specification.
  3. A DUT failure means the observed behavior is wrong; a correlation failure means the testbench may have incorrectly reconstructed, predicted, or matched the transaction.
  4. Stale state can cause later transactions to be classified incorrectly and create misleading secondary errors.
  5. End-of-test detection tells you that something remains unresolved; a timeout requires a defined time or cycle limit.
  6. ID/key, stream, expected and actual values, timing, and relevant checker state provide actionable context.
  7. Termination is justified when continuing would make verification meaningless, such as a critical environment initialization failure or unrecoverable checker state.

Key takeaways

  • Error handling starts with classifying the condition, not blindly choosing a report macro.
  • `uvm_error records an unexpected verification failure while allowing the environment to continue when possible.
  • `uvm_fatal should be reserved for conditions where meaningful verification cannot continue.
  • Expected error behavior belongs in the verification model: deliberately invalid stimulus should produce a deliberately predicted response.
  • Checker state must remain consistent after failures to avoid misleading cascades.
  • Diagnostics should identify the transaction, correlation information, expected/actual behavior, and relevant state.
  • An end-of-test outstanding transaction is different from a protocol timeout; Lesson 28 will add explicit timeout detection.

Where this lesson fits

This lesson completes the first major error-management layer of the checking architecture:

Lesson 21  Scoreboard patterns
  ↓


Lesson 22  Reference models
↓
Lesson 23  Predictors
↓
Lesson 24  In-order checking
↓
Lesson 25  Out-of-order checking
↓
Lesson 26  Multi-stream checking
↓
Lesson 27  Error handling
↓
Lesson 28  Timeout detection
↓
Lesson 29  End-of-test draining
↓
Lesson 30  Debug-friendly diagnostics

Lesson 27 asks what happens when a checker detects something wrong. Lesson 28 will make one particularly important failure explicit: the expected response never arrives within the allowed time.