Hi ,
I am facing an issue with .compare method, where compare between two objects of the same parameterized class but different parameter values with different data inside return success always.
EXAMPLE :
class trans #(parameter type T=bit) extends uvm_sequence_item;
rand bit[T:0] data;
`uvm_object_param_utils_begin(trans#(T))
`uvm_field_int(data, UVM_DEFAULT)
`uvm_object_utils_end
function new(string name=””);
super.new(name);
endfunction
function void post_randomize();
uvm_report_info(get_name(),$sformatf(“data randomized = %0d”,data),UVM_LOW);
endfunction
// User compare hook
function bit do_compare(uvm_object rhs, uvm_comparer comparer);
bit status = 1'b1;
trans that;
if(!$cast(that, rhs)) begin
status = 1'b0;
end else begin
// Custom compare method is returning 1.
status &= comparer.compare_object("item", this, that);
end
return(status);
end function : do_compare
endclass
TEST :
class test extends uvm_component;
`uvm_component_utils(test)
function new(string name, uvm_component parent);
super.new(name,parent);
endfunction
task run_phase(uvm_phase phase);
pkt#(8) d1;
pkt#(9) d2;
d1 = new(“d1”);
d2 = new(“d2”);
void'(d1.randomize());
void'(d2.randomize());
if(d1.compare(d2)) begin
`uvm_info(“CMP”,$sformatf(“COMPARE SUCESS”),UVM_HIGH)
end
else begin
`uvm_info(“CMP”,$sformatf(“COMPARE Failed”),UVM_HIGH)
end
endtask
endclass
I am getting output as always COMPARE success even though the data is different.
I implemented do_compare hook also to compare classes manually by using compare_object, but the status is same (its returing 1).
status &= comparer.compare_object("item", this, that);
Please help .
I found an article regarding this issue , :
https://asic4u.wordpress.com/2018/07/27/uvm-ovm-yet-another-compare-issue/#more-1972
In to the article it mentions UVM committee is fixed the issue.