Parameterizing a class

Hi:

I use the code snippet shown below in 5-6 test cases.

What changes every time, is the following:-

  1. Name of the “counter” variable.
  2. The “error string”, which is an argument for uvm_is_match.
  3. Name of “some_monitor”.

How do I parameterize derived_catcher_c to re-use it in my test cases?

Please explain.
Thank You!


   class derived_catcher_c extends base_catcher_c; 
      int counter;
      `name_constructor ( "derived_catcher_c" )
   
      `uvm_object_utils_begin ( derived_catcher_c )
         `uvm_field_int ( counter, UVM_DEFAULT )
      `uvm_object_utils_end
   
      function action_e catch(); 
         bit ok;
         string error_message; 
   
         error_message = get_message(); 
         ok = uvm_is_match ("*Look for this error string*", error_message);   
         if ( 
               get_severity() == UVM_ERROR   	&& 
               get_id()       == "some_monitor" && 
               ok             == 1
            )
         begin 
            this.counter++;
            set_severity (UVM_WARNING);
         end  
         return THROW;
   
      endfunction: catch 
   endclass: derived_catcher_c

In reply to new_to_uvm:

If you need to change the error_string or monitor id, you can change them using

 uvm_config_db #(string) (... 

or you can declare functions like

function set_error_string(string error_string);
function set_id_string(string id_string); 

In reply to new_to_uvm:

In which way you want to change the 3 things? And why do you have the name of the variable counter? Or do you mean the value of counter?
The config_db is only one idea.