calvapete Posted October 25, 2011 Report Share Posted October 25, 2011 (edited) I'm trying to figure out a way to compare an item with it's superclass. using the uvm_in_order_class comparator. so I've overloaded the do_compare function in this manner. function bit do_compare(uvm_object rhs, uvm_comparer comparer); bit cast_good; SubClass _rhs; comparer.check_type = 0; //compare superclass fields do_compare = super.do_compare(rhs, comparer); //if types match, compare subclass fields. cast_good = $cast(_rhs, rhs); if (cast_good) begin do_compare &= comparer.compare_field("field_1", this.field_1, _rhs.field_1, $bits(field_1)); do_compare &= comparer.compare_field("field_2", this.field_2, _rhs.field_2, $bits(field_2)); ... end endfunction So the check_type field in comparer is meant to turn off the type checking, which it does. except in the first comparison. This appears to be due to the way (order) in which the compare function operates. If the comparer is null (which it seems to be, and I can't set it to a local comparer as it is set to null in the uvm_object class) it assigns the internal reference to uvm_default_comparer. It then does the type comparison, then calls so_compare (at which point the type comparison gets switched off). So what I'm looking for is a way to apply the comparer policy with check type switched off. But I can't see a way of applying this policy either in the object class or the comparator class. Google searching, just leads me to the comment "the user can then simply apply a different policy class." but there is no description of how. Any thoughts? Edited October 25, 2011 by calvapete mistake Quote Link to comment Share on other sites More sharing options...
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.