Cover image: UVM Sequencer Arbitration: How the Sequencer Picks the Next Item | The Art of Verification

UVM Sequencer Arbitration: How the Sequencer Picks the Next Item

In short: when several sequences run on one sequencer, they all wait for the same driver. Every time the driver asks for an item, the sequencer picks one waiting sequence. That choice is arbitration. You set the rule with set_arbitration(): six built-in modes, from plain first-come-first-served to strict priority. The default, UVM_SEQ_ARB_FIFO, ignores priority completely. Use lock() or grab() when one sequence needs the driver to itself for a while.

Most tests start one sequence at a time, so arbitration never comes up.

Then you start two sequences on the same sequencer, give one a higher priority, and it doesn’t go first.

That surprises a lot of engineers. This lesson runs all six modes, plus lock and grab, on one small bench on Synopsys VCS, and prints the exact order the driver received the items.

By the end of this lesson, you’ll be able to:

  • Explain when the sequencer arbitrates, and what it chooses between.
  • Pick the right mode with set_arbitration(), and know which modes use priority.
  • Give a sequence a priority with start().
  • Use lock() and grab() for exclusive access, and know how they differ.

The picture: one barista, many customers

Think of a small coffee shop with one barista.

Customers place orders. The barista can only make one drink at a time. Every time a drink is done, someone has to decide which order is next.

That someone is the sequencer. The barista is the driver. Each customer is a sequence, and each drink is an item.

At the coffee shopIn UVMWhat it means
The baristaThe driverTakes one item at a time
The person who calls the next orderThe sequencerPicks which sequence goes next
A customerA sequenceWaits for a turn to send each item
A loyalty card levelPriority, set in start()Only some modes look at it
Calling orders in the order they cameUVM_SEQ_ARB_FIFOThe default. Ignores loyalty level
Gold members always firstUVM_SEQ_ARB_STRICT_FIFOHighest priority first, then arrival order
A raffle with more tickets for gold membersUVM_SEQ_ARB_WEIGHTEDRandom, but higher priority wins more often
A plain raffleUVM_SEQ_ARB_RANDOMRandom, priority ignored
The manager’s own ruleUVM_SEQ_ARB_USERYou write the rule
Booking the barista for a big order, once your turn comeslock()Waits in line, then nobody else is served
Walking straight to the frontgrab()Next in line, then nobody else is served

Keep this picture in mind. Each run below is one of these rows.

When arbitration happens

A sequence asks for a turn every time it calls start_item(), or `uvm_do, which calls it for you. The request waits in the sequencer until the driver calls get_next_item().

If only one sequence is waiting, there’s nothing to decide. If several are waiting, the sequencer applies its arbitration mode and grants one. The others keep waiting for the next turn.

So arbitration happens per item, not per sequence. A sequence with 4 items wins 4 separate turns.

The six modes

ModeUses priority?How it picks
UVM_SEQ_ARB_FIFONoOldest request first. The default
UVM_SEQ_ARB_WEIGHTEDYesRandom, weighted by priority
UVM_SEQ_ARB_RANDOMNoRandom
UVM_SEQ_ARB_STRICT_FIFOYesHighest priority first, oldest first among equals
UVM_SEQ_ARB_STRICT_RANDOMYesHighest priority first, random among equals
UVM_SEQ_ARB_USERYour callCalls your user_priority_arbitration()

Set it on the sequencer, once, before the sequences start:

env.agt.sqr.set_arbitration(UVM_SEQ_ARB_STRICT_FIFO);

Giving a sequence a priority

Priority is the third argument of start(). A bigger number means higher priority. If you don’t pass one, a sequence takes its parent’s priority, or 100 if it has no parent.

fork
  a.start(sqr, null, 100);
  b.start(sqr, null, 200);
  c.start(sqr, null, 300);   // highest priority
join

Priority only matters in WEIGHTED, STRICT_FIFO and STRICT_RANDOM, and in USER if your rule reads it. In the default FIFO mode, it does nothing.

Writing your own rule

For UVM_SEQ_ARB_USER, extend your sequencer and override one function. UVM passes the list of waiting requests, oldest first, and you return the one to grant.

class tag_sqr extends uvm_sequencer #(tag_item);
  ...
  // Pick the newest request instead of the oldest
  function integer user_priority_arbitration(integer avail_sequences[$]);
    return avail_sequences[avail_sequences.size() - 1];
  endfunction
endclass

lock() and grab()

Sometimes one sequence must send several items with nothing in between. A register write followed by a read-back, for example. Both calls give a sequence the sequencer to itself until it lets go:

task body();
  lock();          // or grab()
  repeat (3) `uvm_do(req)
  unlock();        // or ungrab()
