I have questions on UVM compare options. Here are my requirements:
- Basic seq_item has many packet fields.
Eg:
class my_seq_item extends uvm_sequence_item
rand bit [7:0] da;
rand bit [7:0] sa;
rand bit pkt_type;
rand bit [7:0] da_west;
rand bit [7:0] da_east;
rand bit [3:0] ctrl;
rand bit [3:0] source_id;
:
:
:
endclass
-
Based on pkt_type, the other fields of the packet are different.
We have do_pack method for that. -
I want to use object comparing in scoreboard comparator.
I have mentioned UVM_NOCOMPARE in utility/macros field(in my_seq_item) for all the fields.
I have customized do_compare method(in my_seq_item) as below(not the actual code):
virtual function bit do_compare(uvm_object rhs, uvm_comparer comparer);
mm_seq_item mm_pkt;
bit is_header_ok;
if (!$cast(mm_pkt, rhs))
`uvm_error (get_name(), "Casting failed")
case (pkt_type)
0: begin
is_header_ok == (super.do_compare(mm_pkt, comparer) &&
pkt_type == mm_pkt.pkt_type &&
da_west == mm_pkt.da_west &&
da_east == mm_pkt.da_east &&
ctrl == mm_pkt.ctrl&&
source_id == mm_pkt.source_id
) ;
end
1: begin
is_header_ok == (super.do_compare(mm_pkt, comparer) &&
pkt_type == mm_pkt.pkt_type &&
da == mm_pkt.da &&
sa == mm_pkt.sa &&
ctrl == mm_pkt.ctrl&&
source_id == mm_pkt.source_id
) ;
endcase
return (is_header_ok);
endfunction
is_header_ok is set if all the required fields match. If not, it indicates some fields are not matching. How do I print those fields effectively?
The above example is a sample. My actual code has around 10 pkt_type and each may have around 12-15 fields.
Can we use something like :
comparer.compare_field_int("Compare DA", da, mm_pkt.da, 8);
``` verilog
Will it print if I have set comparer severity, verbosity variables?
Or do i have to print manually. In that case, manual comparison/print is easier?
Any effective method?
TIA