Module 1: Reusable Stimulus | Intermediate UVM

Concurrent Sequences

Learn how to run UVM sequences concurrently, control their lifetime, synchronize dependent activity, and avoid race conditions in realistic multi-interface scenarios.

Learning objectives

  • Explain why concurrent sequences are useful in system-level verification.
  • Distinguish concurrency from simple sequential sequence execution.
  • Use SystemVerilog fork...join constructs to run sequences concurrently.
  • Choose appropriately between join, join_any, and join_none.
  • Identify race conditions and unintended ordering in concurrent stimulus.
  • Synchronize concurrent sequences using explicit events or meaningful DUT behavior.
  • Control the lifetime and termination of background sequences.
  • Validate concurrent stimulus using monitors, scoreboards, assertions, and coverage.

Step 1: Understand the concept

A real SoC rarely performs one operation at a time. While a CPU accesses registers, a DMA engine may move data, a peripheral may generate interrupts, and memory traffic may continue in the background.

If the verification environment always drives these activities sequentially, it may never exercise the interactions that occur when the interfaces operate at the same time.

Concurrent sequences allow independent stimulus activities to overlap in simulation.

                    Virtual Sequence
                       |
         +-------------+-------------+
         |             |             |
         v             v             v
    Control Seq    DMA Seq      Memory Seq
         |             |             |
         v             v             v
    Control Agent   DMA Agent   Memory Agent
         |             |             |
         +-------------+-------------+
                       |
                      DUT

The goal is not simply to "run more sequences." The goal is to model the concurrency that matters to the design and to preserve every dependency that actually exists.

Core idea: Concurrency should represent real system behavior, not merely make the testbench more complicated.

Step 2: Sequential versus concurrent execution

Consider two sequences:

ctrl_seq


dma_seq

Sequential execution is straightforward:

ctrl_seq.start(p_sequencer.ctrl_seqr);


dma_seq.start(p_sequencer.dma_seqr);

The second start() call is reached after the first sequence has returned.

Concurrent execution creates overlapping activity:

fork
ctrl_seq.start(p_sequencer.ctrl_seqr);
dma_seq.start(p_sequencer.dma_seqr);


join

Conceptually:

Sequential:


CTRL  ====================>
DMA                        ====================>

Concurrent:

CTRL  ====================>
DMA       ====================>

This distinction is fundamental. A concurrent sequence does not necessarily mean that the two transactions occur on the same simulation timestep. It means that the processes are allowed to execute independently and their activities may overlap.

Step 3: Concurrency does not mean "no ordering"

A common beginner mistake is to think that concurrent sequences should have no ordering constraints.

Real systems contain both:

  • independent operations,
  • dependent operations,
  • operations that may overlap after a prerequisite, and
  • operations that must finish before another phase begins.

For example:

Configure


|
v
Configuration complete
|
+--------------------+
|                    |
v                    v
DMA traffic        Memory traffic
|                    |
+---------+----------+
|
v
Scenario complete

Configuration has a dependency. DMA and memory traffic may then execute concurrently.

Good concurrent stimulus therefore combines ordering and parallelism.

Step 4: The basic concurrent sequence

A virtual sequence can start independent child sequences using fork...join.

class system_vseq extends uvm_sequence;

`uvm_object_utils(system_vseq)
`uvm_declare_p_sequencer(system_virtual_sequencer)

task body();

    ctrl_seq = ctrl_sequence::type_id::create("ctrl_seq");
    dma_seq  = dma_sequence::type_id::create("dma_seq");

    fork
        ctrl_seq.start(p_sequencer.ctrl_seqr);
        dma_seq.start(p_sequencer.dma_seqr);
    join

endtask


endclass

The virtual sequence owns the scenario-level coordination, while each child sequence remains responsible for its own protocol.

Design rule: The virtual sequence should coordinate what happens when; it should not reimplement the protocol behavior of the individual agents.

Step 5: Understand join

fork...join waits until all spawned processes finish.

fork
seq_a.start(seqr_a);
seq_b.start(seqr_b);
seq_c.start(seqr_c);


join

// Execution continues here only after A, B, and C finish.