endtask

The difference is when it starts. lock() joins the queue like a normal request and waits its turn. grab() goes to the front of the queue and is granted as soon as the driver finishes its current item. The runs below show the exact difference.

Eight runs, one bench

Three sequences, A, B and C, each send 4 items tagged with their letter. They start together on one sequencer with priorities 100, 200 and 300. The driver takes one item every 10 ns. At the end, the test prints the letters in the order the driver got them.

Real output, Synopsys VCS X-2025.06-SP1 with UVM 1.2:

RunOrder the driver gotWhat happened
FIFOABCABCABCABCA fair rotation. C’s priority of 300 made no difference
WEIGHTEDBACCBCBCBAAARandom, but C won 4 of the first 8 turns and A only 1
RANDOMBCCAABBCCBAAA mixed order, no pattern
STRICT_FIFOCCCCBBBBAAAAHighest priority first, every time
STRICT_RANDOMCCCCBBBBAAAAThe same, because no two sequences shared a priority
USER (newest wins)CCCCBBBBAAAAThe same order, for a completely different reason

Every run took 120 ns for 12 items. Arbitration never changes how many items get through. It only changes the order.

FIFO: priority does nothing

UVM_INFO @ 0: uvm_test_top [ARB] arbitration = UVM_SEQ_ARB_FIFO
UVM_INFO @ 120: uvm_test_top [END] ARB=FIFO MODE=three order=ABCABCABCABC (12 items, done at 120)

This is the default, and it’s the one that surprises people. C asked for priority 300, three times A’s. It still waited behind A and B every round. FIFO only looks at who asked first.

If you set a priority and nothing changed, check the mode before anything else.

WEIGHTED: a raffle with extra tickets

UVM_INFO @ 120: uvm_test_top [END] ARB=WEIGHTED MODE=three order=BACCBCBCBAAA (12 items, done at 120)

The weights were 100, 200 and 300. C won 4 of the first 8 turns, B won 3, and A won 1. A’s last three items only went through once B and C had nothing left to send. A different seed gives a different order, but the bias toward C stays.

STRICT_FIFO and STRICT_RANDOM: highest priority first

UVM_INFO @ 120: uvm_test_top [END] ARB=STRICT_FIFO MODE=three order=CCCCBBBBAAAA (12 items, done at 120)

C sent all 4 items before B got a single turn. B did the same to A. Strict modes don’t share. As long as a higher-priority sequence has an item waiting, nobody else goes.

STRICT_RANDOM printed the exact same order. It only picks at random among sequences with the same priority, and here every priority was different.

USER: same order, different reason

UVM_INFO @ 0: uvm_test_top [ARB] arbitration = UVM_SEQ_ARB_USER
UVM_INFO @ 120: uvm_test_top [END] ARB=USER MODE=three order=CCCCBBBBAAAA (12 items, done at 120)

Our rule never looks at priority. It always picks the newest request. C was started last, so its request was newest. After each C item, C asked again, and became the newest again. So C won every turn until it was finished, then B did the same.

That’s a useful warning. A custom rule can starve other sequences without you noticing, and the output can look like it’s doing something sensible.

lock() vs grab(): the real difference

For these two runs, A and B send 6 items each with the same priority. At 25 ns, a third sequence, L, asks for the sequencer with lock() or grab(), sends 3 items tagged L, and lets go.

RunL asked atL got the sequencer atL’s items started atOrder
lock25 ns30 ns40, 50, 60 nsABABLLLABABABAB
grab25 ns25 ns30, 40, 50 nsABALLLBABABABAB

A “got X” line prints when the driver finishes an item, 10 ns after it started.

# lock
UVM_INFO @ 25: uvm_test_top.sqr@@L [EXCL] asking for lock() at 25
UVM_INFO @ 30: uvm_test_top.drv [DRV] got A
UVM_INFO @ 30: uvm_test_top.sqr@@L [EXCL] got the sequencer at 30
UVM_INFO @ 40: uvm_test_top.drv [DRV] got B
UVM_INFO @ 50: uvm_test_top.drv [DRV] got L

