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 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
uvm_severity (which is nothing but
uvm_severity_type (which is an
enum) in order to show a severity string (line 8). FYI, the
uvm_severity_type are defined in
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 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.