UVM Coding Practice · Senior

Basic Sequence Body

start_item, finish_item, objections.

Interview prompt

Write a sequence that sends 10 randomized pkt items on a sequencer.

diagram
WHITEBOARD CHAIN

1. DECLARE    interfaces / types / ports you need
2. SKELETON   class extends + utils macro + key methods
3. MECHANISM  fill one critical method while narrating
4. PITFALL    name one bug juniors make on this pattern
5. TEST       how you would smoke-test the component

Reference sketch (≤40 lines)

systemverilog
class pkt_seq extends uvm_sequence #(pkt);
  `uvm_object_utils(pkt_seq)
  virtual task body();
    repeat (10) begin
      pkt req = pkt::type_id::create("req");
      start_item(req);
      assert(req.randomize());
      finish_item(req);
    end
  endtask
endclass

Buggy snippet — critique verbally

systemverilog
start_item(req);
req.addr = 5; // forgot randomize
finish_item(req);

Code lab drill

After reading, try Code lab exercise uvm-l8-int-basic-seq — topic reference: /topics/uvm/coding-practice/sequences/basic-sequence-body

Smoke test (5 minutes)

  • Run seq — 10 items on bus.

  • UVM transaction log count = 10.

Common pitfalls

  • No randomize.

  • Objection leak if test waits forever.

  • finish_item before drive completes if rsp required.