# grab
UVM_INFO @ 25: uvm_test_top.sqr@@L [EXCL] asking for grab() at 25
UVM_INFO @ 25: uvm_test_top.sqr@@L [EXCL] got the sequencer at 25
UVM_INFO @ 30: uvm_test_top.drv [DRV] got A
UVM_INFO @ 40: uvm_test_top.drv [DRV] got L

With lock(), B already had a request waiting when L asked. L joined the queue behind it, so B’s item went first, and L’s items started at 40 ns.

With grab(), L got the sequencer the moment it asked. The item already on the driver, A’s, finished normally. Then L went straight in at 30 ns, ahead of B’s waiting request. B’s second item slipped from fourth place to seventh.

In both runs, once L had the sequencer, its three items went out back to back, with nothing in between. That’s the whole point of both calls. They only differ in where L joins the line.

Back at the coffee shop: FIFO is a barista who ignores loyalty cards. STRICT is a barista who serves every gold member before anyone else, however long the others wait. USER is a manager whose rule sounds harmless and still leaves two customers waiting. lock() books the barista, then waits for the order already in front. grab() walks to the counter and is next, full stop.

Here’s every run in one picture.

Who got the driver, turn by turn: FIFO gives ABCABCABCABC, WEIGHTED BACCBCBCBAAA, RANDOM BCCAABBCCBAA, STRICT_FIFO, STRICT_RANDOM and USER all give CCCCBBBBAAAA; lock gives ABABLLLABABABAB and grab gives ABALLLBABABABAB
The real item order for all eight runs.

Common mistakes, with fixes

Setting a priority in FIFO mode. The default mode ignores priority. In our FIFO run, C at 300 still went third every round.

  • Fix: call set_arbitration() with WEIGHTED, STRICT_FIFO or STRICT_RANDOM when priority should matter.

Starving a sequence with STRICT modes. A high-priority sequence that never runs out of items blocks everyone below it, for the whole test.

  • Fix A: use WEIGHTED if low-priority traffic must still get through.
  • Fix B: if you need strict, make sure the high-priority sequence ends or pauses.

A custom rule that starves without telling you. Our “newest wins” rule looked harmless and still gave C every turn until it finished.

  • Fix: print the chosen sequence in your user_priority_arbitration() while you develop it, and check the order in a real run.

Forgetting unlock() or ungrab(). Every other sequence on that sequencer waits forever, and the test hangs.

  • Fix: pair every lock() with unlock() and every grab() with ungrab() in the same task, and set a global timeout. See Why Does My UVM Test Never End? for how to find the stuck sequence.

Using grab() when lock() would do. grab() jumps ahead of requests that were already waiting, which can break a sequence that expected its next item to go out promptly.

  • Fix: use lock() by default. Use grab() only when the exclusive items must go next, like a reset or an interrupt response.

Expecting the same WEIGHTED or RANDOM order on every run. The order depends on the random seed.

  • Fix: keep the seed in your regression log so a failing order can be reproduced.

How AI helps (and where it doesn’t)

  • Predicting an order. Paste your sequences, their priorities and the arbitration mode, and ask what order the driver will see. It’s a quick sanity check before a run.
  • Reading a log. Paste a driver log and ask why one sequence was starved. It will usually point at a STRICT mode or a missing unlock().
  • Writing a custom rule. Ask for a user_priority_arbitration() that, for example, round-robins between two groups. Then run it and print the order.

Where to be careful: assistants often say priority “always” matters, and forget that the default FIFO mode ignores it. Some also describe lock() and grab() as the same thing. Only a run shows the real order.

Don’t paste confidential code or logs into public tools. Use what your company has approved. For the bigger picture, read AI in ASIC verification.

Interview questions

These come up a lot in UVM interviews. Try answering each one before reading the answer.

  1. What is the default arbitration mode, and does it use priority? UVM_SEQ_ARB_FIFO, and no. In our run, three sequences with priorities 100, 200 and 300 still went ABCABC.
  2. Which modes use priority? WEIGHTED, STRICT_FIFO and STRICT_RANDOM. USER can, if your rule reads it.
  3. How do you give a sequence a priority? Pass it as the third argument of start(), for example seq.start(sqr, null, 300). A bigger number means higher priority.
  4. What’s the difference between lock() and grab()? Both give a sequence exclusive use of the sequencer. lock() waits behind requests already queued. grab() goes to the front. In our run, grab got in 10 ns earlier and jumped ahead of B’s waiting item.
  5. How would you write your own arbitration? Set UVM_SEQ_ARB_USER and override user_priority_arbitration() in your sequencer. It gets the waiting requests and returns the one to grant.

