Customizing UVM Message Format

Last Updated: September 24, 2013

This is the second article of the message formatting series. This article focuses on UVM. Please see Customizing OVM Message Format or Customizing VMM Message Format for using other methodologies.

One of the benefits of using the standard verification methodology such as UVM, is unified message formatting. Pre-defined format would ease the automatic search and post-processing of the messages. Although the default format is sufficient most of the time, customization of the format may be sometimes required to meet project-wide need, etc. A series of articles will be provided to show you the step-by-step instructions to customize the message formatting, namely for OVM, UVM and VMM. I used the UVM version 1.0p1 for this article.

Step 0 – Default Format

Before changing the message format, let’s look at how the default output looks using `uvm_info macros:

# UVM_INFO my_uvm_report.sv(83) @ 0: reporter [top] This is a message from top.
# UVM_INFO my_uvm_report.sv(68) @ 0: uvm_test_top [my_test] This is a message from my_test.
# UVM_INFO my_uvm_report.sv(39) @ 0: uvm_test_top.my_env_h [my_env] This is a message from my_env.

Step 1 – Define Your Format

The first step is defining your custom format. This is done by overriding the compose_message function of the uvm_report_server class. I created my_report_server class to define the compose_message function. This function constructs a string from severity, component name, report id, and message itself. Lines 9 and 10 define the actual formatting. Note that I casted severity from uvm_severity (which is nothing but bit[1:0]) to uvm_severity_type (which is an enum) in order to show a severity string (line 8). FYI, the uvm_severity and uvm_severity_type are defined in uvm-1.0p1/src/base/uvm_object_globals.svh.

1
2
3
4
5
6
7
8
9
10
11
12
class my_report_server extends uvm_report_server;
   virtual function string compose_message( uvm_severity severity,
                                            string name,
                                            string id,
                                            string message,
                                            string filename,
                                            int line );
      uvm_severity_type severity_type = uvm_severity_type'( severity );      return $psprintf( "%-8s | %16s | %2d | %0t | %-21s | %-7s | %s",             severity_type.name(), filename, line, $time, name, id, message );   endfunction: compose_message
endclass: my_report_server

Step 2 – Use Your Format

The second step is replacing the uvm_report_server with my_report_server. The uvm_report_server is a global server that processes all the reports generated by a uvm_report_handler, which in turn is the class to which most methods in uvm_report_object delegate. Unlike OVM, UVM has a method to set the global report server.

Here are my procedures to replace the server. Firstly, instantiate the my_report_server (line 4). Secondly, set my_server as the global report server using a static function of uvm_report_server (line 5). That’s it. I used the start_of_simulation() function of my_test class to change the formatting, but it is up to you where you do it.

1
2
3
4
5
6
7
class my_test extends uvm_test;
   // ...
   function void start_of_simulation();
      my_report_server my_server = new;      uvm_report_server::set_server( my_server );   endfunction: start_of_simulation
endclass: my_test

Step 3 – See Your New Format

Let’s see how the new output looks:

# UVM_INFO my_uvm_report.sv(83) @ 0: reporter [top] This is a message from top.
# UVM_INFO | my_uvm_report.sv | 68 | 0 | uvm_test_top          | my_test | This is a message from my_test.
# UVM_INFO | my_uvm_report.sv | 39 | 0 | uvm_test_top.my_env_h | my_env  | This is a message from my_env.

The first line still used the default format. This was because the message was displayed before the report server was replaced. This also demonstrates that a message format can be changed on the fly.

I hope this helps.

16 thoughts on “Customizing UVM Message Format”

  1. In my environment, the default message format is:
    # UVM_INFO /proj/proj_xxx/my/dv/tb/test.sv(38) @ 0: xxx, xxx
    how can I change the string filename from ‘/proj/proj_xxx/my/dv/tb/test.sv’ to ‘test.sv’ ?
    the filename with absolute file path is too long to display in one line.

    Thanks

    1. It’s not easy. If you use the messaging macros such as `uvm_info(), they use the `__FILE__ compiler directive to display the file name. The `__FILE__ is set by the simulator (compiler). If you can change the file names from the absolute path to the relative path when you compile, you might be able to get shorter names.

      If you `define UVM_REPORT_DISABLE_FILE, no file name will be displayed. But I think this is not what you want.

  2. extends a class from uvm_report_server, override the function compose_message .

    function string compose_message( umv_severity severity,
                                     string name,
                                     string id,
                                     string message,
                                     string filename,
                                     int line
                                   );
    string filename_;
    uvm_severity_type severity_ = uvm_severity_type'(severity);
    foreach(filename[i])
    begin
          if(filename[i] == "/")
               filename_ ="";
          else
               filename_={filename_,filename[i]};
    end
    return $psprintf("%s%t:%s(%d) : %s",severity_.name(),$time,filename_,line,message)
    endfunction 
    

    you can modify your message format with required spaces and tabs.

    1. How do you inherit ‘uvm_report_server’ which a abstract class containing a lot of ‘pure virtual’ methods with only single function overridden?

      1. Issue is closed.
        UVM 1.2 requires ‘uvm_default_report_server’ extending and ‘compose_report_message(..)’ method overriding.
        A lot of thanks.

  3. I used the same code, and got the below errors for virtual method not implemented.
    Error-[SV-VMNI] Virtual method not implemented
    /pkg/qct/software/dv_meth/uvm/uvm-1.2/release/src/base/uvm_report_server.svh, 60
    Virtual method ‘set_max_quit_count’ not implemented in class
    ‘my_report_server’ (declared in ../..//tb.sv, at line
    160).

    15 other errors for Virtual method not implemented

    Please help me fix this.

    TIA.

  4. Thanks a lot for all the well prepared and structured information!

    I just noticed that the Hyperlinks aren’t working anymore with your code! Could you please tell us, how we can put hyperlinks for the path and time as output in the console?

    Many thanks in advance.

      1. The hyperlinks uvm_info is generating, where you can click on the time in the console and waveform opens or when you click on the filename it shown in source browser. I’d like to have that function with a System Verilog standard print or display function too and not just with that uvm_info, so my question is how to get clickable Hyperlinks for filename to open in source browser and time to open a waveform at specific time?!

  5. Hi Keisuke

    I want to split out messages from some components into their own files. Can you please provide some example of how to do the same?

    Thanks
    – rajdeep

Leave a Reply