Uvm_report_catcher - tricky question

    function action_e catch(); 

      if ( 
            get_severity() == UVM_ERROR && 
            get_id() == "some_mon"
         )
      begin 
         `uvm_info (this.get_name(), $sformatf ("Downgrading to UVM_WARNING."), UVM_LOW);
         set_severity (UVM_WARNING);
      end  
      return THROW;
   endfunction: catch 

Assume some_mon_c.sv has the following lines:-

  1. `uvm_error (this.get_name(), $sformatf(“ABCD”));
  2. `uvm_error (this.get_name(), $sformatf(“EFGH”));

I wish to downgrade only those error messages containing the string “ABCD”. The error messages containing the string “EFGH” should remain error messages.

Is there any way to do this? In this case, get_id() isn’t useful.
Please let me know.

Thank You!

In reply to new_to_uvm:

My bad.
I did not read the class reference manual carefully.
I have to use get_message() in addition to get_id().

Not at all tricky!

Hello,
you can use get_message and uvm_is_match to track particular error message.
I have used it in my code.

example :

typedef string msg[0:2];
typedef string type_id[0:2];

class demoter#(type_id id,msg m) extends uvm_report_catcher;
  
  string str;
  string id1;
  
  function new(string name="new");
    super.new(name);
  endfunction

  
  function action_e catch();
      foreach(m[i])
          begin
            if(uvm_is_match(id[i],get_id()) && uvm_is_match({"*",m[i],"*"},get_message()))
                begin
                 // set_action(UVM_DISPLAY);  
                  if(id[i]!=""||m[i]!="")
                  return THROW; // it will throw whatever condition become true
                end
          end
    
        foreach(m[i])
          begin
            // this is to match whatever message given by array and print only those messages 
            if(uvm_is_match(id[i],get_id()) && uvm_is_match({"*",m[i],"*"},get_message()));
            else
               begin
                return CAUGHT;
               end
          end
  endfunction
  
endclass

module top;
  string id;
  string mesg;
  
  demoter #({"HELLO","","HELLO"},{"my","","my"})m1=new;
  
  initial begin
    uvm_report_cb::add(null, m1);
    `uvm_info("HELLO","This is my message",UVM_NONE)
    `uvm_info("INFO","This is my message",UVM_NONE)
    `uvm_info("HELLO","This is simple message",UVM_NONE)
    
  end
endmodule

Thank you

In reply to mansi.kelawala:

Very good. I’ll try using this.
Thank You Mansi!