Module 4: Stimulus and Drivers | Lesson 34

Sequence-Driver Handshake

Learn exactly how sequence items move from a sequence through a sequencer to a driver, and how the UVM handshake controls when each transaction is requested and completed.

Learning objectives

  • Explain the purpose of the UVM sequence-driver handshake.
  • Understand start_item() and finish_item().
  • Understand get_next_item() and item_done().
  • Trace one transaction from a sequence to a driver.
  • Understand where blocking can occur during the handshake.
  • Explain why the driver must call item_done().
  • Distinguish transaction transfer from DUT protocol completion.
  • Debug common handshake failures systematically.

Step 1: Why does a handshake exist?

In UVM, a sequence generates transaction-level stimulus while a driver converts transactions into DUT signal activity.

The sequence and driver operate independently, so UVM needs a controlled mechanism for transferring each sequence item.

That mechanism is the sequence-driver handshake.

Sequence
|
| "I have a transaction"
v


Sequencer
|
| "Driver, here is the next item"
v
Driver
|
| drives DUT
v
DUT
|
| transaction completed
v
Driver
|
| item_done()
v
Sequencer / Sequence
Core idea: The handshake coordinates the transfer of a sequence item and prevents the sequence and driver from losing track of transaction progress.

Step 2: The four operations you must understand

The basic handshake uses four important operations.

Operation Used by Purpose
start_item() Sequence Begins the sequence-item handshake.
finish_item() Sequence Completes the sequence-side item transfer.
get_next_item() Driver Requests the next available sequence item.
item_done() Driver Indicates that the driver has completed processing the item.

You will see these operations repeatedly in UVM stimulus code. Understanding their relationship is more important than memorizing their names.

Step 3: Start with the sequence side

A sequence normally creates a sequence item and then uses start_item() and finish_item().

task body();

bus_transaction req;

req = bus_transaction::type_id::create("req");

start_item(req);

req.write = 1;
req.addr  = 8'h20;
req.data  = 32'h0000_0055;

finish_item(req);


endtask

The sequence is saying:

"I want to send this transaction through my sequencer."

The sequence does not directly call the driver's get_next_item(). The sequencer manages the communication between the two sides.

Step 4: What does start_item() do?

start_item() begins the sequence-item transaction. It gives the sequencer an opportunity to coordinate this item with other active sequences.

start_item(req);

After this point, the sequence prepares the item.

req.write = 1;


req.addr  = 8'h20;
req.data  = 32'h55;

If the item is randomized, randomization is normally performed between start_item() and finish_item().

start_item(req);