Practice challenge

Take the full code below and try this:

  1. Give B the same priority as C, 300, and run +ARB=STRICT_FIFO, then +ARB=STRICT_RANDOM. Now the two runs should differ. How?
  2. Change our user_priority_arbitration() so it picks the oldest request instead of the newest. Which built-in mode does it now match?
  3. In excl_seq, remove the unlock() call and run +MODE=lock. What happens to A and B?

If step 3 hangs, that’s the point. Add uvm_top.set_timeout(1us, 0); and see the fatal end it.

Frequently asked questions

What is sequencer arbitration in UVM?

When several sequences wait on one sequencer, the sequencer picks which one sends the next item to the driver. The rule it uses is the arbitration mode, set with set_arbitration().

What is the default arbitration mode?

UVM_SEQ_ARB_FIFO. It grants requests in the order they arrived and ignores priority.

Why doesn’t my sequence priority work?

The sequencer is probably still in FIFO mode, which ignores priority. Switch to WEIGHTED, STRICT_FIFO or STRICT_RANDOM.

What is the difference between lock and grab in UVM?

Both give one sequence the sequencer to itself until it lets go. lock() waits for its turn in the queue. grab() goes to the front and is granted as soon as the current item finishes.

Can a sequence be starved?

Yes. In STRICT modes, a higher-priority sequence with items waiting always wins. A custom rule can starve sequences too.

When should I use UVM_SEQ_ARB_USER?

When none of the built-in modes fit, for example round-robin between groups of sequences. Override user_priority_arbitration() and test the order in a real run.

Full code

One file: a sequencer with a custom rule, three letter sequences, a lock/grab sequence, a driver that records the order, and a test. On EDA Playground choose Synopsys VCS and UVM 1.2, set the top module to top, and run once per option in the header.

// arbitration_demo.sv : who gets the driver next? Sequencer arbitration, one bench
// The Art of Verification | theartofverification.com
//
// Run options (one per run):
//   +ARB=FIFO           three sequences A, B, C (priority 100, 200, 300), 4 items each
//   +ARB=WEIGHTED       the same three, weighted by priority
//   +ARB=RANDOM         the same three, priority ignored
//   +ARB=STRICT_FIFO    the same three, highest priority first
//   +ARB=STRICT_RANDOM  the same three, highest priority first, random among equals
//   +ARB=USER           the same three, our own rule: always pick the newest request
//   +MODE=lock          A and B run 6 items each; at 25 ns, L calls lock() and sends 3
//   +MODE=grab          the same, but L calls grab()
//
// Run on Synopsys VCS X-2025.06-SP1 with UVM 1.2 (EDA Playground), 23 Nov 2026.

`timescale 1ns/1ns
`include "uvm_macros.svh"
import uvm_pkg::*;

string ARB  = "FIFO";
string MODE = "three";

class tag_item extends uvm_sequence_item;
  string tag;                          // which sequence sent this item
  `uvm_object_utils(tag_item)
  function new(string name = "tag_item");
    super.new(name);
  endfunction
endclass

// A sequencer with our own arbitration rule for UVM_SEQ_ARB_USER
class tag_sqr extends uvm_sequencer #(tag_item);
  `uvm_component_utils(tag_sqr)
  function new(string name, uvm_component parent);
    super.new(name, parent);
  endfunction
  // avail_sequences holds the waiting requests, oldest first. Pick the newest.
  function integer user_priority_arbitration(integer avail_sequences[$]);
    return avail_sequences[avail_sequences.size() - 1];
  endfunction
endclass

