Jump to content

how to constraint if the same filed name between uvm_do_with caller and callee?


Recommended Posts

All,

Although it could be solved by changing to other names, but still hope there would be a better solution. any idea please share with me and thanks!

class caller extends uvm_sequence;

task body();

int abc = 5; // line 3

`uvm_do_with ( callee, { abc == this.abc} ) // both abc this line are not the one in line 3.

endtask

endclass

Link to comment
Share on other sites

hi sean,

this is a typical sv problem with 1800-2005. the resolution of variables within constraints is inner scope first then outer scope. this means that if a member is found within the object to generate this field is referenced. this means that "abc" is actually the same as "this.abc" which is equivalent to "callee.abc". so using "this." doesnt make sense.

in total you got three solutions:

#1 you rename the field

#2 you can use ieee1800-2009 syntax if that is supported using the "local::"

retval = inner.randomize() with { local::value == value;};

#3 you may use the class scope operator

retval = inner.randomize() with { outer_c::value == value;};

for your example it would mean:

#1 `uvm_do_with ( callee, { abc == abc_temp} )

#2 `uvm_do_with ( callee, { abc == local::abc} )

#3 `uvm_do_with ( callee, { abc == caller::abc} )

PS: actually the 1800-2009 LRM 18.7 states:

>Names qualified by "this" or "super" shall bind to the class of the object handle used in the call to the randomize() with method.

this means that

retval = inner.randomize() with { this.value == value;}

retval = inner.randomize() with { super.value == value;}

should work in as you expected earlier. so it is a semantic difference between the -2005 and -2009 LRM what you will will see as the result.

regards

/uwe

Edited by uwes
Link to comment
Share on other sites

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...