////------------------------------------------------------------------------------classuvm_comparer;// Variable: policy//// Determines whether comparison is UVM_DEEP, UVM_REFERENCE, or UVM_SHALLOW.uvm_recursion_policy_enumpolicy=UVM_DEFAULT_POLICY;// Variable: show_max//// Sets the maximum number of messages to send to the printer for miscompares// of an object. intunsignedshow_max=1;
// small integers, less than or equal to 64 bits. It is automatically called// by <compare_field> if the operand size is less than or equal to 64.virtualfunctionbitcompare_field_int(stringname,uvm_integral_tlhs,uvm_integral_trhs,intsize,uvm_radix_enumradix=UVM_NORADIX);logic[63:0]mask;stringmsg;mask=-1;mask>>=(64-size);if((lhs&mask)!==(rhs&mask))beginuvm_object::__m_uvm_status_container.scope.set_arg(name);case(radix)UVM_BIN:begin$swrite(msg,"lhs = 'b%0b : rhs = 'b%0b",lhs&mask,rhs&mask);
// is printed to standard-out using the current verbosity and severity// settings. See the <verbosity> and <sev> variables for more information.functionvoidprint_msg(stringmsg);uvm_rootroot;uvm_coreservice_tcs;cs=uvm_coreservice_t::get();root=cs.get_root();result++;if(result<=show_max)beginmsg={"Miscompare for ",uvm_object::__m_uvm_status_container.scope.get(),": ",msg};root.uvm_report(sev,"MISCMP",msg,verbosity,`uvm_file,`uvm_line);endmiscompares={miscompares,uvm_object::__m_uvm_status_container.scope.get(),": ",msg,"\n"};endfunction
// ------------//Need this function because sformat doesn't support objectsfunctionvoidprint_rollup(uvm_objectrhs,uvm_objectlhs);uvm_rootroot;uvm_coreservice_tcs;stringmsg;cs=uvm_coreservice_t::get();root=cs.get_root();if(uvm_object::__m_uvm_status_container.scope.depth()==0)beginif(result&&(show_max||(uvm_severity'(sev)!=UVM_INFO)))beginif(show_max<result)$swrite(msg,"%0d Miscompare(s) (%0d shown) for object ",result,show_max);elsebegin$swrite(msg,"%0d Miscompare(s) for object ",result);end
done=1;//don't do any more work after this case, but do cleanupendif(!done&&comparer.check_type&&(rhs!=null)&&(get_type_name()!=rhs.get_type_name()))begin__m_uvm_status_container.stringv={"lhs type = \"",get_type_name(),"\" : rhs type = \"",rhs.get_type_name(),"\""};comparer.print_msg(__m_uvm_status_container.stringv);endif(!done)begincomparer.compare_map[rhs]=this;__m_uvm_field_automation(rhs,UVM_COMPARE,"");dc=do_compare(rhs,comparer);endif(__m_uvm_status_container.scope.depth()==1)begin__m_uvm_status_container.scope.up();end
//------------------------------------------------------------------------------// @uvm-ieee 1800.2-2020 auto 16.3.1classuvm_comparerextendsuvm_policy;// @uvm-ieee 1800.2-2020 auto 16.3.2.3`uvm_object_utils(uvm_comparer)// @uvm-ieee 1800.2-2020 auto 16.3.2.2externvirtualfunctionvoidflush();// @uvm-ieee 1800.2-2020 auto 16.3.3.5externvirtualfunctionuvm_policy::recursion_state_eobject_compared(uvm_objectlhs,uvm_objectrhs,uvm_recursion_policy_enumrecursion,outputbitret_val);
// by <compare_field> if the operand size is less than or equal to 64.// @uvm-ieee 1800.2-2020 auto 16.3.3.2virtualfunctionbitcompare_field_int(stringname,uvm_integral_tlhs,uvm_integral_trhs,intsize,uvm_radix_enumradix=UVM_NORADIX);logic[63:0]mask;stringmsg;if(size>64)begin`uvm_error("UVM/COMPARER/INT/BAD_SIZE",$sformatf("compare_field_int cannot be called with operand size of more than 64 bits. Input argument size=%0d",size))return0;endmask=-1;mask>>=(64-size);if((lhs&mask)!==(rhs&mask))begincase(radix)UVM_BIN:begin$swrite(msg,"%s: lhs = 'b%0b : rhs = 'b%0b",name,lhs&mask,rhs&mask);endUVM_OCT:begin$swrite(msg,"%s: lhs = 'o%0o : rhs = 'o%0o",name,lhs&mask,rhs&mask);end
// Check typename// Implemented as if Mantis 6602 was acceptedif(get_check_type()&&(lhs.get_object_type()!=rhs.get_object_type()))beginif(lhs.get_type_name()!=rhs.get_type_name())beginprint_msg({"type: lhs = \"",lhs.get_type_name(),"\" : rhs = \"",rhs.get_type_name(),"\""});endelsebeginprint_msg({"get_object_type() for ",lhs.get_name()," does not match get_object_type() for ",rhs.get_name()});endendfield_op=uvm_field_op::m_get_available_op();field_op.set(UVM_COMPARE,this,rhs);lhs.do_execute_op(field_op);if(field_op.user_hook_enabled())beginret_val=lhs.do_compare(rhs,this);endfield_op.m_recycle();
// settings. See the <verbosity> and <sev> variables for more information.// @uvm-ieee 1800.2-2020 auto 16.3.3.7functionvoidprint_msg(stringmsg);stringtmp=m_current_context(msg);result++;if((get_show_max()==0)||(get_result()<=get_show_max()))beginmsg={"Miscompare for ",tmp};uvm_pkg::uvm_report(sev,"MISCMP",msg,get_verbosity(),`uvm_file,`uvm_line);endmiscompares={miscompares,tmp,"\n"};endfunction// Internal methods - do not call directly// print_msg_object// ----------------functionvoidprint_msg_object(uvm_objectlhs,uvm_objectrhs);