How to Solve a Complex Verification Issue: Reproduce, Shrink and Isolate a Rare Bug
In short: A complex issue is usually a bug that fails only sometimes, because several conditions have to line up at once. You solve it in four steps. Sweep many seeds to see how often it fails and get one seed that reproduces it. Shrink that failing run to the shortest piece that still fails. Read the last cycles of that piece to find the exact conditions. Then write a short directed test that creates those conditions every time. In this lesson a UVM bench does all four steps in a single run, on an 8-entry FIFO with a bug that needs three things to happen together.
What makes a verification issue complex?
Most bugs are loud. They fail on every seed, the first error points close to the cause, and an hour later they are fixed.
The ones that eat a week are different:
- They fail only sometimes. One seed in ten, or one night in a week. Rerun the regression and it is green.
- They need several conditions at once. A stall, then a particular fill level, then a pointer at a particular value. Each condition on its own is harmless and happens all the time.
- The failing run is long. Thousands of cycles of random traffic, and somewhere in them is the one cycle that matters.
You cannot reason your way to the cause from a long random log. You have to cut the problem down until the cause is the only thing left. That is what this lesson is about.
The picture: a car that rattles only sometimes
Your car makes a rattle, but only some days. You take it to the garage and of course it is quiet.
A good mechanic does not start taking the dashboard apart. They ask questions until the rattle has a recipe: only when the engine is cold, only over bumps, only when turning left. Then they drive one short loop that has a cold start, a speed bump and a left turn, and the rattle comes every time. Now it can be found in ten minutes.
That is the whole method. Turn a rattle that happens sometimes into a short drive that rattles every time. In verification, the short drive is a directed test.
What will you learn in this lesson?
By the end of this lesson you will be able to:
- Explain why some bugs fail only on some seeds, and why that makes them hard.
- Reproduce an intermittent failure by sweeping seeds and keeping the one that fails.
- Shrink a long failing run to its shortest failing prefix with a binary search.
- Read the last cycles of that prefix to find the exact conditions behind the bug.
- Turn those conditions into a short directed test that fails every time, and keep it.
What are the steps to solve a complex issue?
The classic steps still hold: reproduce it, break it down, gather data, look for patterns, find the root cause. For an intermittent bug, each one has a concrete form:
| Classic step | For an intermittent bug | What you get |
|---|---|---|
| Reproduce | Sweep: run many short trials, each with its own seed | How often it fails, and one seed that fails every time you rerun it |
| Break it down | Shrink: cut the failing run down to the shortest piece that still fails | A failure in tens of cycles instead of thousands |
| Gather data, find patterns | Isolate: read the state in the last cycles of that piece | The exact conditions that line up |
| Find the root cause, fix it | Lock in: write a directed test from those conditions | A test that fails every time before the fix and passes after it |
Why does the same seed give the same failure?
A simulator’s random numbers are not really random. They come from a generator that starts from a seed. Same seed, same code, same numbers, same traffic, same failure. That is what makes an intermittent bug fixable: once one seed fails, it fails every time you rerun it.
Two cautions. Change the testbench code and the same seed can give different traffic, so record the seed and the code version together. And make each trial take its random numbers from its own seed, so trial 7 does not change just because trial 6 got longer.
How does shrinking work?
If a seed produces the same cycles every time, then the first 25 cycles of a 50-cycle run are exactly the first 25 cycles of the long run. So you can ask a yes-or-no question: does the first half still fail?
- If yes, the bug is triggered somewhere in the first half. Keep it and ask about its first half.
- If no, the trigger is in the second half. Ask about a longer piece.
This is a binary search. A 50-cycle run needs about six extra runs to find the shortest failing prefix. A 50,000-cycle run needs only about sixteen. The idea is known as delta debugging when you also remove pieces from the middle; cutting from the end is the simplest form, and it is already enough for most stimulus.
Why are the last cycles the important ones?
The shortest failing prefix fails, and the prefix one cycle shorter passes. So the cycle that triggers the bug is the last one. Everything the bug needs is in the state of the design at that moment and the few cycles just before it. Print those, and the conditions are written in front of you.
Each trial must end with a few quiet cycles that empty the design, so a lost or wrong value always reaches the checker. Otherwise a short prefix could hide a bug that it really did trigger.
How do you catch a bug that fails only on some seeds?
Let’s do all four steps on a real UVM bench, in one simulation.
The IP: an 8-entry valid/ready FIFO
- in_ready is 1 when fewer than 8 words are stored. A push happens when in_valid and in_ready are both 1.
- out_valid is 1 when at least one word is stored. A pop happens when out_valid and out_ready are both 1.
- out_data is the oldest word. Words leave in order, none lost, none repeated.
The two bugs
- +BUG=1, the rare one: right after a cycle where the receiver stalled, if exactly one word is stored and the write pointer is at 7, a push and a pop in the same cycle lose the pushed word. Three conditions have to line up, and each one on its own is common.
- +BUG=2, the loud one: out_valid stays low while exactly one word is stored. One word stored happens all the time, so this bug fails almost at once.
BUG=2 is there for contrast. It is the kind of bug that does not need this method.
What does the bench do in one run?
| Step | What the test does |
|---|---|
| SWEEP | 30 trials of 50 random cycles, seeds 100 to 129, in_valid 50% and out_ready 70%. Each trial starts with a reset and ends with 10 drain cycles. Prints which seeds failed. |
| SHRINK | Takes the first failing seed and binary-searches the shortest prefix that still fails |
| WINDOW | Reruns that shortest prefix and prints the FIFO state in its last cycles: words stored, write pointer, whether the cycle before was a stall, push, pop |
| DIRECTED | Runs a short directed sequence built from those conditions |
The random traffic comes from the trial’s own seed, through process::self().srandom(seed), so a prefix of a seed is truly the start of its longer run. The scoreboard checks every handshake and every word against a queue model written from the spec.

