Explain the UVM sequence-sequencer-driver handshake mechanism, detailing…
Explain the UVM sequence-sequencer-driver handshake mechanism, detailing both the sequence-side ( start_item / finish_item ) and driver-side ( get_next_item / item_done ) steps with code.
Model answer
In UVM, a **sequence** generates a stream of transaction items ( uvm_sequence_item ) on a **sequencer**, which arbitrates and forwards each item to the **driver** using a synchronized handshake protocol. **1. Sequence-Side Operational Steps (inside body() ):** 1. **Create the transaction item** using the UVM factory ( txn = my_txn::type_id::create("txn") ). 2. **Call start_item(txn) **: Blocks until the sequencer grants arbitration to this sequence and the driver requests the next item via get_next_item() . 3. **Randomize the transaction** (late randomization, optionally with inline constraints) so constraints reflect the latest testbench state. 4. **Call finish_item(txn) **: Sends the randomized item to the driver and **blocks** until the driver signals completion by calling seq_item_port.item_done() . **2. Driver-Side Operational Steps (inside run_phase() ):** 1. **Declare a transaction handle** (or use the built-in req handle of uvm_driver #(REQ, RSP) ). 2. **Call seq_item_port.get_next_item(req) **: Blocks until a sequence reaches finish_item(txn) and a randomized request item is available from the sequencer. 3. **Drive the pin-level protocol** onto the DUT using the virtual interface ( vif ). 4. **Call seq_item_port.item_done() ** (or seq_item_port.item_done(rsp) if returning a response): A non-blocking call that unblocks the sequence's finish_item(txn) call and completes the handshake. **Sequence Code:** **Driver Code:**