This is useful when the next phase of the test depends on all concurrent activities completing.

Phase 1


|
+---- A -------->
|
+---- B ------------>
|
+---- C ------>


         |
         v
    all complete
         |
         v
      Phase 2

A useful mental model is: join creates a synchronization barrier.

Step 6: Understand join_any

Sometimes the scenario should continue when the first concurrent activity completes.

fork
wait_for_response_a();
wait_for_response_b();


join_any

// Continue after either A or B completes.

This can be useful for scenarios such as:

  • waiting for the first of several possible responses,
  • modeling alternative completion paths,
  • implementing timeout or race-style behavior.

However, join_any does not automatically terminate the remaining processes.

Important: After join_any returns, other forked processes may still be running. You must decide whether they should continue or be terminated.

Step 7: Understand join_none

join_none launches processes without waiting for them to finish.

fork
background_seq.start(p_sequencer.mem_seqr);


join_none

main_seq.start(p_sequencer.ctrl_seqr);

This pattern is useful for background traffic such as:

  • background memory accesses,
  • idle or low-priority traffic,
  • continuous peripheral activity,
  • noise traffic used to stress arbitration.

But join_none creates a process-lifetime problem: who stops the background sequence?

A robust testbench must answer that question explicitly.

Step 8: Compare the three synchronization choices

Construct When the parent continues Typical use
join After all child processes finish Parallel phase with a completion barrier
join_any After the first child process finishes First-response or alternative completion
join_none Without waiting for the child processes Background activity

Choosing the construct should be driven by the scenario's synchronization requirements, not by preference.

Step 9: Synchronize concurrent sequences explicitly

Suppose a DMA sequence and a memory sequence may execute concurrently, but DMA must not start until configuration completes.

One approach is an explicit event:

event cfg_done;


task body();


fork

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

    begin
        @cfg_done;
        dma_seq.start(p_sequencer.dma_seqr);
    end

    begin
        @cfg_done;
        mem_seq.start(p_sequencer.mem_seqr);
    end

join


endtask

The resulting behavior is:

Configuration
  |
  v


cfg_done
/     
v       v
DMA     Memory
|       |
+---+---+
|
v
complete

This is more precise than inserting an arbitrary delay.

Step 10: Do not use delays to hide synchronization problems

Consider:

cfg_seq.start(p_sequencer.ctrl_seqr);


#100ns;

dma_seq.start(p_sequencer.dma_seqr);

The delay may appear to work in one simulation configuration but fail when:

  • the clock frequency changes,
  • the DUT latency changes,
  • the driver implementation changes,
  • additional traffic is introduced,
  • simulation scheduling changes the observed timing.

Prefer synchronization based on actual behavior:

wait_for_cfg_complete();


dma_seq.start(p_sequencer.dma_seqr);
Rule of thumb: If the requirement is "wait until X happens," synchronize on X rather than "wait approximately N nanoseconds."

Step 11: Understand race conditions

Concurrent processes can access shared variables or resources at overlapping times. This can create race conditions.

For example:

int count;


fork
count++;
count++;
join

Shared state becomes especially dangerous when multiple sequences communicate through common variables, configuration objects, or synchronization mechanisms.

In UVM, prefer clear ownership:

  • the virtual sequence owns scenario coordination,
  • individual sequences own their local stimulus generation,
  • agents own protocol-specific activity,
  • monitors observe rather than control the DUT,
  • scoreboards determine expected-versus-actual correctness.

Minimize shared mutable state whenever possible.

Step 12: A more realistic concurrent scenario

Consider a DMA-based system:

  1. Configure DMA through a control bus.
  2. Start background memory traffic.
  3. Start a DMA transfer.
  4. Allow the two traffic sources to overlap.
  5. Wait for DMA completion.
  6. Stop the background traffic.
  7. Check the resulting data.

The dependency graph is:

              Configure
              |
              v
         Config done
              |
      +-------+-------+
      |               |
      v               v
 Memory traffic    DMA transfer
      |               |
      |               v
      |          DMA complete
      |               |
      +-------+-------+
              |
              v
      Stop background
              |
              v
        Check result

