SystemVerilog Scheduling Semantics established that events within the Active region can be processed in any order — the simulator is free to choose. Most of the time this doesn't matter. But when two separate processes both read and write the same variable at the same trigger, that freedom becomes a real problem: the exact same source code can legitimately produce different results depending purely on an order the language never promises to fix.
12 min read | Intermediate Level
What You'll Learn
- What makes something a genuine race condition, rather than just confusing timing
- Why two blocking assignments to the same variable, from different always blocks triggered by the same event, produce genuinely unpredictable results
- Why the exact same scenario becomes fully deterministic once nonblocking assignments are used instead
- The standard, widely-used guidelines for avoiding races in both design and testbench code
What Makes Something a Race Condition?
A race condition exists when a simulation's outcome depends on the relative order two or more events execute in, and that order isn't something the language actually guarantees. It isn't the same as a bug that always misbehaves the same way — a race can pass for months of regressions and then produce a different result the moment the simulator, the seed, or even just the surrounding code changes enough to shift scheduling order.
A Genuine Race: Two Blocking Assignments, Same Trigger
Here, two separate always blocks both trigger on the same clock edge. One writes a; the other reads a to compute b:
module tb;
reg clk;
reg [7:0] a, b;
always #10 clk = ~clk;
// Block 1
always @ (posedge clk) begin
a = 5;
end
// Block 2
always @ (posedge clk) begin
b = a + 1;
end
endmodule
Both blocks execute in the Active region, and the Active region processes its events in whatever order the simulator chooses — the language doesn't specify which of these two blocks runs first. Both outcomes below are equally valid:
| If Block 1 runs first | If Block 2 runs first |
|---|---|
a becomes 5 immediately, then Block 2 reads the new a → b = 6 | Block 2 reads whatever a was before this edge, then Block 1 sets a = 5 → b is something else entirely |
Neither result is wrong, according to the language itself — and that's exactly the problem. The same source code can produce different values for b across different simulators, or even across different runs of the same simulator, with no error or warning at all.
Quick Check
Q: Would adding a $display statement inside Block 2 to print a right before computing b reliably tell you which order actually happened?
Show Answer
It would tell you what happened for that specific simulation run on that specific simulator — but not what will always happen. The whole issue is that this order isn't fixed by the language, so observing it once doesn't guarantee the same order next time, on a different tool, or after an unrelated code change shifts scheduling.
The Fix: Nonblocking Assignments Remove the Ambiguity
Changing both assignments to nonblocking resolves this completely — not by fixing the execution order, but by making the order irrelevant:
always @ (posedge clk) begin
a <= 5;
end
always @ (posedge clk) begin
b <= a + 1;
end
Block 2's right-hand side, a, is now evaluated using whatever value a held before this edge — and that's true no matter which of the two blocks happens to run first in Active, because Block 1's write to a doesn't actually take effect until the NBA region, which only runs after every Active-region read has already completed. b now ends up as (a's pre-edge value) + 1, every single time, on every simulator, regardless of scheduling order.
Quick Check
Q: In the nonblocking version, does it matter whether Block 1 or Block 2's Active-region code executes first?
Show Answer
No — that's the entire point. Block 1's actual write is deferred to NBA either way, so Block 2's read in Active always sees the pre-edge value, completely independent of which block's Active-region code happens to run first.
Guidelines for Avoiding Races
These widely-used rules follow directly from the scheduling model:
- Use nonblocking assignments for sequential (clocked) logic and latches
- Use blocking assignments for combinational logic
- Don't mix blocking and nonblocking assignments within the same
alwaysblock - Avoid having more than one
alwaysblock assign to the same variable - When displaying a value driven by a nonblocking assignment, use
$strobeor$monitorinstead of$display, to guarantee seeing the fully settled value rather than one that depends on Active-region ordering
Testbench-Side Race Avoidance
The same risk exists between testbench and design code, not just within a design's own logic. A testbench that reads a DUT-driven signal using a plain procedural blocking read, at the exact same edge the DUT updates that signal, is exposed to the same kind of ordering ambiguity. The standard fix is to sample through a clocking block, which defines an explicit input skew and guarantees a settled, race-free value — rather than relying on unspecified Active-region ordering between the testbench and the design.
Where Does This Matter in Practice?
Race conditions are one of the most notorious sources of "it worked yesterday" bugs in real verification — a regression can pass reliably for a long time and then fail (or pass differently) purely because an unrelated code change shifted scheduling order enough to flip which side of a race wins. This is exactly why the guidelines above are treated as close to mandatory in most real coding standards, rather than just stylistic preferences.
Common Beginner Mistakes
Mistake #1: Assuming a race that "worked" once is actually fixed
As the first Quick Check shows, observing one specific outcome doesn't mean that outcome is guaranteed. Why? A race can appear to behave consistently for a long time and then produce a different result the moment something shifts scheduling order — passing once is not the same as being correct.
Mistake #2: Mixing blocking and nonblocking assignments in the same always block
This makes the resulting timing much harder to reason about, and is explicitly discouraged by the standard guidelines. Why? Combining the two styles in one block undermines the very consistency that picking one style per block (sequential vs. combinational) is meant to provide.
Mistake #3: Letting more than one always block drive the same variable
Beyond the ordering risk this creates, many tools flag this as a multiple-driver issue on its own. Why? Even setting aside race conditions, having two separate blocks responsible for the same variable is a maintainability problem — it's rarely clear which one is "supposed" to win.
Mistake #4: Reading a DUT-driven signal with a plain blocking read at the same edge it updates
This exposes a testbench to the same ordering ambiguity demonstrated in this article's main example. Why? A clocking block exists specifically to remove this risk, sampling DUT signals at a well-defined, race-free point relative to the clock instead of racing the design directly.
Practice Exercise
Challenge: Identify and Fix a Race
Two always blocks both trigger on posedge clk. One computes sum = x + y;, and a separate block computes avg = sum / 2;. Explain why this is a race condition, and rewrite both blocks to remove it.
Hint
Ask the same question as the article's main example: does the second block's result depend on whether it reads sum before or after the first block updates it?
Solution
always @ (posedge clk) begin
sum <= x + y;
end
always @ (posedge clk) begin
avg <= sum / 2;
end
The original version is a race for exactly the same reason as the article's a/b example: avg's block reads sum, which the other block also writes at the same edge, using blocking assignments whose relative order isn't guaranteed. Switching both to nonblocking makes avg always compute from sum's pre-edge value, regardless of which block's Active-region code happens to run first.
Summary
In this tutorial, you learned:
- A race condition exists when a simulation's outcome depends on an execution order the language doesn't actually guarantee
- Two blocking assignments to the same variable, from different always blocks triggered by the same event, are a genuine, textbook race — either possible outcome is equally valid according to the language
- Switching to nonblocking assignments doesn't fix the execution order — it makes that order irrelevant, since the actual write is always deferred to NBA regardless of which block runs first in Active
- The standard guidelines (nonblocking for sequential logic, blocking for combinational, never mixed, never multiply-driven) all follow directly from this model
- The same risk applies between testbench and design code — a clocking block is the standard way to sample DUT signals without racing them directly
$strobe shows something different from $display. This article explains that model from first principles.A simulation time step is not a single instant — it's an ordered sequence of scheduling regions, each with a specific purpose, that every event happening at that time step passes through in a defined order.
14 min read | Intermediate Level
What You'll Learn
- Why a single simulation time step is divided into an ordered sequence of regions, not a single instant
- What happens in each of the core regions: Preponed, Active, Inactive, NBA, Observed, Reactive, and Postponed
- Why a nonblocking assignment's update is deferred to a later region than where it's evaluated, and why that prevents a classic race condition
- How this model explains behavior already familiar from elsewhere: assertion sampling, program blocks, and $strobe vs $display
A Time Step Is Not a Single Instant
It's tempting to think of everything scheduled "at 10ns" as happening simultaneously, in no particular order. In reality, SystemVerilog defines an ordered sequence of regions within that same time step, and every event — a blocking assignment, a nonblocking assignment, a $display call, a concurrent assertion — is scheduled into a specific one of them:
The core regions, in order, are Preponed, Active, Inactive, NBA, Observed, Reactive, and Postponed. Design code (blocking and nonblocking assignments, $display) runs in the first four; verification-specific constructs (concurrent assertions, program blocks) run in Observed and Reactive. This separation is deliberate — it's what keeps testbench code from racing against the design it's checking.
Preponed: Sampling Before Anything Changes
Preponed runs once per time step, immediately after simulation time advances. Nothing is updated here — it's purely for sampling. This is exactly the "preponed region" referenced throughout this tutorial's Assertions chapter: the values a concurrent assertion uses are captured here, before any of that time step's own updates have had a chance to happen. That's why an assertion sees the value a signal had going into a clock edge, not whatever it might become during that same edge.
Active: Where Most Design and Testbench Code Runs
Active is where the bulk of ordinary execution happens: every blocking assignment executes here directly, continuous assignments and primitive evaluation happen here, and $display/$finish execute here. For a nonblocking assignment, only the right-hand side is evaluated in Active — the actual write is deferred to the NBA region, covered next.
Active can genuinely loop: if executing one event in this region triggers another event that also belongs in Active, the region processes it too, before moving on. This is why, for instance, a chain of combinational logic can fully settle within a single time step before anything advances.
Inactive: A Home for #0 Delays
Inactive holds anything explicitly delayed by #0 — a way to defer a blocking assignment slightly within the same time step. It's a legitimate part of the model, but relying on #0 to "fix" a timing problem is generally considered poor practice, since it tends to paper over a race rather than correctly modeling the intended behavior.
NBA: Where Nonblocking Assignments Actually Update
This is the region that makes nonblocking assignments safe for modeling sequential logic. The right-hand side of every nonblocking assignment is evaluated back in Active — using whatever values were current before this time step's updates — but the actual write to the left-hand side doesn't happen until NBA, a region that only runs after every Active-region read has already completed.
Here's exactly why that matters, using a simple 2-stage shift register:
// Correct: two independent flip-flops in series
always @ (posedge clk) begin
b <= a;
c <= b;
end
Both right-hand sides — a and b — are read in Active, using their values from before this edge. Both writes then apply together in NBA. Given a taking the values 1, 2, 3, 4 across four clock edges, this produces:
| After cycle | a | b | c |
|---|---|---|---|
| 1 | 1 | 0 | 0 |
| 2 | 2 | 1 | 0 |
| 3 | 3 | 2 | 1 |
| 4 | 4 | 3 | 2 |
c correctly lags a by two full cycles — exactly what two staged flip-flops should do. Now compare the same logic written with blocking assignments:
// Broken: collapses the intended 2-stage pipeline
always @ (posedge clk) begin
b = a;
c = b; // reads the value b was JUST assigned, not its old value
end
b = a updates b immediately, in place, in Active. c = b then executes right after, reading b's brand-new value — not the value it held before this edge. Using the exact same a sequence:
| After cycle | a | b | c |
|---|---|---|---|
| 1 | 1 | 1 | 1 |
| 2 | 2 | 2 | 2 |
| 3 | 3 | 3 | 3 |
| 4 | 4 | 4 | 4 |
b and c are now identical every single cycle — the intended 2-stage delay has collapsed into a single stage duplicated twice. This is the textbook reason sequential logic uses nonblocking assignments: NBA's deferred timing guarantees every statement in Active reads pre-edge values, exactly matching how real flip-flops update simultaneously in hardware.
Quick Check
Q: If a third stage, d <= c;, were added to the correct (nonblocking) version, how many cycles behind a would d lag?
Show Answer
Three cycles. Each additional staged nonblocking assignment adds exactly one more cycle of delay, since every stage's right-hand side is read using the previous cycle's already-settled value — a direct consequence of NBA deferring every update until after that time step's Active-region reads are done.
Observed: Where Concurrent Assertions Actually Evaluate
Observed runs once per time step, and it's specifically where a concurrent assertion's property expression is evaluated — using the values already captured back in Preponed. This two-step split (sample in Preponed, evaluate in Observed) is what SystemVerilog Concurrent Assertions and the rest of that chapter build on throughout.
Reactive: Home for Program Blocks and Assertion Actions
Reactive is where two specific things run: code inside a program block, and the pass/fail action block of a concurrent assertion (the $display that follows assert property(p)). This is exactly why SystemVerilog Program Block states that program blocks execute in the reactive region — it's a deliberate design choice, keeping testbench-side reactions separated from the design's own Active/Inactive/NBA activity for that same time step.
Postponed: Where $strobe and $monitor See the Truly Final Value
$display executes in Active, alongside everything else competing for that region. If two separate processes both react to the same event, there's no guarantee about which one's Active-region code runs first — so a $display reading a signal that another process is also about to update in that same time step might show a stale value, depending on execution order.
$strobe and $monitor avoid this entirely by running in Postponed — a region that only executes after every other region for that time step has fully completed. Whatever they print is guaranteed to be the final, settled value, regardless of which order Active-region processes happened to run in.
Quick Check
Q: If a testbench needs to log a signal's value and be certain it reflects everything that happened at that time step, is $display or $strobe the safer choice?
Show Answer
$strobe. Since it runs in Postponed, after every other region has settled, it removes any dependency on Active-region execution order between multiple competing processes — $display offers no such guarantee.
Where Does This Matter in Practice?
This model is the reason for several conventions taken for granted elsewhere in this tutorial: nonblocking assignments for sequential logic, blocking for combinational; concurrent assertions sampling in Preponed and evaluating in Observed; program blocks running in Reactive specifically to avoid racing the design; and $strobe/$monitor existing as separate system tasks from $display at all.
Common Beginner Mistakes
Mistake #1: Using blocking assignments for sequential logic
As the shift register example shows, this can silently collapse a multi-stage pipeline into duplicated single-stage behavior. Why? A blocking assignment's write takes effect immediately, in place, so a later statement in the same block can end up reading a value that was never supposed to be visible until the next clock edge.
Mistake #2: Assuming $display always shows the fully settled value
$display runs in Active, where multiple processes can be competing to update the same signal in an order that isn't fully deterministic. Why? If a check specifically depends on seeing a time step's truly final value, $strobe or $monitor removes that ambiguity; $display does not.
Mistake #3: Overusing #0 delays to work around a race
Reaching for #0 can appear to fix a timing issue without actually addressing its cause. Why? It's generally better to model the real relationship correctly — with nonblocking assignments, or with a program block for testbench code — than to paper over a race with an extra zero-delay.
Mistake #4: Assuming every region runs exactly once per time step
Active, Inactive, and NBA can genuinely loop, re-triggering each other if new events keep landing back in an earlier region. Why? A single time step can involve several passes through this cluster before settling — it isn't always one straight pass through the full sequence of regions.
Practice Exercise
Challenge: Predict a Broken Swap
A common way to swap two registers is a <= b; b <= a; using nonblocking assignments. If this were instead written with blocking assignments (a = b; b = a;), starting with a=5, b=9, what would a and b hold after one clock edge, using each version?
Hint
For the nonblocking version, both right-hand sides are read using their pre-edge values before either write happens. For the blocking version, the first assignment's write is visible to the second statement immediately.
Solution
Nonblocking: a becomes 9, b becomes 5 — a genuine swap, since both right-hand sides (b=9 and a=5) are read using their original values before either write applies.
Blocking: a = b; executes first, so a becomes 9 immediately. b = a; then reads a's new value, so b also becomes 9 — not a swap at all, just both registers ending up equal to the original b. This is the exact same class of bug as the shift register example, applied to a swap instead of a pipeline.
Summary
In this tutorial, you learned:
- A simulation time step is divided into an ordered sequence of scheduling regions, not a single instant
- Preponed samples values for assertions; Active runs blocking code and evaluates (but doesn't yet apply) nonblocking right-hand sides; Inactive holds
#0delays; NBA applies nonblocking updates - NBA's deferred timing is what makes nonblocking assignments correctly model simultaneous hardware updates, avoiding the classic blocking-assignment pipeline bug
- Observed evaluates concurrent assertions; Reactive runs program blocks and assertion pass/fail actions; Postponed is where
$strobe/$monitorsee the fully settled value - The Active-Inactive-NBA cluster can loop within a single time step if new events keep landing back in Active
During reset, most signals are in an undefined or transitioning state — and if an assertion happens to be partway through a multi-cycle check exactly when reset asserts, it can report a failure that has nothing to do with a genuine protocol violation. disable iff exists specifically to prevent this.
11 min read | Intermediate Level
What You'll Learn
- What
disable iffdoes, and where it's placed within a property - Why gating a property's antecedent isn't enough to protect an already-in-progress check
- How
disable iffcan abort a check that already started before the disable condition became true - Why
disable iffis used almost exclusively for reset, rather than arbitrary conditions
Syntax
disable iff is placed right after the clocking event, before the rest of the property expression:
property p_name;
@(posedge clk) disable iff (condition) antecedent |-> consequent;
endproperty
assert property (p_name);
When condition becomes true at any point during the property's evaluation — not just at the moment a new attempt would start — that specific attempt is aborted immediately. It's neither counted as a pass nor a fail; it simply stops being evaluated.
Why Gating the Antecedent Isn't Enough
It might seem like ANDing the reset condition into the antecedent itself — !rst && req |-> ##2 gnt — would achieve the same protection. It doesn't, and the reason matters: that only controls whether a new attempt is allowed to start. It has no effect on a check that already started one or more cycles earlier and is still waiting to resolve. disable iff is different: it can reach back and abort an already in-flight check the moment its condition becomes true, regardless of how far into its own evaluation window that check already was.
A Concrete Example: Aborting a Check Mid-Flight
Take a simple property: whenever req is seen, gnt must follow exactly 2 cycles later.
// Without disable iff - vulnerable to a spurious failure if reset
// happens to occur while a check is already in progress
property p_no_disable;
@(posedge clk) req |-> ##2 gnt;
endproperty
assert property (p_no_disable);
Now suppose the following happens: req is high at cycle 1, starting a check that needs gnt to be high at cycle 3. But at cycle 2, reset asserts — and by cycle 3, gnt is low, as it typically would be during or right after a reset.
Without disable iff, the check that started at cycle 1 has no way to know reset happened partway through — it simply evaluates whether gnt is high at cycle 3, finds it isn't, and reports a failure. This is a spurious failure: nothing about the actual protocol was violated, reset just happened to land in the middle of an in-flight check.
Adding disable iff fixes this:
// With disable iff - the in-flight check from cycle 1 is safely
// aborted the moment rst goes high at cycle 2
property p_with_disable;
@(posedge clk) disable iff (rst) req |-> ##2 gnt;
endproperty
assert property (p_with_disable);
With this version, the moment rst goes high at cycle 2 — while the check started at cycle 1 is still waiting to resolve at cycle 3 — that check is aborted immediately. No pass, no fail. Whatever gnt happens to be doing at cycle 3 no longer matters, because the relevant attempt was already called off a cycle earlier.
Quick Check
Q: If reset instead asserted at cycle 3 (the exact cycle gnt is being checked), rather than cycle 2, would disable iff (rst) still prevent a spurious failure?
Show Answer
Yes. disable iff checks its condition continuously throughout the property's evaluation, not just at a fixed point — if rst becomes true at the exact cycle the consequent would otherwise be checked, the attempt is still aborted before that check can produce a false failure.
Where Is disable iff Used?
Almost every concurrent assertion in a real testbench includes disable iff (!rst_n) (or the active-high equivalent), tied to the design's own reset signal. It's rare to see a production assertion without one, since reset periods are exactly when signals are least reliable and most likely to produce a spurious failure if left unguarded.
Common Beginner Mistakes
Mistake #1: Gating the antecedent instead of using disable iff
As explained above, !rst && req |-> ... only prevents new attempts from starting — it does nothing for a check already in progress when reset asserts. Why? This gap is exactly what produces spurious failures during reset if disable iff isn't used instead.
Mistake #2: Forgetting disable iff entirely
As the worked example shows, an assertion with no reset handling at all can report a completely misleading failure the moment reset happens to interrupt an in-flight check. Why? A spurious, reset-induced failure wastes debug time chasing something that was never a real bug — almost every real assertion needs this protection.
Mistake #3: Placing disable iff in the wrong position
disable iff belongs right after the clocking event and before the rest of the property expression — not anywhere else in the property. Why? This ordering is part of the required property syntax; placing it elsewhere is a syntax error, not just a style preference.
Mistake #4: Using disable iff for something other than reset
While technically legal to use with any condition, disable iff is used almost exclusively for reset in practice. Why? Its whole purpose is suppressing checks during a period when the design's own signals are known to be unreliable — using it to silence an assertion under some other arbitrary condition usually signals the property itself needs rethinking, not that disable iff is the right tool.
Practice Exercise
Challenge: Add disable iff to a Data-Stability Check
Write a property that checks: whenever valid is high and ready is low, data must stay stable (unchanged) on the following cycle. Include disable iff tied to an active-low reset signal rst_n.
Hint
Use $stable(data) as the consequent, and remember disable iff goes right after the clocking event, before the rest of the property.
Solution
property p_data_stable;
@(posedge clk) disable iff (!rst_n)
(valid && !ready) |=> $stable(data);
endproperty
assert property (p_data_stable);
Without disable iff (!rst_n), a reset happening to occur right as data is being checked for stability could easily produce a spurious failure — reset typically forces data to a known value, which would look exactly like an unexpected change to $stable() if the check weren't safely aborted first.
Summary
In this tutorial, you learned:
disable iff (condition)aborts a property's evaluation the moment its condition becomes true, reporting neither a pass nor a fail- It's placed immediately after the clocking event, before the rest of the property expression
- Gating the antecedent alone only prevents new attempts from starting — it can't abort a check already in progress, which is exactly what
disable iffcan do - Its condition is checked continuously throughout a property's evaluation, not just once at the start
disable iffis used almost universally for reset, since that's when a design's signals are least trustworthy
A common assumption about #0 is that it means "let everything else scheduled for this time step finish first, then run this." That's not quite what it does — and the gap between that assumption and what actually happens is a genuine, well-documented gotcha, directly explained by the region order established in SystemVerilog Scheduling Semantics.
11 min read | Intermediate Level
What You'll Learn
- Which region
#0actually defers execution to, and why that's earlier than many people expect - Why a
#0-delayed read can still see a stale value relative to a nonblocking assignment scheduled in the same time step - How to correctly wait for a signal's fully settled value instead
- Why
#0is generally discouraged as a quick fix for a timing problem
What #0 Actually Does
A statement delayed by #0 is deferred from Active into the Inactive region — one step later in that same time step, not pushed out to some point after everything has settled. Critically, Inactive still runs before NBA. Anything relying on a nonblocking assignment's update to have already happened isn't safe inside a #0-delayed statement, because that update genuinely hasn't happened yet.
The Gotcha: #0 Still Runs Before NBA
Here are four different ways of reading the same signal, all triggered by the same clock edge, right after a nonblocking assignment updates it:
module tb;
reg clk = 0;
reg [7:0] a;
always #10 clk = ~clk;
initial a = 0;
// Updates a - the actual write is deferred to NBA
always @ (posedge clk) begin
a <= 5;
end
// Reads immediately, in Active
always @ (posedge clk) begin
$display ("[%0t] immediate read (Active): a=%0d", $time, a);
end
// Reads after a #0 delay, in Inactive - still before NBA!
always @ (posedge clk) begin
#0;
$display ("[%0t] #0-delayed read (Inactive): a=%0d", $time, a);
end
// Reads via $strobe, deferred to Postponed - after NBA has settled
always @ (posedge clk) begin
$strobe ("[%0t] strobe read (Postponed): a=%0d", $time, a);
end
initial begin
#100 $finish;
end
endmodule
At the very first posedge, with a starting at 0: the immediate read executes in Active, before the nonblocking assignment's write has applied, and sees a=0. The #0-delayed read executes next, in Inactive — still before NBA — and also sees a=0, exactly the same stale value, despite having been deliberately delayed. Only the $strobe read, deferred all the way to Postponed, correctly reports a=5 once NBA has actually applied the update.
Quick Check
Q: If the #0-delayed block were changed to #1 instead of #0, would it then see the updated value?
Show Answer
Yes, but for a completely different reason: #1 is a nonzero delay, which advances simulation to an entirely new time step — 1 time unit after the clock edge in this example, not just a later region within the same time step. By then, that edge's NBA update has already applied. This isn't the same mechanism as #0 at all.
Correctly Waiting for a Settled Value
As the example shows, the reliable way to read a value after all of a time step's updates have applied is $strobe or $monitor — both execute in Postponed, guaranteed to run after every other region, including NBA, has finished. Waiting for the following clock edge works too, since by then the previous edge's NBA updates have definitely settled. #0 accomplishes neither of these.
Where Does This Matter in Practice?
#0 is sometimes used deliberately for narrow, specific purposes — like controlling relative ordering between multiple Active-region events within the same time step. It should not be reached for as a general-purpose fix for a suspected race condition, since it doesn't resolve the specific class of race that involves a nonblocking assignment — exactly the case demonstrated in this article.
Common Beginner Mistakes
Mistake #1: Assuming #0 waits for nonblocking updates to settle
As this article's example shows, it doesn't — #0 only defers past Active into Inactive, which still runs before NBA. Why? A signal updated by a nonblocking assignment in the same time step is still not yet updated when a #0-delayed statement runs, no matter how intuitive it might seem that the delay should have let it settle.
Mistake #2: Reaching for #0 as a generic race-condition fix
#0 can resolve some ordering questions within Active, but not the specific, very common case of racing against a nonblocking assignment. Why? Using it without understanding exactly which region it lands in risks "fixing" the symptom on one simulator while leaving the underlying issue intact, or fully unresolved, on another.
Mistake #3: Confusing #0 with a nonzero delay like #1
These are fundamentally different mechanisms, as the Quick Check above shows. Why? #0 stays within the same time step, just in a later region; any nonzero delay advances to a genuinely new, later time step entirely — conflating the two leads to incorrect assumptions about what each one actually guarantees.
Mistake #4: Using $display instead of $strobe when a settled value is needed
As this article's example shows, a plain $display in Active can show exactly the same stale value a #0-delayed read would. Why? If a check specifically needs the fully settled value for a time step, $strobe or $monitor is the tool built for that — neither $display nor #0 provides that guarantee.
Practice Exercise
Challenge: Trace a Different Starting Value
Using the same four-block structure from this article, but with a starting at 10 and the nonblocking assignment changed to a <= a + 1;, predict what each of the four reads would show at the first clock edge.
Hint
Work out which value each read is comparing against — the pre-edge value of a, or the value after the nonblocking assignment has actually applied — using the same region ordering traced in the article.
Solution
The immediate (Active) read and the #0-delayed (Inactive) read both show a=10 — the pre-edge value, since neither runs after NBA. The $strobe (Postponed) read shows a=11, correctly reflecting a <= a + 1 once NBA has applied it. Same pattern as the article's own example, just with different numbers.
Summary
In this tutorial, you learned:
#0defers a statement from Active into Inactive — a later region within the same time step, but still strictly before NBA- A
#0-delayed read can see exactly the same stale value an immediate read would, if it's racing against a nonblocking assignment in the same time step $strobeand$monitor, running in Postponed, are the reliable way to see a time step's fully settled value#0is a same-time-step mechanism, fundamentally different from any nonzero delay, which advances to a genuinely new time step#0should not be treated as a general-purpose fix for a suspected race — it doesn't resolve races involving nonblocking assignments
A covergroup's raw bin hits are only half the story. Coverage options control how that raw hit data actually turns into a reported percentage — how many hits a bin needs before it counts as covered, what target counts as "done," and how much one covergroup's score should count when it's combined with others into a single project-wide number.
13 min read | Intermediate Level
What You'll Learn
- The difference in scope between
optionandtype_option - How
at_leastchanges exactly how many hits a bin needs before it counts as covered - How
goalsets the coverage a covergroup must reach to count as complete, without changing the percentage it reports - How
weightcontrols how much a covergroup contributes when combined into an aggregate coverage score - What
auto_bin_max,per_instance, andcommenteach control
option vs type_option
Both are set the same way — option.name = value; or type_option.name = value; inside a covergroup — but they apply to different things. option controls settings for one specific covergroup instance (or acts as that instance's own default). type_option controls settings for the covergroup type as a whole, shared identically across every instance of it, and can't be overridden per instance.
at_least: How Many Hits Count as Covered
By default, a single hit is enough for a bin to count as covered. at_least raises that threshold:
covergroup cg @(posedge clk);
cp_addr: coverpoint addr {
option.at_least = 3; // a bin needs 3 hits before it counts as covered
bins low = {[0:63]};
bins high = {[64:127]};
}
endgroup
If addr falls in the low range only twice during a test, that bin is not counted as covered yet — at_least requires 3 hits, and only 2 have happened. It takes a third hit before the bin flips to covered and starts contributing to the reported percentage.
Quick Check
Q: With option.at_least = 3, if low is hit exactly 3 times and high is hit exactly once, what does the coverpoint's own coverage percentage show?
Show Answer
50%. low meets the 3-hit threshold and counts as covered; high has only 1 hit, below the threshold, so it doesn't count yet — one out of two bins covered.
goal: A More Achievable Target
goal sets the target percentage a covergroup has to reach to be considered complete. It does not change how the coverage number itself is calculated:
covergroup cg @(posedge clk);
option.goal = 80; // target: complete once 80% of bins are hit
cp_mode: coverpoint mode {
bins b[] = {0, 1, 2, 3, 4, 5, 6, 7, 8, 9}; // 10 explicit bins
}
endgroup
If 8 of the 10 mode bins are hit, this covergroup reports 80% coverage, the same number it would report with no goal at all. What the goal changes is the verdict: coverage tools and reports compare the 80% against the goal and mark the covergroup as having met its target.
The other 2 bins are still unhit. The goal only means that reaching them isn't required for this covergroup to count as complete.
Quick Check
Q: With option.goal = 80 and only 7 of the 10 bins hit, what is the reported coverage, and has the goal been met?
Show Answer
70%, and no. The reported coverage is always the share of bins hit, 7/10 = 70%, and that is below the 80% target. Once an eighth bin is hit, coverage reads 80% and the goal counts as met; goal never changes the percentage itself.
weight: Contribution to a Combined Score
When several covergroups are combined into one overall project coverage number, weight controls how much each one counts in that combination — a plain average by default, or a weighted one if set:
covergroup cg1 @(posedge clk);
option.weight = 5; // counts 5x as much in a combined score
...
endgroup
covergroup cg2 @(posedge clk);
option.weight = 1; // default weight
...
endgroup
If cg1 is at 100% and cg2 is at 0%, a plain average would report 50% combined. With cg1 weighted 5 times as heavily as cg2, the combined score instead becomes (5×100 + 1×0) / (5+1) = 83.3% — cg1's score dominates the combined result, in proportion to its weight.
Quick Check
Q: Does changing cg1's weight affect cg1's own reported coverage percentage?
Show Answer
No. weight only affects how cg1's score is combined with other covergroups into an aggregate — cg1's own individual percentage is still calculated exactly the same way, based only on its own bins.
auto_bin_max, per_instance, and comment
Three more commonly-used options, each simpler than the ones above:
option.auto_bin_max = N;— caps how many bins are automatically created for a coverpoint that doesn't explicitly define its own bins. The default is 64; a coverpoint covering a wide value range without explicit bins gets split into up to this many automatically-sized bins.option.per_instance = 1;— by default, coverage from multiple instances of the same covergroup (for example, one inside a class that gets constructed many times) is combined into a single aggregate result. Setting this reports each instance's own coverage separately instead, which matters when it's important to know whether every individual instance was exercised, not just the group as a whole.option.comment = "...";— a plain documentation string attached to the coverage report, with no effect on the calculated percentage at all.
Where Are These Used?
goal is commonly set below 100 for bins that are legitimately difficult or impractical to hit in every regression configuration, giving sign-off a realistic target instead of blocking indefinitely on a handful of edge cases. weight is used to make coverage of a critical protocol area count more heavily than a lower-priority debug-only coverpoint when reporting one combined number. per_instance is essential whenever a design instantiates the same IP block multiple times and it matters whether each instance was actually exercised, not just the group collectively.
Common Beginner Mistakes
Mistake #1: Assuming a single hit always counts as covered
That's only true at the default at_least = 1. Why? Once at_least is raised, a bin can be hit and still not count toward coverage until it reaches the required number of hits — worth checking before assuming a coverage report is wrong.
Mistake #2: Assuming a met goal means every bin was hit
Not if goal is set below 100. Why? A covergroup that meets an 80% goal can still have one bin in five unhit. Check the coverage number and the list of unhit bins, not only the goal status. The two mean the same thing only when goal is left at its default of 100.
Mistake #3: Expecting weight to change a covergroup's own percentage
As the third Quick Check shows, it doesn't — weight only matters once that covergroup's score is being combined with others. Why? A covergroup's own individual report is always based purely on its own bins, regardless of what weight it's been given for aggregation purposes.
Mistake #4: Confusing option with type_option
Setting option.goal affects one specific instance's default; setting type_option.goal affects every instance of that covergroup type uniformly. Why? Using the wrong one means a setting meant to apply everywhere only ends up affecting a single instance, or vice versa.
Practice Exercise
Challenge: Compute a Combined Score
Covergroup cg_a is at 60% coverage with option.weight = 3. Covergroup cg_b is at 100% coverage with the default weight. What is their combined coverage score?
Hint
Use the same weighted-average formula from this article's main weight example — multiply each covergroup's percentage by its own weight, sum those, then divide by the total weight.
Solution
70%. (3×60 + 1×100) / (3+1) = (180 + 100) / 4 = 280 / 4 = 70. cg_a's lower score still pulls the combined result down, but its heavier weight (3) means it pulls harder than cg_b's default weight of 1 would otherwise allow.
Summary
In this tutorial, you learned:
optionapplies to one covergroup instance (or its own default);type_optionapplies uniformly to every instance of that covergroup typeat_leastsets how many hits a bin needs before it counts as covered, rather than the default of just onegoalsets the percentage a covergroup must reach to count as complete; the reported coverage is still the actual share of bins hitweightcontrols how much a covergroup's score counts when combined with others into an aggregate number, without changing that covergroup's own reported percentageauto_bin_max,per_instance, andcommentcontrol automatic bin count limits, per-instance reporting, and report documentation, respectively
Quiz
No quiz questions available for this article.