RTL Studio Open IDE

Wiki SystemVerilog Classes and handles

Classes and handles

OOP objects for verification — new, handles, local and static.

A class is a verification object. A handle points at an instance. new() constructs; assignment copies the handle, not the object (unless you clone).

flowchart LR
  cls[class txn] --> newn["tr = new"]
  newn --> obj[object]
  h[handle tr] --> obj
class txn;
  rand bit [7:0] data;
  local int seq;
  static int issued;
  function new();
    issued++;
    seq = issued;
  endfunction
endclass

txn tr;
tr = new();

local hides members from outside the class. static is shared across instances. DUT RTL stays modules and structs — classes are TB / UVM.

Wrong vs right

Wrong — tr1 = tr2 expecting a deep copy of fields.

Right — tr1 = new tr2; or a copy() / clone() method (UVM copy).

See also