$time in sequence

Hi,
I want to find the time between start_item and finish_item. can this be done?
I tried as below, but the this does not seem to work.

class simp_sequence extends uvm_sequence#(simp_seq_item);

  `uvm_object_utils(simp_sequence)

  // Declare handles for agent sequence item/transaction
  simp_seq_item req;
  bit  read;
  time start_time;
  time finish_time;
  time diff_time;
  /////////////////////////////////////////////////////////////////////////////////////////////////
  // New function
  function new(string name = "simp_sequence");
    super.new(name);
  endfunction: new

  /////////////////////////////////////////////////////////////////////////////////////////////////
  // Body
  task body();
   
    start_time = $time;
    // Keep reading the status register till READY bit is high
    do begin
      `uvm_do(req);
      read = req.read;
    end
    while(read != 1'b1);
    finish_time = $time;
   
    diff_time = finish_time - start_time;
    if (diff_time < 20ms )begin
      `uvm_info("SEQUENCE","Read complete within time",UVM_LOW);
    end else 
      `uvm_error("SEQUENCE","Read failed");
  endtask: body

endclass: simp_sequence

No display is displayed in the log.
Can i use time in sequence???

In reply to manasa-n:

You need to explain what “does not seem to work” means. What values are you getting for start_time and finish_time?

You might try using real variables and $realtime instead.

In reply to dave_59:

Hi Dave,
It worked with $realtime.
Thank you