SeanChou Posted September 29, 2010 Report Share Posted September 29, 2010 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 Quote Link to comment Share on other sites More sharing options...
uwes Posted September 29, 2010 Report Share Posted September 29, 2010 (edited) 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 October 1, 2010 by uwes Quote Link to comment Share on other sites More sharing options...
SeanChou Posted September 30, 2010 Author Report Share Posted September 30, 2010 Thanks you so much for the quick and comprehensive answer. Quote Link to comment Share on other sites More sharing options...
Recommended Posts
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.