ptang Posted May 12, 2011 Report Posted May 12, 2011 Hi, 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. Thanks, Pinh Quote
jadec Posted May 12, 2011 Report Posted May 12, 2011 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. Quote
krb Posted May 12, 2011 Report Posted May 12, 2011 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. Quote
omer_e Posted December 12, 2011 Report Posted December 12, 2011 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. Omer Quote
jadec Posted December 12, 2011 Report Posted December 12, 2011 You need to mark the fields with UVM_NOPACK if you want them to not to be automatically packed. Quote
omer_e Posted December 12, 2011 Report Posted December 12, 2011 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 Quote
arno Posted December 12, 2011 Report Posted December 12, 2011 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. : xx.set_file_selector(10'b01101_01011); s=xx.convert2string(); xx.set_file_selector(10'b1111_1011); s=xx.convert2string(); xx.set_file_selector(10'b1111_1011); c=xx.do_compare(yy); ... 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. Quote
uwes Posted December 13, 2011 Report Posted December 13, 2011 hi, why dont you implement your own uvm-comparer and pass it in when you compare()? Quote
omer_e Posted December 14, 2011 Report Posted December 14, 2011 i can, but with the field_utils macros it is allot easier, mainly for packet communication. i've decided to abandon the ABSTRACT and PHYSICAL macros and use the regular ones and each user will decide which method to use and how. thanks for the answers Quote
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.