Sequencer Arbitration

How the Sequencer decides which sequence item gets processed next when multiple sequences are running in parallel.

The Traffic Cop

In complex testbenches, you might have multiple sequences (e.g., a background traffic sequence and a directed test sequence) trying to use the same driver at the same time. The Sequencer Arbiter acts as a traffic cop, holding start_item() requests in a queue and releasing them based on a pre-defined algorithm.

Arbitration Triggers:

  • The driver calls get_next_item().
  • The arbiter looks at its queue of waiting sequences.
  • One sequence is "granted" and its start_item() call unblocks.

Detailed Arbitration Modes

You can change the sequencer's decision logic using set_arbitration(). Choosing the right mode is key to finding corner-case bugs in your RTL.

Mode Behavior Best For...
SEQ_ARB_FIFO First-come, first-served. Simple, predictable stimulus.
SEQ_ARB_STRICT_FIFO Highest priority wins. Ensuring directed tests always beat background traffic.
SEQ_ARB_RANDOM Unweighted random pick. Stress-testing bus arbitration and latency.
SEQ_ARB_WEIGHTED Random weighted by priority. Simulating realistic statistical traffic distributions.

Lock vs Grab: Atomic Stimulus

Sometimes a sequence needs to send a burst of items (like a multi-beat AXI transfer) without being interrupted. This is done via Locking.

Implementation: Atomic Flush

task body();
    // 1. Request exclusive access
    grab(); // Jumps to the front of the queue
    // 2. Perform uninterruptible operations
    repeat(10) begin
        `uvm_do(req)
    end
    // 3. Release the sequencer
    ungrab(); 
endtask
                            

The Critical Difference:

lock() puts your request at the back of the queue; it only takes effect once previous sequences have finished. grab() jumps to the front of the queue, taking control as soon as the current item (not sequence) finishes.

Best Practices

  • Avoid Greedy Grabs: Overusing grab() can starve other sequences and hide important bugs related to bus contention.
  • Set Priorities: Always assign priorities when starting sequences from a virtual sequence to make your stimulus more deterministic.
  • Randomize Arbitration: In your base test, occasionally set SEQ_ARB_RANDOM to catch ordering-dependent bugs.