Jump to content

compare() method with kind option?

Recommended Posts


In UVM, is there anything in the uvm_object::compare method or uvm_comparer policy to implement a different comparison similar to the VMM compare() kind argument? For example, I would like a mechanism to be able to select between doing a full compare of all object members or a partial subset compare.



Link to comment
Share on other sites

The comparer does have an "abstract" and "physical" fields which can be used to select between full compare and those specific subsets. You can add UVM_PHYSICAL or UVM_ABSTRACT attributes to your field macros and the generated comparer will honor the abstract and physical settings of the policy object.

Link to comment
Share on other sites

Hi ptang,

I was faced with a similar situation before, in that I had to compare a few member of the seq_item. So I wrote my own comparison:

compare_values &= comparer.compare_field("field1", tx_impl_lhs.f1, tx_ref_rhs.f1, $bits(tx_impl_lhs.f1));

where comparer is an instance of uvm_comparer.

Look for uvm_comparer and do_compare in uvm ref doc.

Link to comment
Share on other sites

  • 6 months later...

hello all

for comparing packets with changing layers the physical and abstract feature looks delicious

i see that in the policy classes, that if you use ABSTRACT macro for a field it will not be participating neither in the compare() nor the pack()/unpack() methods, and the PHYSICAL field will participate in those methods.

great! :)

well, not so great: :(

i expected that when i will implement my own pack/unpack functionality with the do_pack and do_unpack methods the basic pack and unpack will be overrun. they're not!

it will pack both the basic pack and my own do_pack method, causing fields to be packed/unpacked twice...

i would expect to at least an option to tell the UVM - don't pack and unpack, just do what i tell you in the do_pack() and do_unpack() methods and that's it.

so i really don't have a solution for this problem, as i have only 2 options: ABSTRACT and PHYSICAL.

if i will choose PHYSICAL some fields will be doubled in the pack method as i implement the do_ methods, and if i choose ABSTRACT the comparer will not include the fields in the compare...

if i will change the packer policy class that physical fields will not get packed (which i don't know how to do that, any help will be welcomed) i will not have the option of using the basic pack()/unpack() method when i see that they are sufficient.

thanks for listening,

will appreciate a good answer to my problems.


Link to comment
Share on other sites

this is indeed the solution - neglecting the ABSTRACT and PHYSICAL macros and using the other ones - UVM_NOPACK, UVM_NOCOMPARE and etc.

i was looking for a solution that will allow me to use ONLY these two, i guess that there isn't any way, unless UVM update will have some way to disable the basic pack/unpack through the do_pack/do_unpack methods

Link to comment
Share on other sites

UVM doesn't implement a mechanism to select which fields to print / compare / ...

What I do to handle repetitive compare/print is use a int as field selector.

eg. :







... etc ...

Not super elegant, but it saves a lot of coding.

The automation macros could probably be modified to add this without too much trouble.

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.

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