// Sends n items, each tagged with its own letter
class letter_seq extends uvm_sequence #(tag_item);
  `uvm_object_utils(letter_seq)
  string tag = "?";
  int    n   = 4;
  function new(string name = "letter_seq");
    super.new(name);
  endfunction
  task body();
    repeat (n) begin
      req = tag_item::type_id::create("req");
      start_item(req);
      req.tag = tag;
      finish_item(req);
    end
  endtask
endclass

// Takes the sequencer for itself with lock() or grab(), sends 3 items, lets go
class excl_seq extends uvm_sequence #(tag_item);
  `uvm_object_utils(excl_seq)
  bit use_grab;
  function new(string name = "excl_seq");
    super.new(name);
  endfunction
  task body();
    `uvm_info("EXCL", $sformatf("asking for %s at %0t", use_grab ? "grab()" : "lock()", $time), UVM_NONE)
    if (use_grab) grab(); else lock();
    `uvm_info("EXCL", $sformatf("got the sequencer at %0t", $time), UVM_NONE)
    repeat (3) begin
      req = tag_item::type_id::create("req");
      start_item(req);
      req.tag = "L";
      finish_item(req);
    end
    if (use_grab) ungrab(); else unlock();
    `uvm_info("EXCL", $sformatf("let go at %0t", $time), UVM_NONE)
  endtask
endclass

// Takes one item every 10 ns and remembers the order
class tag_driver extends uvm_driver #(tag_item);
  `uvm_component_utils(tag_driver)
  string order = "";
  function new(string name, uvm_component parent);
    super.new(name, parent);
  endfunction
  task run_phase(uvm_phase phase);
    forever begin
      seq_item_port.get_next_item(req);
      #10;
      order = {order, req.tag};
      `uvm_info("DRV", $sformatf("got %s", req.tag), UVM_NONE)
      seq_item_port.item_done();
    end
  endtask
endclass

class arb_test extends uvm_test;
  `uvm_component_utils(arb_test)
  tag_sqr    sqr;
  tag_driver drv;
  function new(string name, uvm_component parent);
    super.new(name, parent);
  endfunction
  function void build_phase(uvm_phase phase);
    super.build_phase(phase);
    sqr = tag_sqr::type_id::create("sqr", this);
    drv = tag_driver::type_id::create("drv", this);
  endfunction
  function void connect_phase(uvm_phase phase);
    drv.seq_item_port.connect(sqr.seq_item_export);
  endfunction

  function void end_of_elaboration_phase(uvm_phase phase);
    case (ARB)
      "FIFO":          sqr.set_arbitration(UVM_SEQ_ARB_FIFO);
      "WEIGHTED":      sqr.set_arbitration(UVM_SEQ_ARB_WEIGHTED);
      "RANDOM":        sqr.set_arbitration(UVM_SEQ_ARB_RANDOM);
      "STRICT_FIFO":   sqr.set_arbitration(UVM_SEQ_ARB_STRICT_FIFO);
      "STRICT_RANDOM": sqr.set_arbitration(UVM_SEQ_ARB_STRICT_RANDOM);
      "USER":          sqr.set_arbitration(UVM_SEQ_ARB_USER);
      default: `uvm_fatal("ARB", {"unknown +ARB=", ARB})
    endcase
    `uvm_info("ARB", $sformatf("arbitration = %s", sqr.get_arbitration().name()), UVM_NONE)
  endfunction

  task run_phase(uvm_phase phase);
    letter_seq a = letter_seq::type_id::create("A");
    letter_seq b = letter_seq::type_id::create("B");
    letter_seq c = letter_seq::type_id::create("C");
    excl_seq   l = excl_seq::type_id::create("L");
    a.tag = "A"; b.tag = "B"; c.tag = "C";
    phase.raise_objection(this);
    if (MODE == "three") begin
      fork
        a.start(sqr, null, 100);       // the third argument is the priority
        b.start(sqr, null, 200);
        c.start(sqr, null, 300);
      join
    end else begin
      a.n = 6; b.n = 6;
      l.use_grab = (MODE == "grab");
      fork
        a.start(sqr);
        b.start(sqr);
        begin #25; l.start(sqr); end
      join
    end
    phase.drop_objection(this);
  endtask

  function void report_phase(uvm_phase phase);
    `uvm_info("END", $sformatf("ARB=%s MODE=%s order=%s (%0d items, done at %0t)",
                               ARB, MODE, drv.order, drv.order.len(), $time), UVM_NONE)
  endfunction
endclass

module top;
  initial begin
    void'($value$plusargs("ARB=%s", ARB));
    void'($value$plusargs("MODE=%s", MODE));
    run_test("arb_test");
  end
endmodule

References

Read next