if (!req.randomize()) begin
`uvm_fatal("RANDFAIL",
"Transaction randomization failed")
end

finish_item(req);
Important: Think of start_item() as entering the controlled sequence-item handshake, not as "sending the item to the driver immediately."

Step 5: What does finish_item() do?

After the sequence has prepared the item, it calls:

finish_item(req);

This completes the sequence-side item operation and allows the sequencer to make the item available to the driver according to the UVM sequence mechanism.

A useful beginner pattern is:

start_item(req);


// Set or randomize fields.

finish_item(req);

Do not think of finish_item() as meaning "the DUT has finished the transaction."

It means the sequence has completed its sequence-item transfer operation. The driver still has to process the item.

Step 6: Now look at the driver

The driver normally waits for sequence items in its run_phase().

task run_phase(uvm_phase phase);

forever begin

    seq_item_port.get_next_item(req);

    drive_transaction(req);

    seq_item_port.item_done();

end


endtask

This creates the other half of the handshake.

The driver asks:

get_next_item(req);

Once it receives an item, it drives the DUT.

drive_transaction(req);

When the driver has completed processing that item, it tells the sequencer:

item_done();

Step 7: The complete handshake

Put the sequence and driver sides together:

SEQUENCE                         DRIVER


start_item(req)
|
| prepare/randomize
|
finish_item(req)
|
|------------------------>
|                    get_next_item(req)
|                         |
|                         v
|                    drive DUT
|                         |
|                         v
|                    item_done()
|<------------------------|
|
next sequence item

This is the basic mental model you should carry forward.

Handshake summary: The sequence produces an item. The sequencer manages its transfer. The driver consumes the item, drives the DUT, and signals completion.

Step 8: Why is item_done() important?

The driver must tell the sequencer when it has finished processing the current item.

seq_item_port.item_done();

If the driver forgets this operation, the sequence/sequencer handshake may not progress as expected.

For example:

task run_phase(uvm_phase phase);

forever begin

    seq_item_port.get_next_item(req);

    drive_transaction(req);

    // item_done() accidentally missing

end


endtask

This is a classic handshake bug.

The driver may appear to have driven one transaction, but the sequence can fail to progress to the next transaction.

Rule: Every successful get_next_item() should have a corresponding completion operation such as item_done() in the normal driver flow.

Step 9: Driver completion is not the same as sequence completion

This distinction is extremely important.

Consider a bus write. The sequence creates the transaction. The driver receives it and may then have to perform several clock cycles of protocol activity.

Sequence


|
| write transaction
v
Sequencer
|
v
Driver
|
+-- assert valid
|
+-- drive address
|
+-- drive data
|
+-- wait for ready
|
+-- complete bus transfer
|
+-- item_done() 

The driver should call item_done() at the appropriate point in its transaction-processing flow—not merely because it received the object.

The exact completion point depends on the protocol implemented by the driver.

Step 10: A realistic driver example

Suppose a simple bus requires valid to remain asserted until the DUT raises ready.

task run_phase(uvm_phase phase);

forever begin

    seq_item_port.get_next_item(req);

    vif.valid <= 1'b1;
    vif.addr  <= req.addr;
    vif.data  <= req.data;

    do begin
        @(posedge vif.clk);
    end
    while (!vif.ready);

    vif.valid <= 1'b0;

    seq_item_port.item_done();

end


endtask

Here the driver does not call item_done() immediately after receiving the transaction.

It first performs the protocol operation and waits for the completion condition.

This is the key difference between:

"I received the transaction."

and:

"I completed driving the transaction."

Step 11: Understand blocking behavior

Some handshake operations wait until the required condition occurs.

For example:

seq_item_port.get_next_item(req);

The driver can wait here until a sequence item is available.

Similarly, the sequence may wait as part of the sequence-item handshake when another sequence is currently being serviced.

This is one reason the handshake is useful: the sequence and driver do not have to guess when the other side is ready.

Think in terms of waiting: The sequence waits for the sequence mechanism to accept its item; the driver waits for an available item; the driver then waits for the DUT protocol to complete.

Step 12: One transaction, one complete timeline

Imagine a sequence generating one write.

Time


|
|  Sequence creates req
|
|  start_item(req)
|
|  req fields assigned
|
|  finish_item(req)
|------------------------------+
|                              |
|                         Sequencer
|                              |
|                              v
|                       Driver gets req
|                              |
|                              v
|                       Driver drives bus
|                              |
|                              v
|                       DUT accepts write
|                              |
|                              v
|                       item_done()
|                              |
+------------------------------+
|
v
Sequence can continue

This timeline is useful when debugging a test that appears to "hang" in the middle of a sequence.

Step 13: Multiple transactions

Consider a sequence that sends three transactions:

repeat (3) begin

req = bus_transaction::type_id::create("req");

start_item(req);

if (!req.randomize()) begin
    `uvm_fatal("RANDFAIL", "Randomization failed")
end

finish_item(req);


end

The conceptual flow is:

Transaction 1
 |
 v


Sequencer
|
v
Driver
|
item_done()
|
v
Transaction 2
|
v
Sequencer
|
v
Driver
|
item_done()
|
v
Transaction 3
|
v
Sequencer
|
v
Driver
|
item_done()

This is why the handshake is important for ordered transaction flow.

Step 14: What happens when the driver is slower?

A driver may take many clock cycles to process a transaction.

For example:

Sequence:
write A
write B
write C


Driver:
receives A
drives A for 5 cycles
completes A
receives B
drives B for 8 cycles
completes B
receives C

The sequence does not need to manually calculate those driver timing details.

The driver implements the protocol and the handshake provides the transaction-level synchronization.

Step 15: Common handshake mistakes

Mistake 1: Forgetting item_done()

The driver receives and drives an item but never reports completion. Later sequence activity may stop unexpectedly.

Mistake 2: Calling item_done() too early

seq_item_port.get_next_item(req);


seq_item_port.item_done();

drive_transaction(req);

This can incorrectly indicate completion before the driver has actually finished processing the transaction.

Mistake 3: Skipping the sequence-item handshake

Do not treat a sequence as a direct function call into the driver. Use the UVM sequence/sequencer mechanism.