Notice that this is not completely sequential and not completely parallel. It is a mixture of both.

Step 13: Implement the scenario

task body();

configure_dma_seq cfg_seq;
dma_transfer_seq dma_seq;
memory_background_seq mem_seq;

cfg_seq =
    configure_dma_seq::type_id::create("cfg_seq");

dma_seq =
    dma_transfer_seq::type_id::create("dma_seq");

mem_seq =
    memory_background_seq::type_id::create("mem_seq");

// Required prerequisite.
cfg_seq.start(p_sequencer.ctrl_seqr);

// Concurrent phase.
fork
    dma_seq.start(p_sequencer.dma_seqr);
    mem_seq.start(p_sequencer.mem_seqr);
join


endtask

This is a good first implementation because the dependency is explicit: configuration occurs before the concurrent phase.

The next refinement is to define how the background sequence terminates. A production environment should not rely on the sequence simply ending by accident.

Step 14: Managing a background sequence

A common architecture is to let background traffic run while the main operation executes.

fork
background_seq.start(p_sequencer.mem_seqr);


join_none

dma_seq.start(p_sequencer.dma_seqr);

// Later:
// signal background traffic to stop.

The critical design question is how background_seq detects the termination request.

One possible architecture is:

background sequence
   |
   v


repeat until stop_requested
|
+---- generate transaction
|
+---- check stop condition
|
v
exit

The exact mechanism depends on the sequence architecture, but the principle is universal: background activity needs a controlled lifecycle.

Step 15: Understand sequence cancellation

In more advanced environments, a sequence may need to be stopped before its normal completion.

This can happen during:

  • reset,
  • timeout,
  • error recovery,
  • test phase termination,
  • scenario transitions.

A concurrent-sequence design should therefore consider not only: "How does this sequence start?" but also: "How does this sequence stop?"

Intermediate-level insight: Process lifetime is part of stimulus architecture. Starting concurrent activity without designing its termination path creates fragile tests.

Step 16: Do not confuse concurrent processes with parallel hardware

UVM sequences execute as SystemVerilog processes in simulation. They are not physical hardware threads.

Two sequences running concurrently means the simulator schedules their processes independently according to SystemVerilog simulation semantics.

Therefore:

fork
seq_a.start(seqr_a);
seq_b.start(seqr_b);


join

does not guarantee that both sequences issue transactions on exactly the same simulation timestep.

If cycle-accurate alignment is required, express that requirement explicitly using an appropriate synchronization mechanism.

Step 17: Coordinate at transaction boundaries

A useful abstraction for multi-agent coordination is the transaction boundary.

Instead of trying to synchronize individual driver implementation details, coordinate meaningful protocol events.

Control transaction
   |
   v


Configuration response
|
+------------------+
|                  |
v                  v
DMA request          Memory request
|                  |
+--------+---------+
|
v
Completion event

This keeps the virtual sequence independent of low-level driver implementation.

Step 18: Verify the concurrency itself

A test can complete without proving that the intended concurrency actually occurred.

For example, suppose the requirement is:

"DMA traffic must overlap with background memory traffic."

Merely checking that both sequences completed is insufficient.

The verification environment should collect observable evidence showing that the transactions overlapped in the intended region of the scenario.

Timeline


---------------------------------------------------->

Memory:   [========== BACKGROUND ==========]

DMA:              [========= TRANSFER =========]


                ^^^^^^^^^^^^^
                overlap region

Depending on the design, useful evidence may include:

  • monitor timestamps,
  • transaction ordering,
  • protocol assertions,
  • scoreboard activity,
  • functional coverage for concurrent conditions.

Step 19: Add coverage for concurrency

If concurrent behavior is a verification requirement, consider making it measurable.

For example, coverage could distinguish:

DMA active


Memory active
Interrupt active

and cross those conditions to determine whether important combinations were exercised.

DMA active     x     Memory active


DMA active     x     Interrupt active
Memory active  x     Interrupt active

This turns concurrency from an assumption into measurable verification evidence.

Step 20: Common mistakes

