UVM message management

Keywords: Verilog microchip systemverilog

UVM message management

1, Foreword

A good verification system should have message management features, which are:

  • Print information in a standardized way
  • Filter (importance level) information
  • Print channel
    These features are supported in UVM, which provides a series of rich classes and methods to generate and filter messages:
  • Message method
  • Message processing
  • Message mechanism

2, Message method

  • In the UVM environment or outside the environment, as long as there is the introduction of uvm_pkg, you can print messages according to the severity and redundancy of messages through the following methods.
function void uvm_report_info(string id,string message,int verbosity=UVM_MEDIUM,string filename ="",int line=0);
function void uvm_report_warning(string id,string message,int verbosity=UVM_MEDIUM,string filename ="",int line=0);
function void uvm_report_error(string id,string message,int verbosity=UVM_LOW,string filename ="",int line=0);
function void uvm_report_fatal(string id,string message,int verbosity=UVM_NONE,string filename ="",int line=0);
  • The four message functions have several messages in common. They are severity, redundancy, message ID, message, file name and line number:
  • Severity: it can also be obtained from the function name itself. The four severity levels are UVM_INFO,UVM_WARNING,UVM_ERROR,UVM_FATAL. Different severity levels will also have different instructions in the printed messages. At the same time, the simulator handles messages with different severity levels differently. For example, for UVM_FATAL message, the simulation will stop by default.
  • Message ID: this ID can be any string used to mark information. This tag is printed together with the message itself, and different tags can also be used for message processing.
  • Message: the subject of the message text.
  • Redundancy: redundancy is directly related to filtering in message processing. If the redundancy setting is lower than the filter switch, the message will be printed, otherwise it will not be printed. However, whether the message will be printed or not has nothing to do with other measures taken on the message, such as simulation stop.
  • File name and line number: these messages are used to provide the file and line number where the message occurs. The user can use the default value, and the UVM background will automatically fill in their original file name and line number, and also output the file name and line number when printing.
  • Corresponding to each message is how to process these messages. Generally, the message processing method corresponds to the severity level of the message. If users have additional requirements, they can also modify the message processing method for each severity level.

    For messages with different severity levels, users can use the default message processing method
RedundancyMessage importance
UVM_NONERepresents the most important message
UVM_LOWIndicates a second most important message
UVM_MEDIUMIntermediate grade
UVM_HIGHNot so important
UVM_FULLDown in turn
UVM_DEBUGDown in turn

3, Message macro

  • If you want to customize the message processing method, you can use UVM_ report_ Configure the methods provided by the object class.
  • uvm_report_object class is between uvm_object class and UVM_ The intermediate class between component classes. Its main function is to complete message printing and management.
  • UVM also provides some macros to correspond to the above message methods, and users can also use these macros to process messages.
package uvm_message_pkg;
  import uvm_pkg::*;
  `include "uvm_macros.svh"
  
  class config_obj extends uvm_object;
    `uvm_object_utils(config_obj)
    function new(string name = "config_obj");
      super.new(name);
      `uvm_info("CREATE", $sformatf("config_obj type [%s] created", name), UVM_LOW)
    endfunction
  endclass
  
  class comp2 extends uvm_component;
    `uvm_component_utils(comp2)
    function new(string name = "comp2", uvm_component parent = null);
      super.new(name, parent);
      `uvm_info("CREATE", $sformatf("unit type [%s] created", name), UVM_LOW)
    endfunction
    function void build_phase(uvm_phase phase);
      super.build_phase(phase);
      `uvm_info("BUILD", "comp2 build phase entered", UVM_LOW)
      `uvm_info("BUILD", "comp2 build phase exited", UVM_LOW)
    endfunction
    task run_phase(uvm_phase phase);
      super.run_phase(phase);
      `uvm_info("RUN", "comp2 run phase entered", UVM_LOW)
      `uvm_info("RUN", "comp2 run phase exited", UVM_LOW)
    endtask
  endclass

  class comp1 extends uvm_component;
    `uvm_component_utils(comp1)
    function new(string name = "comp1", uvm_component parent = null);
      super.new(name, parent);
      `uvm_info("CREATE", $sformatf("unit type [%s] created", name), UVM_LOW)
    endfunction
    function void build_phase(uvm_phase phase);
      super.build_phase(phase);
      `uvm_info("BUILD", "comp1 build phase entered", UVM_LOW)
      `uvm_info("BUILD", "comp1 build phase exited", UVM_LOW)
    endfunction
    task run_phase(uvm_phase phase);
      super.run_phase(phase);
      `uvm_info("RUN", "comp1 run phase entered", UVM_LOW)
      `uvm_info("RUN", "comp1 run phase exited", UVM_LOW)
    endtask
  endclass

  class uvm_message_test extends uvm_test;
    config_obj cfg;
    comp1 c1;
    comp2 c2;
    `uvm_component_utils(uvm_message_test)
    function new(string name = "uvm_message_test", uvm_component parent = null);
      super.new(name, parent);
    endfunction
    function void build_phase(uvm_phase phase);
      super.build_phase(phase);
      `uvm_info("BUILD", "uvm_message_test build phase entered", UVM_LOW)
      cfg = config_obj::type_id::create("cfg");
      c1 = comp1::type_id::create("c1", this);
      c2 = comp2::type_id::create("c2", this);

     
      // set_report_id_verbosity_hier("BUILD", UVM_NONE);
      // set_report_id_verbosity_hier("CREATE", UVM_NONE);
      // set_report_id_verbosity_hier("RUN", UVM_NONE);
      
      // uvm_root::get().set_report_id_verbosity_hier("CREATE", UVM_NONE);
      // uvm_root::get().set_report_id_verbosity_hier("BUILD", UVM_NONE);
      // uvm_root::get().set_report_id_verbosity_hier("RUN", UVM_NONE);
      `uvm_info("BUILD", "uvm_message_test build phase exited", UVM_LOW)
    endfunction
    function void end_of_elaboration_phase(uvm_phase phase);
      //set_report_id_verbosity_hier("BUILD", UVM_NONE);
      //set_report_id_verbosity_hier("CREATE", UVM_NONE);
      //set_report_id_verbosity_hier("RUN", UVM_NONE);
    endfunction

    task run_phase(uvm_phase phase);
      super.run_phase(phase);
      `uvm_info("RUN", "uvm_message_test run phase entered", UVM_LOW)
      phase.raise_objection(this);
      phase.drop_objection(this);
      `uvm_info("RUN", "uvm_message_test run phase exited", UVM_LOW)
    endtask
  endclass
endpackage

module uvm_message_ref;

  import uvm_pkg::*;
  `include "uvm_macros.svh"
  import uvm_message_pkg::*;
  
  initial begin
    uvm_root::get().set_report_id_verbosity_hier("TOPTB", UVM_NONE);
    uvm_root::get().set_report_verbosity_level_hier(UVM_NONE);
    `uvm_info("TOPTB", "RUN TEST entered", UVM_LOW)
    run_test(""); // empty test name
    `uvm_info("TOPTB", "RUN TEST exited", UVM_LOW)
  end

endmodule

Where, set_report_id_verbosity_hier(“ID”, UVM_NONE); Filter the redundancy of a message ID,
set_report_verbosity_level_hier(UVM_NONE); Filter the redundancy of all types of ID messages.

4, Message mechanism

  • Message processing is performed by uvm_report_handler class, and each UVM_ report_ There is a UVM in the object class_ report_ Handler instance.
  • UVM above_ report_ Object message processing method or uvm_component message processing methods are for these uvms_ report_ Configuration made by handler.
  • In addition to the above common usage methods, users can also make more advanced message control. For example, when UVM_ After error occurs, the simulation stops by default because UVM is set_ Error is handled by UVM_ When the number of counts reaches the upper limit (the default is 1), the simulation stops. You can use set_max_quit_count to modify the UVM_COUNT value.

5, Callback function

  • When message users want to do additional processing when processing information, the callback function is very necessary, UVM_ report_ The object class provides the following callback functions to meet more user needs:
function bit report_hook(string id,string message,int verbosity,string filename,int line);
function bit report_info_hook(string id,string message,int verbosity,string filename,int line);
function bit report_warning_hook(string id,string message,int verbosity,string filename,int line);
function bit report_error_hook(string id,string message,int verbosity,string filename,int line);
function bit report_fatal_hook(string id,string message,int verbosity,string filename,int line);
  • report_ The hook () function combines the UVM in message management_ CALL_ Hook parameter, combined with user-defined callback function, can realize richer configuration.
  • In this way, when calling the callback function, the user will first call report_hook() function, and then select the more detailed callback function report according to the severity level_ SEVERITY_ hook().
  • By default, report_ The return value of the hook () function is 1, and then it is transferred to the severity hook function.
  • If Report_ If the hook () function is user-defined and returns 0, the subsequent report_ SEVERITY_ The hook () function does not execute.

  • Except for every UVM_ report_ There is a built-in UVM in the object_ report_ All UVM except handler instance_ report_ Handler instances also depend on UVM_ UVM IN PKG_ report_ The only instance of server, but this instance is not directly exposed to the user as a global variable. The user needs to call UVM by himself_ report_ server::get_ Server () method.
  • uvm_report_server is a global message processing device used to process messages from all uvms_ report_ The message generated in the handler. All of this unique report server are not exposed to UVM_ One reason why PKG is used by users is the way messages are processed.
  • Focus on the author

  • Readme
    The author is a graduate student majoring in digital design at China University of science and technology. His level is limited. If there are mistakes, please correct them and want to make progress with you.
  • experience
    He has won the national scholarship, "Higher Education Society Cup" mathematical modeling national second prize
  • Update in succession:
    1. Follow up content of system verilog related to UVM verification;
    2. Some basic module designs related to verilog digital design, such as FIFO, UART, I2C, etc.
    3. Research guarantee and competition experience, etc
  • WeChat official account
    Welcome to the official account of "the daily practice of digital IC Xiao Bai". We look forward to fighting with you to travel around the digital IC world.

Posted by fitchn on Thu, 11 Nov 2021 18:57:34 -0800