Mistake 4: Confusing finish_item() with DUT completion

finish_item() completes the sequence-side item operation. It does not mean the DUT has accepted the transaction.

Mistake 5: Forgetting the sequencer-driver connection

If the sequencer and driver are not connected, the driver may wait forever for an item that cannot reach it.

Mistake 6: Driver waits for an impossible protocol condition

The handshake can be correct while the driver itself waits forever for a DUT response that never occurs. Always distinguish a UVM handshake problem from a DUT protocol problem.

Step 16: Debug a sequence that hangs

Suppose a sequence sends transaction 1 successfully but never reaches transaction 2.

Trace the transaction lifecycle:

  1. Did transaction 1 get created?
  2. Did start_item() execute?
  3. Did the item get randomized or assigned correctly?
  4. Did finish_item() execute?
  5. Did the sequencer deliver the item?
  6. Did the driver return from get_next_item()?
  7. Did the driver drive the transaction?
  8. Did the DUT reach its expected completion condition?
  9. Did the driver call item_done()?
  10. Did the sequence proceed to transaction 2?

Add temporary messages at important points:

`uvm_info("SEQ",
       "Before start_item",
       UVM_MEDIUM)


`uvm_info("SEQ",
"Before finish_item",
UVM_MEDIUM)

`uvm_info("DRV",
"Driver received item",
UVM_MEDIUM)

`uvm_info("DRV",
"Driver completed item",
UVM_MEDIUM)

If you see "Driver completed item" but never see the next sequence message, investigate the sequence/sequencer handshake.

If you never see "Driver received item," investigate the sequence, sequencer, and connection.

If you see "Driver received item" but never see "Driver completed item," investigate the driver and DUT protocol.

Step 17: Handshake versus protocol timing

There are actually two different forms of coordination happening.

Coordination Purpose
UVM sequence-driver handshake Transfers and completes sequence items.
DUT protocol handshake Controls actual interface behavior between driver and DUT.

For example:

UVM side:


get_next_item()
|
v
driver receives transaction
|
v
DUT side:

valid = 1
|
v
wait for ready
|
v
transaction accepted
|
v
UVM side:

item_done()

Keeping these two layers separate makes driver debugging much easier.

Step 18: Complete architecture

At this point, the entire stimulus path should look familiar:

                UVM

   +-------------------+
   |      Sequence     |
   |                   |
   | start_item()      |
   | finish_item()     |
   +---------+---------+
             |
             v
   +-------------------+
   |     Sequencer     |
   |                   |
   | manages item flow |
   +---------+---------+
             |
             v
   +-------------------+
   |      Driver       |
   |                   |
   | get_next_item()   |
   | drive DUT         |
   | item_done()       |
   +---------+---------+
             |
             v

          DUT

This architecture allows each layer to remain focused on one job.

Core mental model: Sequence generates. Sequencer manages. Driver consumes. The driver then reports completion through the handshake.

Try it yourself

Build and trace a three-transaction sequence-driver handshake.

  1. Create a bus_transaction.
  2. Create a sequence that generates three transactions.
  3. Use start_item() and finish_item().
  4. Create a sequencer for the transaction type.
  5. Connect the sequencer to the driver.
  6. Use get_next_item() in the driver.
  7. Have the driver print the transaction it receives.
  8. Call item_done() after the driver finishes processing each item.
  9. Verify that all three transactions reach the driver in the expected order.
Challenge: Intentionally comment out item_done(). Observe where the sequence stops progressing. Restore item_done(), then intentionally make the driver wait for a DUT completion condition that never occurs. Compare the two failure modes and identify which side of the verification architecture is responsible for each hang.

Key takeaways

  • The sequence-driver handshake controls sequence-item transfer between sequences and drivers.
  • start_item() and finish_item() are used on the sequence side.
  • get_next_item() and item_done() are used on the driver side.
  • The sequencer manages communication between sequences and the driver.
  • finish_item() does not mean that the DUT has completed the transaction.
  • The driver should normally call item_done() after it has completed processing the current item.
  • Protocol timing belongs in the driver, while scenario intent belongs in the sequence.
  • UVM handshake behavior and DUT protocol handshakes are separate concepts.
  • A missing or premature item_done() can cause confusing sequence stalls.
  • When a sequence hangs, trace the transaction from sequence → sequencer → driver → DUT → completion.