Module 1: Reusable Stimulus | Intermediate UVM

Scenario Synchronization

Learn how to synchronize complex UVM scenarios using explicit events, sequence completion, DUT responses, objections, and meaningful protocol milestones instead of fragile timing assumptions.

Learning objectives

  • Explain why synchronization is necessary in multi-sequence UVM scenarios.
  • Distinguish sequence completion from DUT operation completion.
  • Synchronize stimulus using sequence completion and explicit SystemVerilog events.
  • Recognize when a synchronization point should be based on DUT behavior.
  • Use fork...join, join_any, and join_none correctly in coordinated scenarios.
  • Understand common synchronization hazards such as races, missed events, and deadlocks.
  • Design synchronization points that remain reusable and independent of low-level driver implementation.
  • Validate that the intended scenario ordering actually occurred.

Step 1: Understand the concept

In the previous lesson, we learned how to run multiple sequences concurrently. Concurrency creates overlapping activity, but it does not automatically tell the sequences when they are allowed to proceed.

That responsibility belongs to synchronization.

Consider a typical system-level scenario:

Configure DUT
 |
 v


Configuration complete
|
+-------------------+
|                   |
v                   v
Start DMA          Start background traffic
|                   |
|                   |
+---------+---------+
|
v
DMA complete
|
v
Stop background
|
v
Check result

Some operations must happen in order. Others may happen concurrently. Synchronization defines the boundaries between these phases.

Core idea: Synchronization is not about making simulation "wait." It is about expressing the conditions under which one part of the scenario is allowed to continue.

Step 2: Why arbitrary delays are fragile

A common first attempt is to synchronize sequences with fixed delays:

config_seq.start(p_sequencer.cfg_seqr);


#100ns;

data_seq.start(p_sequencer.data_seqr);

This assumes that configuration will always complete within 100 ns.

That assumption can become invalid when:

  • the clock frequency changes,
  • the DUT latency changes,
  • bus arbitration introduces additional wait states,
  • the driver implementation changes,
  • randomized traffic increases contention, or
  • the test is reused on another configuration.

The better question is not:

"How long should I wait?"

It is:

"What event proves that I can safely continue?"

Verification principle: Prefer synchronization based on meaningful completion conditions over arbitrary simulation time.

Step 3: First synchronization mechanism — sequence completion

The simplest synchronization mechanism is the return of sequence.start().

config_seq.start(p_sequencer.cfg_seqr);


data_seq.start(p_sequencer.data_seqr);

The second sequence does not start until the first sequence's start() call returns.

This is useful when the sequence itself represents the required operation.

For example:

reset_seq.start(p_sequencer.reset_seqr);


configuration_seq.start(p_sequencer.cfg_seqr);
traffic_seq.start(p_sequencer.data_seqr);

Here the scenario is naturally sequential:

Reset


|
v
Configuration
|
v
Traffic

However, there is an important limitation.

Step 4: Sequence completion is not always DUT completion

This distinction is critical in intermediate UVM verification.

A sequence can finish generating bus transactions before the DUT has completed the operation requested by those transactions.

Sequence


|
|  write START register
v
Driver
|
v
DUT begins operation
|
|........ processing ........|
|                            |
v                            v
sequence ends              DUT completes

Therefore:

seq.start(seqr);

does not automatically mean:

"The DUT has completed the requested operation."

If the next stimulus depends on DUT completion, synchronize on a DUT-visible completion condition.

Step 5: Identify the correct synchronization point

Before writing synchronization code, identify the milestone that matters to the scenario.

Requirement Possible synchronization point
Reset transaction has been generated Sequence completion
Register programming completed Configuration sequence completion or protocol response
DUT accepted a command Observed handshake/response
DMA transfer completed Completion response, interrupt, or monitored transaction
Interrupt occurred Observed interrupt event
All parallel traffic finished fork...join
First of several conditions occurred join_any or explicit event logic

The synchronization mechanism should match the verification requirement.

Step 6: Synchronizing concurrent sequences with fork...join