Mistake 1: Running everything concurrently. Real dependencies still need to be preserved.
Mistake 2: Assuming fork guarantees simultaneous execution. It creates concurrent processes; it does not guarantee identical timing.
Mistake 3: Using arbitrary delays for synchronization. Synchronize on meaningful events instead.
Mistake 4: Forgetting that join_any leaves other processes alive. Decide what should happen to the remaining processes.
Mistake 5: Starting background traffic without a stop strategy. Every long-lived process needs controlled termination.
Mistake 6: Sharing mutable state unnecessarily. Excessive shared state increases race-condition risk.
Mistake 7: Verifying only sequence completion. Verify the observable DUT behavior and the intended interaction between agents.

Step 21: A practical design workflow

  1. Describe the system scenario. State what the DUT should experience.
  2. Identify independent activities. Determine which operations can overlap.
  3. Identify dependencies. Determine what must happen before another activity.
  4. Draw the timeline. Make the intended concurrency visible before coding it.
  5. Choose the fork construct. Decide whether the phase requires join, join_any, or join_none.
  6. Define synchronization points. Use meaningful events or protocol/DUT behavior.
  7. Define process termination. Especially for background activity.
  8. Validate with observations. Use monitors, scoreboards, assertions, and coverage.

Step 22: The mental model to remember

              SYSTEM SCENARIO
                 |
                 v
         Dependency graph
                 |
      +----------+----------+
      |                     |
      v                     v


Sequential phase      Concurrent phase
|                     |
|              +------+------+
|              |             |
|              v             v
|           Sequence A   Sequence B
|              |             |
+--------------+-------------+
|
v
Synchronization
|
v
Observable DUT
|
v
Scoreboard / SVA /
Coverage

The best concurrent sequence is not the one containing the most fork statements. It is the one whose structure accurately represents the system behavior being verified.

Try it yourself

Build a virtual sequence for a DUT with:

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

The scenario is:

  1. Configure the DMA engine.
  2. Wait for configuration completion.
  3. Start background memory traffic.
  4. Start a DMA transfer concurrently with the memory traffic.
  5. Wait for the DMA completion indication.
  6. Stop the background traffic.
  7. Verify the transferred data.

Before writing SystemVerilog, draw the timeline:

Configuration
  |
  v


Config complete
|
+--------------------------+
|                          |
v                          v
Memory traffic              DMA transfer
|                          |
|                    DMA complete
|                          |
+------------+-------------+
|
v
Stop background
|
v
Check result

Then answer:

  1. Which operations are sequential?
  2. Which operations are concurrent?
  3. Where should the synchronization points be?
  4. Should the concurrent phase use join, join_any, or join_none?
  5. How will the background sequence terminate?
  6. What monitor or scoreboard evidence proves that DMA and memory traffic overlapped?
  7. What coverage would demonstrate that the concurrent scenario was exercised?

Verification checkpoint

You have mastered this lesson when you can look at a multi-agent scenario and determine its concurrency model before writing the code.

  • Independent operations can execute concurrently.
  • Dependent operations require explicit ordering or synchronization.
  • Parallel phases need a deliberate completion policy.
  • Background processes need a deliberate termination policy.
  • Concurrency requirements should be observable and, where useful, measurable through coverage.
Expert check: If you cannot draw the expected timeline and explain why each process starts, waits, overlaps, and terminates, the concurrent sequence is not yet fully specified.

Key takeaways

  • Concurrent sequences model overlapping system activity across independent interfaces.
  • Concurrency does not eliminate ordering; real scenarios usually combine sequential dependencies with concurrent phases.
  • fork...join, join_any, and join_none provide different process-lifetime and synchronization semantics.
  • Explicit synchronization is safer than arbitrary timing delays.
  • Sequence completion does not automatically mean that the DUT has completed the corresponding operation.
  • Background sequences require a controlled startup and shutdown strategy.
  • Minimize unnecessary shared state to reduce race-condition risk.
  • Verify concurrency through observable transactions, assertions, scoreboard results, and functional coverage.
  • A strong virtual sequence makes system-level intent clear without leaking protocol implementation details into the coordination layer.