Stimulus strategy at the SoC level is largely about generating traffic that's legal - constrained to the address map, the register model, and the protocol each interface actually implements. A significant part of an SoC's specification is about what happens when something isn't legal: a corrupted packet, an illegal register write, a bit flip in memory. This article looks at how verification deliberately breaks things on purpose, and how it tells the difference between an error it caused and a real bug.

9 min read | Intermediate Level

What You'll Learn

  • Why error-handling logic needs its own dedicated stimulus strategy instead of showing up by accident
  • The main categories of negative tests at the SoC level - protocol violations, illegal accesses, and memory faults
  • Where and how errors actually get injected into a testbench
  • How the environment tells an intentionally injected error apart from a genuine, unexpected bug

Why Error Paths Need Their Own Stimulus Strategy

A well-constrained random test is, by design, unlikely to ever produce an illegal transaction, a corrupted packet, or a memory bit flip - constraints exist specifically to keep stimulus inside the legal space. That's exactly the problem: real hardware has to handle a corrupted bus transaction, a bad ECC codeword, or a software bug that writes to the wrong register, and none of that error-handling logic - retry state machines, ECC correction, interrupt-driven fault handlers, watchdog recovery - gets meaningfully exercised by stimulus that's constrained to never trigger it. If a test plan never deliberately breaks something, an entire class of RTL that exists purely to detect and recover from bad input goes unverified, no matter how much legal traffic the regression runs.

What Counts as a Negative Test

A few categories cover most of what negative testing at the SoC level actually targets:

  • Protocol violations. A corrupted CRC or parity bit, a malformed packet header, an illegal burst length - anything that breaks the rules of the interface protocol itself, aimed at the logic responsible for detecting and reporting that violation.
  • Illegal accesses. A write to a read-only register, an access from a master that isn't authorized for that region, a read from an address the current configuration has disabled - these target the SoC's access-control and decode-error logic rather than any single protocol.
  • Memory faults. A bit flip in an ECC-protected memory, ranging from a single correctable error to a multi-bit uncorrectable one, aimed specifically at the ECC decoder's detection, correction, and reporting paths.
  • Sequencing and configuration violations. Issuing a request during a power-down transition, or before a required initialization sequence completes, ties directly back into the power-sequencing and reset-ordering bugs covered earlier in this chapter - the same class of bug, reached deliberately instead of by accident.

Where and How Errors Actually Get Injected

There are two broad places to inject a fault, and they test different things.

Boundary injection corrupts a transaction at the interface, before it reaches the DUT - a driver-level callback flips a CRC bit, corrupts a data field, or sends an out-of-range address, right at the point where the DUT would normally receive a legal one. This is generally the preferred approach, because it exercises the DUT's own detection logic exactly the way it would encounter the error in the field: the DUT still has to notice the corruption itself, not just react to a state it was artificially placed into.

Internal injection forces a signal or a memory location directly, from inside the testbench, bypassing the interface entirely - flipping bits in a memory array through a backdoor write, for instance, rather than corrupting a transaction that writes through it. This reaches states a boundary injection sometimes can't - an already-stored value that needs to go bad while sitting in memory, not while being written - but it tests only the recovery logic downstream of the injection point, not any detection logic upstream of it.

A memory ECC agent is a good example of internal injection done properly: rather than corrupting write data, the injection happens on the read side, flipping specific bit positions in the data returned from memory before the ECC decoder sees it. A configurable agent typically supports single-bit, double-bit, and arbitrary multi-bit error injection, either at a fixed bit position or across a configurable ratio of bits, so the same environment can target both the decoder's correctable-error path and its uncorrectable-error detection path with the same infrastructure.


