Customizing VMM Message Format

Last Updated: September 24, 2013

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

One of the benefits of using the standard verification methodology such as VMM, 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 VMM version 1.1.1a for this article. The reason I did not use the latest version (1.2.1) was simply because ModelSim-Altera Starter Edition, which I use, did not run right out of the box with the latest version.

Step 0 – Default Format

Before changing the message format, let’s look at how the default output looks. The default output using `vmm_note() shorthand macro, as well as using the standard vmm_log::start_msg(), vmm_log::text(), and vmm_log::end_msg() function calls look like this:

# Normal[NOTE] on my_xactor(xactor) at                    0:
#     This is a message from my_xactor using `vmm_note() macro.
# Normal[NOTE] on my_xactor(xactor) at                    0:
#     This is a message from my_xactor formatted by format_msg().
#     This is a message from my_xactor formatted by continue_msg().

VMM displays a header in a separate line by default. This makes message filtering with a simple grep more difficult, as a message body is not on the same line as its header.
The code used to output the above messages follows:

1
2
3
4
5
6
7
8
9
10
11
12
class my_xactor extends vmm_xactor;
   // ...
   virtual protected task main();
      super.main();
      `vmm_note( log, "This is a message from my_xactor using `vmm_note() macro." );
      log.start_msg( vmm_log::NOTE_TYP, vmm_log::DEFAULT_SEV );
      log.text( "This is a message from my_xactor formatted by format_msg()." );
      log.text( "" );
      log.text( "This is a message from my_xactor formatted by continue_msg()." );
      log.end_msg();
   endtask: main
endclass: my_xactor

Step 1 – Define Your Format

The first step is defining your custom format. This is done by overriding the format_msg() function and the continue_msg() function of vmm_log_format class. I created my_log_format class to define the functions. Lines 11 to 17 and lines 30 to 36 define the actual formatting. Note that VMM uses VMM_LOG_FORMAT_FILE_LINE macro as a switch to include the file name and the line number.

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
class my_log_format extends vmm_log_format;
   virtual function string format_msg( string name,
                                       string inst,
                                       string msg_typ,
                                       string severity,
`ifdef VMM_LOG_FORMAT_FILE_LINE
                                       string fname,
                                       int    line,
`endif
                                       ref string lines[$] );
      string msg = { $psprintf( "%-6s | ", severity ),`ifdef VMM_LOG_FORMAT_FILE_LINE                     $psprintf( "%16s | %3d | ", fname, line ),`endif                     $psprintf( "%0t | %-9s | %-6s | ", $time, name, inst ) };       for ( int i = 0; i < lines.size; i++ ) msg = { msg, lines[i], " " };      return msg;
   endfunction: format_msg
 
   virtual function string continue_msg( string name,
                                         string inst,
                                         string msg_typ,
                                         string severity,
`ifdef VMM_LOG_FORMAT_FILE_LINE
                                         string fname,
                                         int    line,
`endif
                                         ref string lines[$] );
      string msg = { $psprintf( "%-6s | ", severity ),`ifdef VMM_LOG_FORMAT_FILE_LINE                     $psprintf( "%16s | %3d | ", fname, line ),`endif                     $psprintf( "%0t | %-9s | %-6s | ", $time, name, inst ) };       for ( int i = 0; i < lines.size; i++ ) msg = { msg, lines[i], " " };      return msg;
   endfunction: continue_msg
endclass: my_log_format

Step 2 – Use Your Format

The second step is setting the new format to message service. Firstly, instantiate my_log_format (line 7). Secondly, set the my_log_format object to the message service (line 8). That’s it. I used my top module to change the formatting, but it is up to you where you do it.

1
2
3
4
5
6
7
8
9
10
11
module top;
   vmm_log log;
   my_log_format log_format;
   // ...
   initial begin
      log = new( "vmm_log", "log" );
      log_format = new;      log.set_format( log_format );      // ...
   end
endmodule: top

Step 3 – See Your New Format

Let’s see how the new output looks:

# Normal | 0 | my_xactor | xactor | This is a message from my_xactor using `vmm_note() macro.
# Normal | 0 | my_xactor | xactor | This is a message from my_xactor formatted by format_msg().
# Normal | 0 | my_xactor | xactor | This is a message from my_xactor formatted by continue_msg().

Now each message was output in a single line.

I hope this helps.

Leave a Reply