I am using uvm do_compare for user-defined comparison .I have some fields which are not to be compared .But its failing

Hi ,

I saw the Your text to link here… link for using do_compare.

I am trying to use do_compare and I have a requirement that 1 field in the packet to be compared is a structure but I just need to compare 2 fields in the struct and mask 1 field.Is it possible to do it.
I tried the below code and it fails since the value of depth_cmp_mode is not equal for the predicted and collected output.
Even if I comment the line

//eq&=(idec_utre_sb0[3:0]==tr.idec_utre_sb0[3:0]);
      //eq&=(idec_utre_sb0[7]==tr.idec_utre_sb0[7]);

still the code fails with the error.I am not clear why the code fails though the idec_utre_scissor is exactly same.

typedef struct packed {
          logic depth_write_disable;
          logic[2:0] depth_cmp_mode;
          logic[2:0] stencil_reference;
    }isp_facestate_struct;

    typedef struct packed {
          isp_facestate_struct facestate;
          logic dfb_enable_depth_test;
    }isp_sideband0_struct;

      typedef struct packed {
          logic[15:0] ymax;
    }isp_scissor_struct;

class definition:

 class isp_idec_utre_packet extends uvm_sequence_item;
 
     isp_scissor_struct idec_utre_scissor         ;
     isp_sideband0_struct idec_utre_sb0                ;
 
    `uvm_object_utils_begin(isp_idec_utre_packet)
       `uvm_field_int(idec_utre_scissor          , UVM_DEFAULT)
       `uvm_field_int(idec_utre_sb0             , UVM_DEFAULT)
     `uvm_object_utils_end
 
    function new(string name = "isp_idec_utre_packet");
       super.new(name);
    endfunction: new
 
     function bit do_compare(uvm_object rhs, uvm_comparer comparer);
        isp_idec_utre_packet tr;
        bit eq;

       if(!$cast(tr, rhs)) `uvm_fatal("isp_idec_utre_packet", "ILLEGAL do_compare() cast")
       eq = super.do_compare(rhs, comparer);

      eq&=(idec_utre_scissor==tr.idec_utre_scissor);
      eq&=(idec_utre_sb0[3:0]==tr.idec_utre_sb0[3:0]);
      eq&=(idec_utre_sb0[7]==tr.idec_utre_sb0[7]);

      return(eq);
   endfunction: do_compare

 endclass: isp_idec_utre_packet

In the scoreboard I am calling the compare function:

if (collected_packet.compare(predicted_packet)==0) begin
             report = {"Mismatch between collected and predicted idec utre packet\n",
             collected_packet.sprint(),predicted_packet.sprint()};
          `uvm_error("idec_utre_mismatch",report);
          end

In reply to geetika6:

Use “UVM_NOCOMPARE” in structure registration. Compare the fields of interest manually in “do_compare”.


       `uvm_field_int(idec_utre_scissor          , UVM_DEFAULT | UVM_NOCOMPARE)
       `uvm_field_int(idec_utre_sb0             , UVM_DEFAULT  | UVM_NOCOMPARE)
       //... 

In reply to sharvil111:

The recommended way is not to use field macros. You should overwrite the do_compare etc. functions. If you use the field macros and do a Manual overwrite of some of These functions, like do_compare. The overwritten implementation, i.e. that’s yours, will be used.

Thanks sharvil111.
Yes it works if I make it UVM_NOCOMPARE.

Chr_sue
I am doing manual override, but if the field macros are already present with UVM_DEFAULT then my code in do_compare finally still fails since it by defaults compares all the bits of that vector and not my implementation.
I think it fails because of the super.do_compare