Verification Methodology Forum - Powered by vBulletin
+ Reply to Thread
Results 1 to 2 of 2

Thread: usage of get_trigger_data()

  1. #1

    Default usage of get_trigger_data()

    Hi All,
    I am facing the following issue while using get_trigger_data() to get the data associated with the last trigger event.

    When I use get_trigger_data(), after wait_trigger(), I am getting the correct value of data. Now, I change the field of packet "data2.sfd =1". After this, I am again calling get_trigger_data() in other task. Then why the updated value of sfd is displayed? According to the functionality, get_trigger_data() should reflect the data associated with a last trigger event.

    I have tried the following code:

    Code:
    import ovm_pkg::*;
    `include "ovm_macros.svh"
    
    class packet extends ovm_sequence_item;
      rand bit [7:0] sfd;
      `ovm_object_utils_begin(packet)
        `ovm_field_int(sfd, OVM_ALL_ON)
      `ovm_object_utils_end
       function new (string name = "packet");
         super.new(name);
       endfunction : new
    endclass: packet
    
    class bfm_c extends ovm_driver;
       packet data1;
       packet data2;
       packet data3;
       ovm_object datax;
       ovm_object datax1;
       ovm_event ack_process;
      `ovm_component_utils(bfm_c)
    
      function new(string name ="", ovm_component parent);
         super.new(name, parent);
         ack_process  = new("ack");
         data1  = new("data1");
         data2  = new("data2");
         data3  = new("data3");
      endfunction
    
      task run;
        fork
         begin #1;
          ack_process.wait_trigger();
          datax = ack_process.get_trigger_data();
          $cast(data2,datax);
          $display("After wait data2.sfd=%d", data2.sfd); 
          data2.sfd=1;
         end
         begin #4;
          void'(data1.randomize());
          ack_process.trigger(data1);
         end
       join
       task_1();
      endtask
    
      task task_1;
      begin
        datax1 = ack_process.get_trigger_data();
        $cast(data3,datax1);
        $display("data3.sfd=%d", data3.sfd); 
      end
      endtask
    endclass : bfm_c
    
    module top;
      bfm_c e;
      initial begin e = new("bfm_c",null); run_test();
      end
    endmodule

    Is this the expected behaviour of get_trigger_data()? Please let me know about this.

    Thanks,
    Mital

  2. Default

    Hi Mital,

    ack_process.get_trigger_data() returns a class handle. $cast copies the class handle to your data2 variable. Anything you do to data2 is actually being done to the object you originally passed into the ovm_event via the call to trigger.

    If you want to modify data2 without changing the ovm_event data you should copy or clone the returned object, e.g.

    Code:
      $cast( data2,datax.clone() );
    Regards,
    Dave
    David Long
    Doulos
    http://www.doulos.com

+ Reply to Thread

Bookmarks

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts