Featured post

Top 5 books to refer for a VHDL beginner

VHDL (VHSIC-HDL, Very High-Speed Integrated Circuit Hardware Description Language) is a hardware description language used in electronic des...

Saturday 22 October 2016

Build smart tests using uvm_report_catcher

Today we will look into a very useful concept of UVM specially when we are doing any erroneous testing. Its all about modifying the severity, id, action, verbosity or the report string itself before the report is finally issued by the report server. 

Normally in our test environment shout for error when any erroneous scenario like CRC error condition or generation of any error interrupt occurs. And we also write erroneous tests to test these scenarios where we end-up with error messages and tests fails. 

The uvm_report_catcher is used to catch messages issued by the uvm report server. Upon catching a report, the catch method can modify the severity, id, action, verbosity or the report string itself before the report is finally issued by the report server.  The report can be immediately issued from within the catcher class by calling the issue method.

The catcher maintains a count of all reports with FATAL, ERROR or WARNING severity and a count of all reports with FATAL, ERROR or WARNING severity whose severity was lowered.  These statistics are reported in the summary of the uvm_report_server.

Example: 

Report catcher class:
class error_report_catcher extends uvm_report_catcher;
  //new constructor
  virtual function action_e catch();
    if(get_severity() == UVM_ERROR && get_id() == "MON_CHK_NOT_VALID") begin
      set_severity(UVM_INFO);
      return CAUGHT;
    end
    else begin
      return THROW;
    end
  endfunction
endclass : error_report_catcher_c


Use of error catcher in testcase: 
class erroneous_test extends base_test_class;

  // report catcher to suppress errors
  error_report_catcher error_catcher ;
  /// \fn new_constructor
   
  /// \fn build_phase
virtual function void build_phase(uvm_phase phase);
    super.build_phase(phase);
      error_catcher = new();
      uvm_report_cb::add(null,error_catcher) ;
      uvm_config_db#(int)::set(this,“uvc.tx_agent","is_active",UVM_ACTIVE);
         
      // User configurations
      env_cfg.print();
      uvm_config_db#(env_config_c)::set(this, "*" , “env_cfg", env_cfg);
      // Calling the error sequence
      uvm_config_db#(uvm_object_wrapper)::set(this, “uvc.tx_agent.tx_sequencer.main_phase","default_sequence",valid_invalid_seq_c::type_id::get());
  endfunction : build_phase

endclass : erroneous_test