Suppose two independent sequences must complete before the next phase begins:

fork
dma_seq.start(p_sequencer.dma_seqr);
memory_seq.start(p_sequencer.mem_seqr);


join

check_seq.start(p_sequencer.ctrl_seqr);

The timeline is:

DMA:       ======================>


Memory:    ================>
|
v
CHECK

The join acts as a barrier. The parent sequence continues only after both child processes finish.

This pattern is useful when the next phase depends on completion of the entire concurrent phase.

Step 7: Synchronizing with join_any

Sometimes a scenario should continue after the first of several conditions.

fork
wait_for_interrupt();
wait_for_timeout();


join_any

report_result();

The parent continues as soon as one process finishes.

But the remaining process does not automatically disappear.

This means the design must answer:

  • Should the remaining process continue?
  • Should it be terminated?
  • Could it affect later phases?
  • Could it access shared state after the scenario has moved on?
Important: join_any is a synchronization decision and a process-lifetime decision. Treat both aspects explicitly.

Step 8: Synchronizing with explicit events

SystemVerilog events can be useful when one process needs to notify another process that a scenario milestone has occurred.

event cfg_done;


fork
begin
cfg_seq.start(p_sequencer.cfg_seqr);
-> cfg_done;
end


begin
    @cfg_done;
    data_seq.start(p_sequencer.data_seqr);
end


join

The first process performs configuration and triggers the event. The second process waits for that event before starting data traffic.

Configuration
  |
  v


cfg_done
|
v
Data traffic

This is much more expressive than:

#100ns;

Step 9: Understand the danger of missed synchronization

Synchronization mechanisms must also be designed with process ordering in mind.

Consider an event that is triggered before another process begins waiting for it. Depending on the synchronization mechanism and implementation, the waiting process may not observe the intended notification.

The general lesson is:

Do not treat synchronization as a magic signal. Understand who creates the synchronization condition, who consumes it, and when each process becomes active.

For robust environments, consider whether an event, a persistent state condition, a monitored transaction, or a UVM synchronization primitive best represents the requirement.

Step 10: Synchronize on DUT behavior

System-level scenarios often need to wait for something the DUT actually did.

For example:

Configure DMA
  |
  v


Start transfer
|
v
Wait for DMA completion
|
v
Read destination data

A robust test should synchronize on the completion indication rather than on an estimated delay.

Conceptually:

start_dma_seq();


wait_for_dma_complete();

read_destination_seq();

The implementation of wait_for_dma_complete() may be based on an observed interrupt, a response transaction, a status indication, or another meaningful DUT event.

Step 11: Keep synchronization out of the wrong layer

A reusable verification environment has clear responsibilities.

Layer Primary responsibility
Test Selects the scenario and high-level intent
Virtual sequence Coordinates scenario-level activity
Protocol sequence Generates reusable protocol transactions
Driver Converts transactions into pin/interface activity
Monitor Observes interface activity
Scoreboard Checks expected versus actual behavior

Scenario synchronization normally belongs at the scenario coordination layer. Avoid forcing a virtual sequence to know low-level driver implementation details.

Step 12: A realistic multi-agent example

Imagine a DUT with:

  • control-bus agent,
  • DMA agent,
  • memory agent, and
  • interrupt monitoring.

The required scenario is:

  1. Configure the DUT.
  2. Wait until configuration is accepted.
  3. Start background memory traffic.
  4. Start DMA traffic.
  5. Wait for DMA completion.
  6. Stop background traffic.
  7. Check the transferred data.

A virtual sequence might express the high-level intent as:

task body();

configure_seq.start(p_sequencer.ctrl_seqr);

fork
    background_mem_seq.start(p_sequencer.mem_seqr);
    dma_seq.start(p_sequencer.dma_seqr);
join_any

wait_for_dma_complete();

stop_background_memory();

check_data_seq.start(p_sequencer.ctrl_seqr);


endtask

The exact implementation depends on the environment, but the important point is the separation of responsibilities:

Virtual sequence
   |
   +---- configuration
   |
   +---- concurrent stimulus
   |
   +---- synchronization
   |
   +---- completion
   |
   +---- checking


Protocol sequences
|
+---- bus-specific transactions

Agents
|
+---- protocol implementation

Step 13: Sequence synchronization versus DUT synchronization

These two ideas are related but not identical.

Sequence synchronization

One sequence waits for another sequence to finish.

seq_a.start(seqr_a);


seq_b.start(seqr_b);

DUT synchronization

A sequence waits for an observable DUT condition.

start_operation();


wait_for_completion();
continue_operation();

The second is often the more meaningful synchronization point for system-level verification because it is tied to actual DUT behavior.

Step 14: Avoid synchronization through implementation details

Consider this fragile design:

wait(driver.internal_counter == 8);

The virtual sequence now depends on an internal driver implementation detail. If the driver is refactored, the scenario may break even though the protocol behavior has not changed.

Prefer a semantic synchronization point:

wait_for_transfer_complete();

The abstraction is important. The scenario should care that the transfer is complete, not how the driver internally counts its transactions.

Reuse rule: Synchronize on semantic verification events, not private implementation state, whenever practical.

Step 15: Recognize deadlocks

Poor synchronization can create a deadlock: every process is waiting for another process to make progress.

Sequence A


|
v
wait for B

Sequence B
|
v
wait for A

Neither sequence can proceed.

When debugging a stalled test, ask:

  1. What process is currently waiting?
  2. What condition is it waiting for?
  3. Which process is responsible for producing that condition?
  4. Can that process actually execute?
  5. Could the condition have occurred before the waiter became active?
  6. Is the synchronization condition dependent on another blocked process?

Step 16: Recognize race conditions

A race occurs when the correctness of the scenario depends on which concurrent process happens to execute first.

For example:

fork
set_mode(1);
send_data();


join

If send_data() depends on set_mode(1), these operations should not be launched as independent concurrent activities.

Express the dependency explicitly:

set_mode(1);


fork
send_data();
background_traffic();
join

The principle is simple: only independent operations should be concurrent.

Step 17: Synchronization and reset

Reset is one of the most important synchronization boundaries in a verification environment.

A typical scenario may require:

Reset asserted
  |
  v


Reset released
|
v
DUT initialized
|
v
Configuration
|
v
Normal traffic

Do not assume that reset release automatically means the DUT is ready. Some designs require additional initialization or status confirmation.

Therefore, distinguish between:

  • reset signal transition,
  • reset sequence completion,
  • DUT initialization completion, and
  • functional readiness.

Step 18: Synchronization and objections

UVM objections control phase lifetime; they are not a replacement for synchronization between sequences.

Conceptually:

raise_objection()
    |
    v


Run scenario
|
+---- synchronize sequences
|
+---- wait for DUT completion
|
v
drop_objection()

The objection answers: "Should the UVM phase be allowed to finish?"

Synchronization answers: "When may this part of the scenario continue?"

Do not mix the concepts: A phase objection can keep simulation alive, but it does not tell one sequence when another sequence has completed.

Step 19: A practical synchronization checklist

  1. Identify the dependency. What must happen before the next action?
  2. Identify the evidence. What observable condition proves that the dependency is satisfied?
  3. Choose the synchronization mechanism. Sequence completion, event, response, monitor notification, or another appropriate mechanism.
  4. Check process lifetime. What happens to concurrent processes after synchronization?
  5. Check for races. Could two operations access dependent state concurrently?
  6. Check for deadlocks. Can every wait condition eventually be satisfied?
  7. Check reuse. Does the synchronization depend on low-level implementation details?
  8. Check observability. Can the testbench prove that the intended synchronization actually occurred?

Step 20: Debugging a stalled scenario

When a synchronized test stops making progress, do not immediately add another delay.

Instead, construct a wait-for graph:

Scenario


|
+---- waiting for config_done
|
v
Config sequence
|
+---- waiting for response
|
v
DUT

