Jump to content

Recommended Posts

Posted

I am trying to pass a trigger-specific information to my testbench. My triggers work correctly, but I am unable to get data using wait_trigger_data.

 

I extended "event_object" from UVM_OBJECT, but when I try to capture it in wait_trigger_data, I get error  ”Types are not assignment compatible”.

 

/testcases/tests/test_dsp.svh(87): Arg. 'data' of 'wait_ptrigger_data':  Illegal assignment to type 'class dsp_cfg_pkg.event_object' from type 'class uvm_pkg.uvm_object': Types are not assignment compatible.

 

=========================================================

class event_object extends uvm_object;

  `uvm_object_utils(event_object)

   bit [10:0]            addr;

   int                        pos;

endclass : event_object

 

===========================================================

in my test:

 

event_object        event_object_h;

..

event_object_h    = event_object::type_id::create("event_object_h", null);

..

tm_clk_ev.wait_ptrigger_data(event_object_h);

 

================================================================

in module:

 

uvm_event     tm_clk_ev;

event_object event_object_h;

..

event_object_h    = event_object::type_id::create("event_object_h");

 

event_object_h.addr = a;

event_object_h.pos  = corrupt_bit;

tm_clk_ev.trigger(event_object_h);

              

Posted

You're trying to assign a handle of base class type to a handle of derived class type, which isn't allowed in SV.

 

You need to create a uvm_object temp variable, then do an explicit dynamic cast, e.g.

event_object        event_object_h;
uvm_object          temp_obj;

..

event_object_h    = event_object::type_id::create("event_object_h", null);

..

tm_clk_ev.wait_ptrigger_data(temp_obj);

assert ( $cast, event_object_h, temp_obj) else
   `uvm_error("TB", "Dynamic cast failed")


Posted

Thanks Alan. I previously attempted to use your approach, but I mistakenly thought that I need to create/construct an object before I can use it (temp_obj =new()) which is obviously not allowed on abstract classes.

In your example, why am I allowed to use a 'null' value for a class reference handle to temp_object without creating it in the first place with temp_obj=new()?

 

The alternative solution which eliminates a need for the base uvm_object class is the following:

==================================

event_object event_object_h;
..
event_object_h = event_object::type_id::create("event_object_h", null);

tm_clk_ev.wait_trigger;

$cast(event_object_h, tm_clk_ev.get_trigger_data());
 

Posted

A handle can contain a null value. Of course if you try to use it you'll get some kind of "bad reference" error from your simulator :-)

 

A simple example could be

class C;
   int a;
   function new(int a = 10);
      this.a = a;
   endfunction
endclass : C

module m;
    C h1;
    C h2;
    
    initial begin
        // h1 and h2 are both null
        h1 = new(20);  // h1 refers to an object, h2 is null
        h2 = h1;       // h2 and h1 both refer to the same object
        h1 = null;     // now h1 is null...
    end
endmodule : m


However in the code I posted, it gets filled in by a non-null value when wait_ptrigger_data is called of course.

 

I guess my naming was inconsistent with yours - I should have called it temp_obj_h.

 

In your code, if you could have created a uvm_object, the handle would just have got overwritten when you called wait_ptrigger_data - and the original object you created would have been cleaned up by the garbage collector,

 

regards

Alan

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...