Sequence Arbitration
Understand how a UVM sequencer chooses between competing sequences and how to control stimulus priority without creating hidden testbench dependencies.
Learning objectives
- Explain why multiple sequences may compete for the same sequencer.
- Describe how the UVM sequencer arbitrates sequence requests.
- Use sequence priority to influence which sequence runs next.
- Understand when to use sequencer locking and grabbing.
- Select an arbitration policy appropriate for the verification scenario.
- Debug unexpected stimulus ordering using observable evidence.
Step 1: Understand the problem
In a simple UVM test, one sequence may run on a sequencer at a time. In a realistic verification environment, however, several sequences may be active simultaneously. For example, a normal traffic sequence may be generating requests while another sequence is waiting to issue an interrupt, error condition, or high-priority control transaction.
All of those sequences may request access to the same sequencer. The sequencer therefore needs a mechanism to decide which sequence gets the next opportunity to send a sequence item.
+----------------------+
| Sequencer |
| |
normal_seq ---->| |
error_seq ---->| Arbitration |----> Driver
control_seq ---->| |
+----------------------+
This decision is called sequence arbitration. It is important because the order in which transactions reach the driver can change the behavior of the DUT and, consequently, the result of the test.
Step 2: Understand competing sequences
Consider a bus environment with three types of stimulus:
- Normal traffic: continuously generates ordinary requests.
- Control traffic: occasionally needs to issue a configuration transaction.
- Error traffic: intentionally generates a protocol or data error.
Each sequence can run independently, but they all use the same sequencer:
normal_seq.start(env.agent.sequencer);
control_seq.start(env.agent.sequencer);
error_seq.start(env.agent.sequencer);
If these sequences overlap in time, they compete for the sequencer. The sequencer decides which request is granted rather than allowing two sequence items to drive the same interface simultaneously.
This separation is fundamental to UVM architecture:
Sequence
|
| request item
v
Sequencer
|
| arbitration / grant
v
Driver
|
| pin-level activity
v
DUT Step 3: Use sequence priority
A sequence can be assigned a priority that influences arbitration. A useful example is giving an urgent control sequence a higher priority than normal background traffic.
normal_seq.set_priority(100);
control_seq.set_priority(500);
fork
normal_seq.start(env.agent.sequencer);
control_seq.start(env.agent.sequencer);
join
The exact numeric values are less important than their relationship. In this example, the control sequence has higher priority than the normal sequence.
Priority should also not be confused with correctness. A higher-priority sequence being selected does not mean that its transaction is expected to succeed. Priority controls stimulus scheduling; the scoreboard and assertions determine behavioral correctness.
Step 4: Understand arbitration modes
UVM provides different arbitration strategies. The important lesson is not to memorize every mode immediately, but to understand why the arbitration policy matters.
Common strategies include:
- FIFO: favors requests according to their arrival order.
- Weighted: provides probabilistic preference according to configured weights.
- Random: introduces variation among eligible requests.
- Random with exclusions: randomly selects among eligible requests while respecting sequence priorities.
- Strict priority: gives preference to higher-priority sequences.
The correct mode depends on the verification objective. Deterministic arbitration can make debugging easier, while randomized arbitration can expose more interleavings.
env.agent.sequencer.set_arbitration(
SEQ_ARB_STRICT_FIFO
);
When experimenting with arbitration, make the policy explicit in the test or environment configuration. Hidden scheduling behavior is difficult to debug.
Step 5: Lock and grab the sequencer
Priority is not the same as exclusive ownership. Sometimes a sequence needs to perform several related operations without another sequence inserting transactions between them.
UVM provides lock() and grab() mechanisms for this purpose.
Locking
A sequence can request a lock so that, after the current arbitration point, other sequences are prevented from obtaining the sequencer until the lock is released.
task body();
lock(m_sequencer);
// Perform a sequence of related operations.
send_control_item();
send_data_item();
send_status_item();
unlock(m_sequencer);
endtask
Grabbing
A grab is stronger: it places the requesting sequence at the front of the arbitration queue. This should be used carefully because it can significantly change the expected ordering of other stimulus.
task body();
grab(m_sequencer);
send_urgent_item();
send_followup_item();
ungrab(m_sequencer);
endtask
Step 6: See arbitration in a realistic scenario
Imagine that normal traffic is continuously running while a reset-control sequence needs exclusive access to the bus.
task normal_traffic();
repeat (100) begin
bus_item req;
start_item(req);
assert(req.randomize() with {
kind == NORMAL;
});
finish_item(req);
end
endtask
task reset_control();
lock(m_sequencer);
send_reset_command();
send_status_request();
wait_for_reset_completion();
unlock(m_sequencer);
endtask
Without synchronization, normal traffic could be inserted between operations that are intended to form one control sequence. With a lock, the control sequence can establish the required ownership of the sequencer.
The important question is not "How can I force my sequence to run first?" It is: "What ordering does the protocol or verification requirement actually require?"
Step 7: Debug arbitration problems
Unexpected transaction ordering is often blamed on randomization, but arbitration is another common cause. When debugging, inspect the complete path from sequence request to DUT activity.
- Identify which sequences were active at the time of the unexpected transaction.
- Determine which sequences were requesting the sequencer.
- Check their priorities and the configured arbitration mode.
- Look for active locks or grabs.
- Compare sequencer activity with monitor observations.
- Record the random seed when randomized arbitration is involved.
`uvm_info("ARB_DEBUG",
$sformatf("Sequence=%s priority=%0d",
get_name(), get_priority()),
UVM_MEDIUM)
A useful debug log should answer three questions: who requested the sequencer, who was selected, and why was that selection expected?
Common mistakes
- Assuming sequence start order determines transaction order: concurrent sequences are subject to sequencer arbitration.
- Using high priority everywhere: this destroys the meaning of priority and can starve lower-priority stimulus.
- Using grab as a normal scheduling mechanism: grab is intended for exceptional ownership requirements, not ordinary traffic.
- Ignoring starvation: a strict priority policy can prevent lower-priority sequences from getting service.
- Debugging only at the DUT pins: the monitor shows what happened at the interface, but the root cause may be in sequence scheduling.
Choose the right mechanism
| Requirement | Typical mechanism |
|---|---|
| Normal competing traffic | Sequencer arbitration |
| Prefer urgent stimulus | Sequence priority |
| Keep related operations together | Sequencer lock |
| Immediately obtain sequencer access | Sequencer grab |
| Coordinate multiple sequencers | Virtual sequence |
| Verify actual ordering | Monitor + scoreboard/assertions |
Build it in small pieces
- Create two sequences that can run on the same sequencer.
- Start them concurrently so they compete for sequence-item access.
- Run the test with a deterministic arbitration policy first.
- Add priorities and observe how the transaction ordering changes.
- Introduce a third sequence with lower priority and check whether it receives service.
- Experiment with a lock around a multi-item control operation.
- Use monitor output to confirm the actual order seen by the DUT.
Try it yourself
Create three sequences for a shared bus:
normal_traffic_seq— generates ordinary transfers.control_seq— generates an important control transaction.error_seq— generates a deliberate error condition.
Start the sequences concurrently on the same sequencer. Give the control sequence a higher priority and observe how the transaction order changes.
Then modify the control sequence so that it locks the sequencer while performing a three-item operation. Confirm through the monitor that unrelated traffic does not appear between those protected operations.
Intermediate challenge
Design a test in which low-priority background traffic continues running while urgent control traffic occasionally takes precedence. Demonstrate through logs and monitor output that the urgent sequence receives the intended service without permanently starving the background sequence.
Key takeaways
- Sequence arbitration determines which competing sequence gets access to a sequencer next.
- Sequence priority influences arbitration but should represent a real scheduling requirement.
- Locks provide controlled ownership for related operations, while grabs provide stronger immediate priority.
- Arbitration policy affects stimulus ordering and therefore can affect DUT behavior.
- Always validate scheduling assumptions with monitor, scoreboard, assertion, and debug evidence.
- Use the least powerful synchronization mechanism that correctly expresses the protocol requirement.