Trace the dependency until you find the process that should produce the next observable event.

Useful debug evidence includes:

  • sequence start and completion messages,
  • transaction monitor output,
  • protocol handshakes,
  • interrupt activity,
  • assertion failures,
  • simulation timestamps,
  • phase and objection state.

Step 21: Build synchronization incrementally

  1. Start with one sequence and verify that it completes correctly.
  2. Add the second sequence sequentially and confirm both behaviors.
  3. Identify the exact point where concurrency is required.
  4. Introduce fork...join or another appropriate mechanism.
  5. Add explicit synchronization only where a real dependency exists.
  6. Add DUT-based completion conditions.
  7. Add background traffic and controlled termination.
  8. Verify the final scenario with monitor, scoreboard, assertion, and coverage evidence.

This incremental approach makes synchronization bugs much easier to isolate.

Step 22: Expert mental model

             SYSTEM REQUIREMENT
                 |
                 v
         Scenario dependency
                 |
      +----------+----------+
      |                     |
      v                     v
 Can overlap?          Must wait?
      |                     |
      v                     v
 Concurrent             Synchronize
 activity                  |
      |                    |
      +----------+---------+
                 |
                 v
         Observable milestone
                 |
                 v
          Next scenario phase
                 |
                 v
        Verification evidence

The strongest synchronization design starts with the verification requirement and works downward toward the implementation.

Do not start with fork, event, or a delay and then try to invent a reason for using it.

Try it yourself

Design a virtual sequence for a DUT containing a control bus, DMA interface, memory interface, and interrupt output.

The required scenario is:

  1. Apply reset.
  2. Wait until the DUT is functionally ready.
  3. Configure the DMA engine.
  4. Start background memory traffic.
  5. Start a DMA transfer.
  6. Allow DMA and memory activity to overlap.
  7. Wait for the actual DMA completion indication.
  8. Stop background memory traffic.
  9. Read and verify the destination data.

Before writing the code, answer these questions:

  1. Which steps are sequential?
  2. Which steps are concurrent?
  3. What proves that reset initialization is complete?
  4. What proves that DMA configuration is complete?
  5. Should DMA completion be detected through sequence completion or DUT behavior?
  6. Which fork/join construct is appropriate for the concurrent phase?
  7. How will background traffic be stopped?
  8. What could cause a deadlock?
  9. What could cause a race?
  10. What monitor, scoreboard, assertion, or coverage evidence proves the scenario behaved correctly?
Challenge: Do not use a fixed #delay for any synchronization point unless the requirement itself is explicitly time-based. Every other wait should have a meaningful reason.

Verification checkpoint

You have mastered this lesson when you can inspect a complex scenario and identify every synchronization boundary before implementing it.

  • What starts the phase?
  • What activities may overlap?
  • What activities must wait?
  • What observable condition releases each wait?
  • What processes remain alive afterward?
  • How does each background process terminate?
  • How will the testbench prove that the intended ordering occurred?
Expert check: A synchronization design is complete only when you can explain not just when a process waits, but also what condition releases it, who produces that condition, and what happens afterward.

Key takeaways

  • Synchronization defines when a scenario is allowed to move from one phase to another.
  • Prefer meaningful behavioral conditions over arbitrary simulation delays.
  • Sequence completion and DUT completion are not necessarily the same event.
  • Use fork...join, join_any, and join_none according to the required process and synchronization semantics.
  • Explicit events can coordinate independent processes, but their lifetime and ordering must be understood carefully.
  • Synchronize on semantic events rather than private driver implementation details.
  • Good synchronization prevents both race conditions and deadlocks.
  • UVM objections control phase lifetime; they do not replace sequence synchronization.
  • Background activity requires an explicit termination strategy.
  • Synchronization should be observable through monitor activity, protocol responses, assertions, scoreboard results, or coverage.
  • The virtual sequence should express scenario intent while keeping protocol implementation details inside reusable protocol sequences and agents.