Coordinating Multiple Agents
Learn how to coordinate independent protocol agents to model realistic system-level scenarios while preserving deterministic ordering and synchronization.
Learning objectives
- Explain why multi-agent scenarios require explicit coordination.
- Distinguish sequential, parallel, and synchronized stimulus.
- Use a virtual sequence to coordinate multiple protocol sequencers.
- Use
fork...joinsafely when agents can operate concurrently. - Use synchronization mechanisms when one agent depends on another.
- Recognize and prevent race conditions in virtual sequences.
- Validate coordination through observable DUT behavior rather than sequence completion alone.
Step 1: Understand why coordination matters
Modern SoCs rarely communicate through a single interface. A realistic verification scenario may involve a control bus, DMA engine, interrupts, memory traffic, and peripheral interfaces at the same time.
Each interface can have its own UVM agent and protocol sequencer:
DUT
|
+------------+------------+
| | |
v v v
Control DMA Interrupt
Agent Agent Agent
| | |
v v v
ctrl_seqr dma_seqr irq_seqr
^ ^ ^
| | |
+------------+------------+
|
virtual sequence
The important question is no longer simply: "Can I generate traffic?"
The question becomes: "Can I generate the right traffic at the right time across multiple interfaces?"
That is the purpose of coordination.
Step 2: Three ways to coordinate agents
Multi-agent stimulus normally falls into three categories.
1. Sequential execution
The second activity starts only after the first sequence completes.
cfg_seq.start(p_sequencer.ctrl_seqr);
dma_seq.start(p_sequencer.dma_seqr);
This is appropriate when the second operation depends on the first operation being complete.
2. Parallel execution
Independent activities execute concurrently.
fork
ctrl_seq.start(p_sequencer.ctrl_seqr);
dma_seq.start(p_sequencer.dma_seqr);
join
This is appropriate when the DUT is expected to handle simultaneous activity.
3. Synchronized execution
Activities start independently but synchronize at a defined point.
fork
begin
cfg_seq.start(p_sequencer.ctrl_seqr);
-> cfg_done;
end
begin
@cfg_done;
dma_seq.start(p_sequencer.dma_seqr);
end
join
This is useful when traffic can be prepared in parallel but a specific event must occur before another operation proceeds.
Step 3: Start with a system-level scenario
Before writing fork...join, describe the intended behavior in plain
language.
For example:
- Program the DMA engine through the control interface.
- Wait until configuration is complete.
- Start DMA traffic.
- Allow the interrupt agent to observe or stimulate interrupt behavior.
- Verify that the transfer completes correctly.
Notice that this is a scenario, not a protocol implementation. The virtual sequence coordinates the scenario while each child sequence remains responsible for its own protocol.
System scenario
|
+--> control sequence
|
+--> DMA sequence
|
+--> interrupt sequence
Step 4: Sequential coordination
Start with the simplest possible dependency.
class dma_system_vseq extends uvm_sequence;
`uvm_object_utils(dma_system_vseq)
`uvm_declare_p_sequencer(system_virtual_sequencer)
task body();
configure_dma_seq cfg_seq;
dma_transfer_seq dma_seq;
cfg_seq =
configure_dma_seq::type_id::create("cfg_seq");
dma_seq =
dma_transfer_seq::type_id::create("dma_seq");
cfg_seq.start(p_sequencer.ctrl_seqr);
dma_seq.start(p_sequencer.dma_seqr);
endtask
endclass
The important property is that dma_seq.start() is not reached until
cfg_seq.start() returns.
configure
|
v
[complete]
|
v
DMA transfer
Step 5: Parallel coordination with fork...join
Suppose the control traffic and background memory traffic are independent. Running them sequentially may create an unrealistic scenario.
task body();
fork
ctrl_seq.start(p_sequencer.ctrl_seqr);
background_seq.start(p_sequencer.mem_seqr);
join
endtask
Conceptually:
time -------------------------------------------------->
control: [====================]
memory: [====================]
Both sequences are started before the fork...join completes.
This is useful for modeling concurrent system activity such as:
- CPU register accesses during DMA traffic,
- background memory traffic during packet reception,
- control operations while a peripheral is active,
- multiple independent interfaces operating simultaneously.
Step 6: Understand the danger of parallel execution
fork...join is powerful, but parallel execution does not magically
establish ordering.
Consider:
fork
configure_seq.start(p_sequencer.ctrl_seqr);
dma_seq.start(p_sequencer.dma_seqr);
join
If the DMA operation requires configuration to be complete, this code may be incorrect.
configure ---------------------->
?
DMA ---------------------->
The two sequences can execute concurrently. The virtual sequence has not told the DMA sequence to wait for configuration.
Step 7: Synchronize dependent agents
SystemVerilog synchronization primitives can make the dependency explicit. A simple event can be used when one sequence needs to notify another.
event cfg_done;
task body();
fork
begin
configure_seq.start(p_sequencer.ctrl_seqr);
-> cfg_done;
end
begin
@cfg_done;
dma_seq.start(p_sequencer.dma_seqr);
end
join
endtask
The execution now has a clear dependency:
control sequence
|
v
configuration complete
|
cfg_done
|
v
DMA sequence
The key improvement is that the ordering is represented explicitly rather than being an accidental consequence of scheduling.
Step 8: Synchronize at the right abstraction level
A common mistake is synchronizing on the wrong event.
For example, this:
cfg_seq.start(p_sequencer.ctrl_seqr);
dma_seq.start(p_sequencer.dma_seqr);
guarantees sequence execution ordering, but the DUT may still require several clock cycles after the final configuration transaction before it is ready for DMA.
The correct synchronization point might instead be:
- a monitored completion transaction,
- a DUT status indication,
- a protocol response,
- an interrupt,
- a testbench event generated by a monitor.
This leads to an important verification principle:
Step 9: Coordinate three agents
Now consider a more realistic scenario:
1. Configure DMA
2. Start background memory traffic
3. Start DMA transfer
4. Wait for transfer completion
5. Generate or handle interrupt
6. Finish the scenario
The dependency graph is more useful than simply writing code:
configure
|
v
configuration done
|
+------+------+
| |
v v
DMA traffic memory traffic
|
v
transfer done
|
v
interrupt
Only after defining this relationship should you implement the virtual sequence.
Step 10: 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");
// Configuration must happen first.
cfg_seq.start(p_sequencer.ctrl_seqr);
// These activities are now allowed to overlap.
fork
dma_seq.start(p_sequencer.dma_seqr);
mem_seq.start(p_sequencer.mem_seqr);
join
endtask
This implementation is intentionally simple. It establishes one strict dependency and then introduces concurrency only where it is justified.
Step 11: Coordinate without coupling protocol details
A virtual sequence should say:
configure
start DMA
run background traffic
wait for completion
It should not contain low-level protocol implementation such as:
drive_awaddr();
drive_wdata();
wait_for_bresp();
toggle_interrupt_pin();
Those responsibilities belong in the appropriate protocol sequences, drivers, monitors, and agents.
The virtual sequence coordinates intent; child sequences implement protocol behavior.
Step 12: Avoid using delays as synchronization
One of the most dangerous shortcuts in multi-agent stimulus is using arbitrary delays to establish ordering.
cfg_seq.start(p_sequencer.ctrl_seqr);
#100ns;
dma_seq.start(p_sequencer.dma_seqr);
The problem is that #100ns expresses time, not intent.
If configuration takes 20 ns today and 150 ns after a design change, the
synchronization becomes unreliable.
Prefer a meaningful completion condition.
wait_for_configuration_complete();
dma_seq.start(p_sequencer.dma_seqr);
Or use a monitor-driven event or other testbench synchronization mechanism appropriate to the environment.
Step 13: Understand fork...join variants
SystemVerilog provides several ways to control parallel processes.
| Construct | Meaning | Typical use |
|---|---|---|
join |
Wait for all spawned processes. | All activities are required to finish. |
join_any |
Continue when any spawned process finishes. | Race or first-completion scenarios. |
join_none |
Do not wait for spawned processes. | Background activity. |
For example, background traffic may intentionally continue while another part of the scenario proceeds:
fork
background_seq.start(p_sequencer.mem_seqr);
join_none
main_seq.start(p_sequencer.ctrl_seqr);
However, this creates lifecycle responsibilities. The test must eventually terminate or stop the background activity cleanly.
Step 14: Be careful with background sequences
A background sequence launched with join_none can outlive the
operation that started it.
fork
background_seq.start(p_sequencer.mem_seqr);
join_none
main_seq.start(p_sequencer.ctrl_seqr);
// What stops background_seq?
A robust environment should define how background activity terminates. Otherwise, the sequence can continue running while the test is attempting to finish or reset the environment.
Ask three questions whenever using background activity:
- Who starts it?
- Who stops it?
- What event tells the test that it is safe to finish?
Step 15: Understand sequence completion versus DUT completion
This distinction is critical in real verification environments.
dma_seq.start(p_sequencer.dma_seqr);
The call returning means the sequence has completed its sequence-level work. It does not necessarily mean:
- the DUT has completed the transaction,
- the response has reached the monitor,
- the interrupt has occurred,
- the scoreboard has processed the expected result.
A robust system-level scenario often looks more like:
start DMA sequence
|
v
sequence completes
|
v
wait for DUT completion event
|
v
observe expected response
|
v
scenario complete Step 16: Use synchronization to express dependencies
Instead of thinking only in terms of sequence calls, think in terms of a dependency graph.
Independent:
A -------->
B -------->
Dependent:
A -------->
|
v
event
|
v
B -------->
Partially concurrent:
A -------->
|
+---- event ----> C
|
B -------->
This mental model makes virtual sequences easier to design and debug.
Step 17: Validate coordination with observable evidence
Do not declare a scenario successful merely because the virtual sequence completed without an exception.
Evidence should come from the verification environment:
- monitor transactions,
- scoreboard comparisons,
- protocol assertions,
- DUT status responses,
- interrupt observations,
- functional coverage.
For example, if a DMA transfer is expected to generate an interrupt:
DMA request
|
v
DMA activity observed
|
v
DMA completion observed
|
v
interrupt observed
|
v
scoreboard validates result
The virtual sequence creates the stimulus. The rest of the verification environment provides evidence that the DUT behaved correctly.
Step 18: Common coordination mistakes
Step 19: A practical design workflow
- Describe the scenario in plain language. Do not start with SystemVerilog.
- Identify the participating agents. Determine which protocol sequences are required.
- Draw dependencies. Mark what must happen first and what can happen concurrently.
- Implement the sequential portions. Start with the simplest deterministic ordering.
-
Add justified parallelism.
Use
fork...joinonly where concurrency is meaningful. - Add explicit synchronization. Synchronize on meaningful events when dependencies cross agents.
- Validate with monitors and checkers. Prove that the DUT observed the intended interaction.
- Only then add randomization and stress. Complexity should be added after the coordination model is correct.
Step 20: Putting the architecture together
UVM TEST
|
v
system_virtual_seq
|
v
system_virtual_sequencer
/ | \
/ | \
v v v
ctrl_seqr dma_seqr mem_seqr
| | |
v v v
ctrl_agent dma_agent mem_agent
| | |
v v v
ctrl_drv dma_drv mem_drv
\ | /
\ | /
DUT
The architectural separation is now clear:
- The test selects the scenario.
- The virtual sequence defines the coordination.
- The virtual sequencer provides access to protocol sequencers.
- The protocol sequences generate interface-specific stimulus.
- The drivers convert transactions into pin-level activity.
- The monitors and scoreboards provide verification evidence.
Try it yourself
Design a virtual sequence for a DUT containing three interfaces:
- a control bus,
- a DMA interface, and
- a memory interface.
The required scenario is:
- Program the DMA engine through the control bus.
- Wait until configuration is complete.
- Start background memory traffic.
- Start the DMA transfer.
- Allow memory and DMA traffic to execute concurrently.
- Wait for the DMA completion indication.
- Stop the background traffic cleanly.
- Allow the scoreboard to verify the resulting data.
Before writing code, draw the dependency graph.
configure
|
v
configuration complete
|
+----------------+
| |
v v
memory traffic DMA transfer
|
v
DMA complete
|
v
stop background
|
v
scoreboard check
Challenge 1: Identify which operations must be sequential and which can execute concurrently.
Challenge 2: Implement the scenario using the virtual sequencer from Lesson 7.
Challenge 3: Replace at least one arbitrary delay with a meaningful synchronization event.
Challenge 4: Explain how you would prove from monitor or scoreboard evidence that the coordination happened in the intended order.
Verification checkpoint
You should now be able to answer these questions:
- When should multiple agents run sequentially?
- When is parallel execution appropriate?
- Why can blindly using
fork...joinintroduce a bug? - What is the difference between sequence completion and DUT completion?
- Why are arbitrary time delays a poor synchronization mechanism?
- What should a virtual sequence coordinate, and what should remain inside child protocol sequences?
- How should a background sequence be started and terminated safely?
- What verification evidence proves that multi-agent coordination produced the intended DUT behavior?
Key takeaways
- Multi-agent verification requires explicit control of ordering, concurrency, synchronization, and process lifetime.
- Sequential execution is appropriate for true dependencies; parallel execution is appropriate for independent or intentionally concurrent activity.
-
fork...joinprovides concurrency but does not establish application-level dependencies by itself. - Synchronize on meaningful events or DUT behavior rather than relying on arbitrary delays.
- A virtual sequence coordinates system-level intent while child sequences remain responsible for protocol-specific behavior.
- Sequence completion and DUT completion are not necessarily the same event.
- Background activity requires an explicit lifecycle and shutdown strategy.
- The best coordination strategy is one that makes the intended system behavior obvious, deterministic, reusable, and observable.