The code
This file, with its expected output, is also on GitHub in the course repo: tav-verification-basics, 07-rare-bug-debugging.
One file, UVM 1.2, every name starting with tav_. Paste it into EDA Playground, pick Synopsys VCS with UVM 1.2, set the top module to tav_top, and run. Add +BUG=1 or +BUG=2 to switch a bug on.
// tav_shrink_fifo_uvm.sv : a bug that fails on only some seeds; sweep, shrink, isolate, lock in (UVM 1.2)
// Run on Synopsys VCS X-2025.06-SP1 with UVM 1.2 (EDA Playground), 24 Nov 2026.
// The Art of Verification | theartofverification.com
//
// EDA Playground: Synopsys VCS, UVM 1.2, top module "tav_top".
// Paste this whole file into testbench.sv and leave design.sv empty.
//
// The design is an 8-entry valid/ready FIFO. One run of the test does four steps:
// SWEEP 30 short random trials, each with its own seed (seeds 100 to 129), 50 cycles each
// SHRINK takes the first failing seed and finds the shortest prefix of it that still fails
// WINDOW prints the state of the FIFO in the last cycles of that shortest failing prefix
// DIRECTED a short directed test built from those conditions, so the bug fails every time
// Each trial starts with a reset and ends with 10 drain cycles, so a lost word always surfaces.
//
// Run options (one per run):
// (none) the clean design
// +BUG=1 a rare bug: right after a stall, with one word stored and the write pointer at 7,
// a push and a pop in the same cycle lose the pushed word
// +BUG=2 a loud bug: out_valid stays low while exactly one word is stored
//
// Spec (8-entry FIFO):
// in_ready = 1 when fewer than 8 words are stored. push = in_valid and in_ready
// out_valid = 1 when at least 1 word is stored. pop = out_valid and out_ready
// out_data is the oldest word. Words leave in order, none lost, none repeated.
// rst_n (async, active low) empties the FIFO.
`timescale 1ns/1ns
`include "uvm_macros.svh"
import uvm_pkg::*;
// ---------------------------------------------------------------------------
// The design
// ---------------------------------------------------------------------------
module tav_ring_fifo (input logic clk, rst_n,
input logic in_valid,
input logic [7:0] in_data,
output logic in_ready,
output logic out_valid,
output logic [7:0] out_data,
input logic out_ready,
input int bug);
logic [7:0] mem [8];
logic [2:0] wp, rp;
logic [3:0] count;
logic push, pop, stalled;
assign in_ready = (count != 4'd8);
assign out_valid = (bug == 2) ? (count > 4'd1) : (count != 4'd0); // BUG=2
assign out_data = mem[rp];
assign push = in_valid && in_ready;
assign pop = out_valid && out_ready;
always_ff @(posedge clk or negedge rst_n) begin
if (!rst_n) begin
wp <= 0; rp <= 0; count <= 0; stalled <= 0;
end else begin
stalled <= out_valid && !out_ready;
if (push && !(bug == 1 && pop && stalled && count == 4'd1 && wp == 3'd7)) begin // BUG=1
mem[wp] <= in_data;
wp <= wp + 1;
end
if (pop) rp <= rp + 1;
count <= count + push - pop;
end
end
endmodule
// ---------------------------------------------------------------------------
// Interface: the monitor samples just before each rising edge; assertions live here
// ---------------------------------------------------------------------------
interface tav_fifo_if (input logic clk);
logic rst_n, in_valid, in_ready, out_valid, out_ready;
logic [7:0] in_data, out_data;
clocking mon_cb @(posedge clk);
default input #1step;
input rst_n, in_valid, in_ready, in_data, out_valid, out_ready, out_data;
endclocking
A_HOLD_OUT: assert property (@(posedge clk) disable iff (!rst_n)
(out_valid && !out_ready) |=> (out_valid && $stable(out_data)))
else `uvm_error("SVA", "A_HOLD_OUT: out_valid dropped or out_data changed while stalled")
A_NO_X: assert property (@(posedge clk) disable iff (!rst_n) !$isunknown({in_ready, out_valid}))
else `uvm_error("SVA", "A_NO_X: in_ready or out_valid is X")
endinterface
// ---------------------------------------------------------------------------
// Transaction: one clock cycle at the FIFO pins
// ---------------------------------------------------------------------------
class tav_fifo_item extends uvm_sequence_item;
bit in_valid, out_ready, rst;
bit [7:0] in_data;
logic in_ready, out_valid;
logic [7:0] out_data;
`uvm_object_utils(tav_fifo_item)
function new(string name = "tav_fifo_item");
super.new(name);
endfunction
endclass
// ---------------------------------------------------------------------------
// Sequences
// ---------------------------------------------------------------------------
class tav_fifo_base_seq extends uvm_sequence #(tav_fifo_item);
`uvm_object_utils(tav_fifo_base_seq)
bit [7:0] next_data = 1;
function new(string name = "tav_fifo_base_seq");
super.new(name);
endfunction
task cyc(bit v, bit r, int n = 1);
repeat (n) begin
req = tav_fifo_item::type_id::create("req");
start_item(req);
req.in_valid = v; req.out_ready = r; req.in_data = next_data++;
finish_item(req);
end
endtask
task drain();
cyc(0, 1, 10);
endtask
endclass
class tav_reset_seq extends tav_fifo_base_seq;
`uvm_object_utils(tav_reset_seq)
function new(string name = "tav_reset_seq");
super.new(name);
endfunction
task body();
req = tav_fifo_item::type_id::create("req");
start_item(req);
req.rst = 1;
finish_item(req);
endtask
endclass
// Random traffic from a fixed seed: the same seed always gives the same cycles,
// so the first n cycles of a seed are a true prefix of its longer run
class tav_seeded_seq extends tav_fifo_base_seq;
`uvm_object_utils(tav_seeded_seq)
int unsigned seed, n;
function new(string name = "tav_seeded_seq");
super.new(name);
endfunction
task body();
process::self().srandom(seed);
for (int i = 0; i < n; i++)
cyc($urandom_range(99) < 50, $urandom_range(99) < 70); // in_valid 50%, out_ready 70%
drain();
endtask
endclass
// Built from the WINDOW conditions: one word stored, write pointer at 7, a stall, then push and pop
class tav_directed_seq extends tav_fifo_base_seq;
`uvm_object_utils(tav_directed_seq)
function new(string name = "tav_directed_seq");
super.new(name);
endfunction
task body();
cyc(1, 0); // push one word: 1 stored, write pointer 1
cyc(1, 1, 6); // push and pop together 6 times: still 1 stored, write pointer 7
cyc(0, 0); // stall: the receiver is not ready
cyc(1, 1); // push and pop together right after the stall
drain();
endtask
endclass
// ---------------------------------------------------------------------------
// Driver: drives on the falling edge, idles when there is no item
// ---------------------------------------------------------------------------
class tav_fifo_driver extends uvm_driver #(tav_fifo_item);
`uvm_component_utils(tav_fifo_driver)
virtual tav_fifo_if vif;
function new(string name, uvm_component parent);
super.new(name, parent);
endfunction
function void build_phase(uvm_phase phase);
if (!uvm_config_db#(virtual tav_fifo_if)::get(this, "", "vif", vif))
`uvm_fatal("NOVIF", "no virtual interface")
endfunction
task run_phase(uvm_phase phase);
vif.rst_n <= 0; vif.in_valid <= 0; vif.out_ready <= 0; vif.in_data <= 0;
forever begin
seq_item_port.try_next_item(req);
if (req == null) begin
@(negedge vif.clk);
vif.in_valid <= 0; vif.out_ready <= 1;
end else begin
if (req.rst) begin
@(negedge vif.clk);
vif.rst_n <= 0; vif.in_valid <= 0; vif.out_ready <= 0;
@(negedge vif.clk);
vif.rst_n <= 1;
end else begin
@(negedge vif.clk);
vif.in_valid <= req.in_valid; vif.out_ready <= req.out_ready; vif.in_data <= req.in_data;
end
seq_item_port.item_done();
end
end
endtask
endclass
// ---------------------------------------------------------------------------
// Monitor: one transaction per clock, sampled just before the edge
// ---------------------------------------------------------------------------
class tav_fifo_monitor extends uvm_monitor;
`uvm_component_utils(tav_fifo_monitor)
virtual tav_fifo_if vif;
uvm_analysis_port #(tav_fifo_item) ap;
function new(string name, uvm_component parent);
super.new(name, parent);
ap = new("ap", this);
endfunction
function void build_phase(uvm_phase phase);
if (!uvm_config_db#(virtual tav_fifo_if)::get(this, "", "vif", vif))
`uvm_fatal("NOVIF", "no virtual interface")
endfunction
task run_phase(uvm_phase phase);
forever begin
tav_fifo_item t;
@(vif.mon_cb);
t = tav_fifo_item::type_id::create("t");
t.rst = (vif.mon_cb.rst_n !== 1'b1);
t.in_valid = vif.mon_cb.in_valid;
t.in_ready = vif.mon_cb.in_ready;
t.in_data = vif.mon_cb.in_data;
t.out_valid = vif.mon_cb.out_valid;
t.out_ready = vif.mon_cb.out_ready;
t.out_data = vif.mon_cb.out_data;
ap.write(t);
end
endtask
endclass
// ---------------------------------------------------------------------------
// Scoreboard: queue model from the spec, per-trial results, a window of recent cycles
// ---------------------------------------------------------------------------
class tav_fifo_scoreboard extends uvm_scoreboard;
`uvm_component_utils(tav_fifo_scoreboard)
uvm_analysis_imp #(tav_fifo_item, tav_fifo_scoreboard) imp;
bit [7:0] q[$];
int mismatches, cycle, pushes_total;
bit quiet, prev_stall;
string trial_name, first_msg;
string hist[$]; // one line per cycle of the current trial
function new(string name, uvm_component parent);
super.new(name, parent);
imp = new("imp", this);
endfunction
function void start_trial(string name, bit be_quiet);
trial_name = name; quiet = be_quiet;
mismatches = 0; cycle = 0; pushes_total = 0; prev_stall = 0; first_msg = "";
hist.delete();
endfunction
function void err(string msg);
mismatches++;
if (mismatches == 1) begin
first_msg = $sformatf("cycle %0d: %s", cycle, msg);
if (!quiet) `uvm_error("MISMATCH", $sformatf("%s, %s", trial_name, first_msg))
end
endfunction
function void write(tav_fifo_item t);
bit e_ready, e_valid, push, pop;
if (t.rst) begin
q.delete(); prev_stall = 0;
return;
end
cycle++;
e_valid = (q.size() > 0);
e_ready = (q.size() < 8);
if (t.out_valid !== e_valid) err($sformatf("out_valid=%b, expected %b with %0d stored", t.out_valid, e_valid, q.size()));
if (t.in_ready !== e_ready) err($sformatf("in_ready=%b, expected %b with %0d stored", t.in_ready, e_ready, q.size()));
push = t.in_valid && t.in_ready;
pop = t.out_valid && t.out_ready;
// what the cycle looked like, from the spec's point of view
hist.push_back($sformatf("cycle %0d: stored=%0d write_ptr=%0d stalled_before=%0d push=%0d pop=%0d",
cycle, q.size(), pushes_total % 8, prev_stall, push, pop));
if (pop) begin
if (q.size() == 0) err($sformatf("popped data=%0d but nothing was stored", t.out_data));
else if (t.out_data !== q[0]) err($sformatf("popped data=%0d, expected %0d", t.out_data, q[0]));
if (q.size() > 0) void'(q.pop_front());
end
if (push) begin
q.push_back(t.in_data);
pushes_total++;
end
prev_stall = t.out_valid && !t.out_ready;
endfunction
// the cycles around the end of the random part of the trial
function void print_window(int last_cycle);
for (int i = last_cycle - 3; i <= last_cycle + 1; i++)
if (i >= 0 && i < hist.size()) `uvm_info("WINDOW", hist[i], UVM_NONE)
endfunction
endclass
// ---------------------------------------------------------------------------
// Agent and environment
// ---------------------------------------------------------------------------
class tav_fifo_agent extends uvm_agent;
`uvm_component_utils(tav_fifo_agent)
uvm_sequencer #(tav_fifo_item) sqr;
tav_fifo_driver drv;
tav_fifo_monitor mon;
function new(string name, uvm_component parent);
super.new(name, parent);
endfunction
function void build_phase(uvm_phase phase);
sqr = uvm_sequencer#(tav_fifo_item)::type_id::create("sqr", this);
drv = tav_fifo_driver::type_id::create("drv", this);
mon = tav_fifo_monitor::type_id::create("mon", this);
endfunction
function void connect_phase(uvm_phase phase);
drv.seq_item_port.connect(sqr.seq_item_export);
endfunction
endclass
class tav_fifo_env extends uvm_env;
`uvm_component_utils(tav_fifo_env)
tav_fifo_agent agt;
tav_fifo_scoreboard scb;
function new(string name, uvm_component parent);
super.new(name, parent);
endfunction
function void build_phase(uvm_phase phase);
agt = tav_fifo_agent::type_id::create("agt", this);
scb = tav_fifo_scoreboard::type_id::create("scb", this);
endfunction
function void connect_phase(uvm_phase phase);
agt.mon.ap.connect(scb.imp);
endfunction
endclass
// ---------------------------------------------------------------------------
// Test: sweep, shrink, window, directed
// ---------------------------------------------------------------------------
class tav_shrink_test extends uvm_test;
`uvm_component_utils(tav_shrink_test)
tav_fifo_env env;
virtual tav_fifo_if vif;
int unsigned seed_base = 100, n_trials = 30, n_cycles = 50;
function new(string name, uvm_component parent);
super.new(name, parent);
endfunction
function void build_phase(uvm_phase phase);
env = tav_fifo_env::type_id::create("env", this);
if (!uvm_config_db#(virtual tav_fifo_if)::get(this, "", "vif", vif))
`uvm_fatal("NOVIF", "no virtual interface")
endfunction
// one trial: reset, the traffic, then let the monitor see the last cycle
task run_seq(string name, tav_fifo_base_seq s, bit quiet, output int fails);
tav_reset_seq r = tav_reset_seq::type_id::create("r");
r.start(env.agt.sqr);
env.scb.start_trial(name, quiet); // start counting only after the reset, so nothing left
// over from the previous trial is counted in this one
s.start(env.agt.sqr);
repeat (2) @(vif.mon_cb);
#1;
fails = env.scb.mismatches;
endtask
task run_seed(int unsigned seed, int unsigned n, bit quiet, output int fails);
tav_seeded_seq s = tav_seeded_seq::type_id::create("s");
s.seed = seed; s.n = n;
run_seq($sformatf("seed %0d", seed), s, quiet, fails);
endtask
task run_phase(uvm_phase phase);
int fails, failing[$], lo, hi, mid, runs;
string list;
tav_directed_seq d;
phase.raise_objection(this);
// SWEEP: many short trials, each with its own seed
for (int i = 0; i < n_trials; i++) begin
run_seed(seed_base + i, n_cycles, 0, fails);
if (fails > 0) begin failing.push_back(seed_base + i); list = {list, $sformatf(" %0d", seed_base + i)}; end
end
`uvm_info("SWEEP", $sformatf("trials=%0d cycles_each=%0d failing=%0d seeds:%s", n_trials, n_cycles,
failing.size(), failing.size() ? list : " none"), UVM_NONE)
// SHRINK: the shortest prefix of the first failing seed that still fails (binary search)
if (failing.size() > 0) begin
lo = 1; hi = n_cycles; runs = 0;
while (lo < hi) begin
mid = (lo + hi) / 2;
run_seed(failing[0], mid, 1, fails); runs++;
if (fails > 0) hi = mid; else lo = mid + 1;
end
`uvm_info("SHRINK", $sformatf("seed %0d: fails in %0d cycles, still fails in the first %0d (found in %0d extra runs)",
failing[0], n_cycles, lo, runs), UVM_NONE)
// WINDOW: rerun the shortest failing prefix and show its last cycles
run_seed(failing[0], lo, 1, fails);
`uvm_info("WINDOW", $sformatf("seed %0d, first %0d cycles, first error: %s", failing[0], lo, env.scb.first_msg), UVM_NONE)
env.scb.print_window(lo);
end else
`uvm_info("SHRINK", "nothing to shrink: no trial failed", UVM_NONE)
// DIRECTED: the conditions from the window, every time
d = tav_directed_seq::type_id::create("d");
run_seq("directed", d, 0, fails);
`uvm_info("DIRECTED", $sformatf("stall, then push and pop with 1 stored and write pointer 7: %0d cycles -> %s",
env.scb.cycle, fails ? "FAIL" : "PASS"), UVM_NONE)
phase.drop_objection(this);
endtask
function void report_phase(uvm_phase phase);
`uvm_info("SUMMARY", $sformatf("assertion_fails=%0d", uvm_report_server::get_server().get_id_count("SVA")), UVM_NONE)
endfunction
endclass
// ---------------------------------------------------------------------------
// Top
// ---------------------------------------------------------------------------
module tav_top;
logic clk = 0;
int BUG = 0;
always #5 clk = ~clk;
tav_fifo_if vif (clk);
tav_ring_fifo dut (.clk(clk), .rst_n(vif.rst_n), .in_valid(vif.in_valid), .in_data(vif.in_data),
.in_ready(vif.in_ready), .out_valid(vif.out_valid), .out_data(vif.out_data),
.out_ready(vif.out_ready), .bug(BUG));
initial begin
void'($value$plusargs("BUG=%d", BUG));
`uvm_info("TOP", $sformatf("Running with BUG=%0d", BUG), UVM_NONE)
uvm_config_db#(virtual tav_fifo_if)::set(null, "uvm_test_top", "vif", vif);
uvm_config_db#(virtual tav_fifo_if)::set(null, "uvm_test_top.env.agt.*", "vif", vif);
run_test("tav_shrink_test");
end
endmodule
What output should you expect?
With no bug switched on, this is the real log from Synopsys VCS X-2025.06-SP1 with UVM 1.2 (trimmed to the report lines):
[SWEEP] trials=30 cycles_each=50 failing=0 seeds: none
[SHRINK] nothing to shrink: no trial failed
[DIRECTED] stall, then push and pop with 1 stored and write pointer 7: 21 cycles -> PASS
[SUMMARY] assertion_fails=0
Thirty seeds clean, and the directed test passes on the correct design. That last line matters: a directed test is only useful if it passes when the design is right. Now the two bugs, real VCS results:
| Run | SWEEP | SHRINK | WINDOW (trigger cycle) | DIRECTED |
|---|---|---|---|---|
| No bug | 0 of 30 seeds fail | nothing to shrink | none | PASS |
| +BUG=1 (rare) | 3 of 30: seeds 101, 102, 116 | seed 101: 50 cycles down to 26, in 6 extra runs | cycle 27: 1 stored, write pointer 7, stall before, push and pop | FAIL |
| +BUG=2 (loud) | 30 of 30 | seed 100: 50 cycles down to 1, in 6 extra runs | cycle 3: 1 stored, out_valid low | FAIL |

Now follow +BUG=1 through the four steps, straight from its log.
Step 1: sweep
[SWEEP] trials=30 cycles_each=50 failing=3 seeds: 101 102 116
Three seeds in thirty. On most nights a regression with a few of these seeds would come back green. But each failing seed fails every time you rerun it, and each one printed its first error:
UVM_ERROR @ 935: uvm_test_top.env.scb [MISMATCH] seed 101, cycle 28: popped data=13, expected 26
A word went missing. The log does not say why, and the 27 cycles before it are random traffic. That is where most people open the waveform and start scrolling.
Step 2: shrink
[SHRINK] seed 101: fails in 50 cycles, still fails in the first 26 (found in 6 extra runs)
Six more runs of the same seed, each one shorter or longer depending on the last answer. The first 25 random cycles pass, the first 26 fail. So the bug is triggered by random cycle 26, and nothing after it matters.

Step 3: read the window
[WINDOW] cycle 24: stored=1 write_ptr=5 stalled_before=0 push=1 pop=1
[WINDOW] cycle 25: stored=1 write_ptr=6 stalled_before=0 push=1 pop=1
[WINDOW] cycle 26: stored=1 write_ptr=7 stalled_before=0 push=0 pop=0
[WINDOW] cycle 27: stored=1 write_ptr=7 stalled_before=1 push=1 pop=1
[WINDOW] cycle 28: stored=1 write_ptr=0 stalled_before=0 push=0 pop=1
Cycle 1 of every trial is an idle cycle while the sequence starts, so random cycle 26 is cycle 27 here. Read it against the cycles around it:
- Cycles 24 and 25 also push and pop with one word stored, and they are fine.
- Cycle 26 is a stall: one word waiting, the receiver not ready.
- Cycle 27 has everything at once: one word stored, the write pointer at 7, a stall on the cycle before, and a push and a pop together.
- Cycle 28 pops the word pushed in cycle 27. It should be 26. The FIFO hands out 13, an old value still sitting in slot 7, because the new word was never written.
That is the recipe. No waveform was needed to find it.
Step 4: lock it in
[DIRECTED] stall, then push and pop with 1 stored and write pointer 7: 21 cycles -> FAIL
The directed sequence builds the recipe on purpose: one push, six cycles of push and pop together to walk the write pointer to 7 with one word stored, one stall, then a push and a pop. It fails on the buggy design and passes on the correct one. That test, not seed 101, is what goes into the regression, because a bench change can make seed 101 produce different traffic tomorrow. The assertion A_HOLD_OUT also fired 6 times in this run, on later cycles where the out-of-step write pointer let a push change the word waiting at the output.
And the loud bug?
BUG=2 failed all 30 seeds, and shrinking took seed 100 down to 1 random cycle: one push, and on the next cycle out_valid is low with a word stored. When the sweep says 30 of 30, you do not need this method. The sweep result alone tells you which kind of bug you have.
What are the most common mistakes with intermittent bugs?
| Mistake | What it looks like | Fix |
|---|---|---|
| Rerunning until it passes | The nightly failure is green on a rerun, so it gets closed | A failure that went away is still a bug. Keep the seed and reproduce it |
| Not recording the seed | The log shows the error but not the seed that made it | Print the seed at the start of every test, and keep it with the failure |
| Changing the bench before reproducing | A new seed or new code, and the failure is gone | Reproduce first on the exact seed and code version, then change things |
| Debugging the full long run | Hours scrolling through thousands of cycles of waveform | Shrink first. Debug the shortest failing piece |
| One random stream for the whole test | Making one trial shorter changes the traffic in all the trials after it | Give each trial its own seed |
| No drain at the end of a trial | A short prefix triggers the bug but the lost data never reaches the checker | End every trial with quiet cycles that empty the design |
| Fixing without a directed test | The fix seems to work because the random seed stopped failing | Prove the fix with a directed test that failed before it and passes after it |
| Only one seed after the fix | The original seed passes, so the bug is marked fixed | Run the directed test and a wide seed sweep; similar bugs nearby show up there |
Can AI help with a rare bug?
Yes, once you have shrunk it. A long random log is too big and too noisy for an assistant to reason about. A five-line window of the last cycles is exactly the kind of input it handles well.
Task: give an assistant the spec and the WINDOW lines from the +BUG=1 run, without telling it the bug, and ask what conditions trigger it and for the shortest directed sequence that would reproduce it.
Tool: Claude, in Anthropic’s Cowork app, 24 Nov 2026, run in a fresh session that had never seen the bench, the RTL or the bug list. It got only the prompt below.
Prompt:
You are a senior design verification engineer. Help me find the bug.
Design: an 8-entry FIFO with valid/ready on both sides.
- in_ready = 1 when fewer than 8 words are stored. push = in_valid && in_ready.
- out_valid = 1 when at least 1 word is stored. pop = out_valid && out_ready.
- out_data is the oldest word. Words leave in order, none lost, none repeated.
A random test fails on 3 of 30 seeds. I shrank one failing seed: its first 26 random
cycles fail, its first 25 pass. Each trial ends with drain cycles. These are the last
cycles of the shortest failing run, as seen by the reference model:
[WINDOW] cycle 24: stored=1 write_ptr=5 stalled_before=0 push=1 pop=1
[WINDOW] cycle 25: stored=1 write_ptr=6 stalled_before=0 push=1 pop=1
[WINDOW] cycle 26: stored=1 write_ptr=7 stalled_before=0 push=0 pop=0
[WINDOW] cycle 27: stored=1 write_ptr=7 stalled_before=1 push=1 pop=1
[WINDOW] cycle 28: stored=1 write_ptr=0 stalled_before=0 push=0 pop=1
First error: cycle 28: popped data=13, expected 26
1. Which cycle triggers the bug, and what conditions line up there?
2. Which conditions are really needed, and which might be coincidence? How would you check?
3. Write the shortest directed sequence (in_valid, out_ready per cycle, from empty) that
should reproduce it.
Keep it short.
Output (excerpt):
1. Trigger cycle: 27; the error only shows up at 28. At cycle 27: stored=1, push and pop
together, stalled_before=1, write_ptr=7. Cycles 24 and 25 also had push and pop at
stored=1 and passed. The difference at 27 is the stall just before it and the wrap.
2. Most likely needed: stall before + push and pop together + stored=1.
Possibly coincidence: write_ptr=7, the wrap. This is the one to rule out first.
How to check: directed tests that change one condition at a time.
3. A. Assumes the wrap is not needed (4 cycles):
c0: 1,0 c1: 0,0 (stall) c2: 1,1 c3: 0,1 (pop and check)
B. If A passes, the wrap matters (10 cycles):
c0: 1,0 c1-c6: 1,1 (walks write_ptr to 7) c7: 0,0 c8: 1,1 c9: 0,1
If A fails, the wrap is a coincidence. If only B fails, the wrap is needed.
How I validated it: it picked the right trigger cycle and listed all four conditions. Its sequence B is the same recipe as the bench’s directed test, which failed on VCS in the +BUG=1 run. To settle its open question I ran its two sequences on the design with Icarus Verilog 12 and a plain testbench: A passes and B fails, and B without the stall also passes. So the stall and the wrap are both needed.
Where it fell short:
- It guessed wrong about the wrap. It called write_ptr=7 the condition most likely to be a coincidence. The wrap is required. To its credit, it proposed the exact experiment that proves it wrong, which is the right habit: never trust a guess you can test in four cycles.
- It did not explain the value 13. An old word in slot 7 is the clue that the write was skipped rather than written to the wrong place. It went straight past it.
- It never suspected the bench. A wrong model, or a monitor that samples on the wrong edge, could produce the same window. Keep the bench on the suspect list.
The shrink made this possible. Five lines of window are something an assistant can reason about. Fifty cycles of random traffic would not have been.
Interview questions on complex and intermittent bugs
- A test fails once in a nightly regression and passes on rerun. What do you do? Treat it as a real bug. Get the seed and the code version from the failing run, rerun that exact seed to reproduce it, then shrink it.
- Why does the same seed reproduce the same failure? The simulator’s random numbers come from a generator started from the seed. Same seed and same code give the same stimulus.
- What can break seed reproducibility? Changing the testbench code, changing the order objects are created or randomized, or sharing one random stream across parts of the test that should be independent.
- How do you shrink a long failing test? Rerun a shorter prefix of the same seed and binary-search the shortest length that still fails. Each trial needs drain cycles at the end so the failure can surface.
- Why is the last cycle of the shortest failing prefix important? That prefix fails and one cycle shorter passes, so the triggering cycle is the last one. The design state there holds the conditions.
- How do you prove the fix for a rare bug? A directed test built from the conditions fails before the fix and passes after it, and a wide seed sweep stays clean.
- How is a multi-condition bug different from a corner case? A corner case is one extreme value. A multi-condition bug needs several ordinary conditions to happen together, so random tests reach it only by luck.
Practice challenge
Try these on the demo bench:
- Change n_trials to 100 and run +BUG=1. How many seeds fail? Is the fraction close to what you saw with 30?
- Shrink the second failing seed instead of the first. Does its window show the same three conditions?
- Remove the drain() call at the end of tav_seeded_seq and run +BUG=1 again. What happens to the SHRINK result, and why?
- Write a second directed test that reaches the same conditions in a different way, for example by filling the FIFO first. Does it fail too?
If both directed tests fail, you have found the conditions, not just one lucky path to them.
Frequently asked questions
How do you debug an intermittent failure in verification?
Reproduce it on the exact seed and code version that failed. Shrink the failing run to the shortest piece that still fails. Read the state in its last cycles to find the conditions. Then write a directed test from those conditions so it fails every time.
What is a seed in simulation?
The starting value of the simulator’s random number generator. The same seed with the same code produces the same random stimulus, which is what lets you reproduce a random failure.
What is test shrinking?
Cutting a failing test down to the smallest version that still fails. Cutting from the end with a binary search is the simplest form. Delta debugging goes further and also removes pieces from the middle.
Why do some bugs fail only on some seeds?
Because they need several conditions at the same time, such as a stall, a particular fill level and a particular pointer value. Random traffic lines them up only now and then.
Should I keep the failing seed in my regression?
Yes, but do not rely on it. A small bench change can make the same seed produce different traffic. The directed test built from the conditions is what protects you for good.
References and related lessons
References
- Accellera UVM standard downloads: the UVM library this bench uses.
- EDA Playground: run the demo in your browser with Synopsys VCS.
- IEEE 1800 SystemVerilog standard: random stability and process::srandom are described in the chapter on random number generation.
Related lessons
- Full course: Verification Basics, all 8 lessons in order
- Previous lesson: Debugging in Verification: The Art and Science of Finding the Real Bug
- Next lesson: Formal vs Functional Verification: What Each One Proves, With a Real Example
- Stress Verification in UVM: Finding the Bugs Normal Random Testing Misses
- The Practical Verification Debug Guide: A Repeatable Method
- Assertions and their advantages
Part of the learning path Verification fundamentals
