Compensating for different timeunits between SystemVerilog packages

There’s also a uvm_tlm2_time class that could probably help you here. You’d need to have a config field inside your UVC which tells it what the global precision is:


class uvc_config;
  enum { PS, NS } resolution;

  function time get_cur_time();
    uvm_tlm2_time t = new();
    return get_realtime($time(), resolution == PS : 1.0e-12 ? 1.0e-9;
  endfunction
endclass


class some_component;
  task some_task();
    // do stuff
    begin_tr(..., .begin_time(cfg.get_cur_time()));
  endtask
endclass

DISCLAIMER: I haven’t tested the code and it’s sure to have some problems, but you could probably use it as a starting point.