// Error injection agent config - targets single-bit vs multi-bit ECC paths
// with the same reusable agent, just by changing the error mode
class ecc_error_cfg extends uvm_object;
  `uvm_object_utils(ecc_error_cfg)

  typedef enum {SINGLE_BIT, DOUBLE_BIT, MULTI_BIT} err_mode_t;

  rand err_mode_t    err_mode;
  rand bit [63:0]    err_position_mask;  // which bit(s) to flip
  rand int unsigned  err_ratio_pct;      // used only in MULTI_BIT mode

  constraint c_single_bit {
    (err_mode == SINGLE_BIT) -> $countones(err_position_mask) == 1;
  }
  constraint c_double_bit {
    (err_mode == DOUBLE_BIT) -> $countones(err_position_mask) == 2;
  }
endclass
Two places to inject an error: at the boundary, where a driver callback corrupts a transaction before the DUT sees it so the DUT's own detection is exercised, or internally, where the testbench forces a signal or flips memory bits directly

Telling a Real Bug from an Expected Error

Injecting an error on purpose means the DUT is expected to report it - the ECC decoder is supposed to flag an uncorrectable error, the protocol checker is supposed to raise a CRC violation. Without special handling, that expected report looks identical to a real bug: a uvm_error from a protocol checker, either way, fails the test. The environment needs a way to distinguish "this error was expected because I caused it" from "this error means something is actually wrong."

The standard pattern is expected-error registration paired with a report catcher. Before injecting the fault, the test registers the specific error ID it expects to see - tied to the transaction, the address, or some other identifying detail - with a central error-injection service. A uvm_report_catcher installed at the environment level intercepts every error report; if its ID matches something currently registered as expected, the catcher demotes it from UVM_ERROR to UVM_WARNING before it can fail the test, and the fact that it fired at all still gets logged and checked against what the test expected to happen. Any error that doesn't match a registered ID passes through as a real UVM_ERROR, exactly as it would in an ordinary test.


class negative_test_report_catcher extends uvm_report_catcher;

  virtual function action_e catch();
    string id = get_id();

    // Only demote errors this specific test pre-registered as expected -
    // anything else still fails the test normally
    if (error_injection_svc::is_expected(id)) begin
      set_severity(UVM_WARNING);
      error_injection_svc::mark_observed(id);   // confirms the DUT actually reported it
      return THROW;
    end

    return THROW;  // unregistered errors pass through unchanged
  endfunction
endclass

Registering an expected error and then confirming it was actually observed matters as much as the demotion itself - a negative test that injects a fault but never checks whether the DUT reported it can pass even if the detection logic is completely broken.

Common Mistakes

Running only legal, constrained-random traffic and treating that as complete coverage.

Error-handling RTL is part of the design's actual specification. A regression built entirely from legal stimulus leaves it completely unverified, regardless of how much legal traffic runs through it.

Injecting faults by forcing deep internal signals instead of at a realistic boundary.

Forcing an internal state can reach conditions a boundary injection can't, but it skips over whatever detection logic sits between the boundary and that internal point - meaning that logic never actually gets tested. Prefer boundary injection wherever the target error can be reached that way.

Demoting every error in a negative test instead of only the specific, registered one.

A catcher that demotes error severity too broadly can hide a genuine, unrelated bug that happens to fire during the same test. Only the specific error ID the test actually injected should ever be demoted.

Summary

In this article, you learned:

  • Error-handling logic - retry state machines, ECC correction, fault interrupts - needs its own deliberately illegal stimulus, since constrained-random legal traffic is designed to never trigger it
  • Protocol violations, illegal accesses, memory faults, and sequencing violations are the main categories of negative tests at the SoC level
  • Boundary injection at the interface tests the DUT's own detection logic realistically; internal injection reaches states a boundary injection can't, but bypasses whatever detection sits upstream of it
  • A configurable memory error-injection agent flips specific bit positions on the read path, letting the same infrastructure target both correctable and uncorrectable ECC paths
  • Expected-error registration paired with a report catcher lets a negative test demote its own intentional error to a warning while still failing on any genuinely unexpected one
Did you find what you were looking for?

Quiz

Test Your Knowledge

1 of 5 Score: 0 / 5