UVM Tutorial for Candy Lovers – 27. Message Verbosity

UVM has a rich reporting facility. This article explains how to use a verbosity threshold to filter messages.

Pre-defined Verbosity Levels

UVM pre-defines six verbosity levels; UVM_NONE to UVM_DEBUG. These levels are nothing but integer enum values (the parentheses in the figure show the values). A message with the UVM_NONE level is always printed, while a message with another verbosity level requires a higher threshold to print.

 

                                                                           Pre-defined Verbosity Levels

Verbosity-Level Example

As an example, I added several `uvm_info macros with different verbosity levels to the functional coverage subscriber and the scoreboard. The macro takes three arguments; `uvm_info( ID, MESSAGE, VERBOSITY_LEVEL )

Functional Coverage Subscriber

class jelly_bean_fc_subscriber extends uvm_subscriber#( jelly_bean_transaction );
  // ...
  function void write( jelly_bean_transaction t );
    jb_tx = t;
    jelly_bean_cg.sample();
 
    //         _ID__  _________________________MESSAGE__________________________  VERBOSITY_LEVEL
    `uvm_info( "id1", { t.color.name(), " ", t.flavor.name(), "  1 UVM_DEBUG"  }, UVM_DEBUG  ) 
    `uvm_info( "id1", { t.color.name(), " ", t.flavor.name(), "  2 UVM_FULL"   }, UVM_FULL   )
    `uvm_info( "id1", { t.color.name(), " ", t.flavor.name(), "  3 UVM_HIGH"   }, UVM_HIGH   )
    `uvm_info( "id1", { t.color.name(), " ", t.flavor.name(), "  4 UVM_MEDIUM" }, UVM_MEDIUM )
    `uvm_info( "id1", { t.color.name(), " ", t.flavor.name(), "  5 UVM_LOW"    }, UVM_LOW    )
    `uvm_info( "id1", { t.color.name(), " ", t.flavor.name(), "  6 UVM_NONE"   }, UVM_NONE   )
 
    `uvm_info( "id2", { t.color.name(), " ", t.flavor.name(), "  7 UVM_DEBUG"  }, UVM_DEBUG  )
    `uvm_info( "id2", { t.color.name(), " ", t.flavor.name(), "  8 UVM_FULL"   }, UVM_FULL   )
    `uvm_info( "id2", { t.color.name(), " ", t.flavor.name(), "  9 UVM_HIGH"   }, UVM_HIGH   )
    `uvm_info( "id2", { t.color.name(), " ", t.flavor.name(), " 10 UVM_MEDIUM" }, UVM_MEDIUM )
    `uvm_info( "id2", { t.color.name(), " ", t.flavor.name(), " 11 UVM_LOW"    }, UVM_LOW    )
    `uvm_info( "id2", { t.color.name(), " ", t.flavor.name(), " 12 UVM_NONE"   }, UVM_NONE   )
  endfunction: write
endclass: jelly_bean_fc_subscriber

Scoreboard

class jelly_bean_sb_subscriber extends uvm_subscriber#( jelly_bean_transaction );
  // ...
  function void write( jelly_bean_transaction t );
    if (     t.flavor == CHOCOLATE && t.sour   && t.taste == YUMMY ||
         ! ( t.flavor == CHOCOLATE && t.sour ) && t.taste == YUCKY ) begin
      `uvm_error( get_name(), { "You lost sense of taste!", t.convert2string() } )
    end else begin
      //         _ID__  _________________________MESSAGE__________________________  VERBOSITY_LEVEL
      `uvm_info( "id1", { t.color.name(), " ", t.flavor.name(), " 13 UVM_DEBUG"  }, UVM_DEBUG  )
      `uvm_info( "id1", { t.color.name(), " ", t.flavor.name(), " 14 UVM_FULL"   }, UVM_FULL   )
      `uvm_info( "id1", { t.color.name(), " ", t.flavor.name(), " 15 UVM_HIGH"   }, UVM_HIGH   )
      `uvm_info( "id1", { t.color.name(), " ", t.flavor.name(), " 16 UVM_MEDIUM" }, UVM_MEDIUM )
      `uvm_info( "id1", { t.color.name(), " ", t.flavor.name(), " 17 UVM_LOW"    }, UVM_LOW    )
      `uvm_info( "id1", { t.color.name(), " ", t.flavor.name(), " 18 UVM_NONE"   }, UVM_NONE   )
 
      `uvm_info( "id2", { t.color.name(), " ", t.flavor.name(), " 19 UVM_DEBUG"  }, UVM_DEBUG  )
      `uvm_info( "id2", { t.color.name(), " ", t.flavor.name(), " 20 UVM_FULL"   }, UVM_FULL   )
      `uvm_info( "id2", { t.color.name(), " ", t.flavor.name(), " 21 UVM_HIGH"   }, UVM_HIGH   )
      `uvm_info( "id2", { t.color.name(), " ", t.flavor.name(), " 22 UVM_MEDIUM" }, UVM_MEDIUM )
      `uvm_info( "id2", { t.color.name(), " ", t.flavor.name(), " 23 UVM_LOW"    }, UVM_LOW    )
      `uvm_info( "id2", { t.color.name(), " ", t.flavor.name(), " 24 UVM_NONE"   }, UVM_NONE   )
    end
  endfunction: write
endclass: jelly_bean_sb_subscriber

The following figure summarizes the messages defined in the above two components.

                                                           Messages Defined in the Two Components

Default Verbosity Threshold

If we do not specify any verbosity threshold, UVM uses UVM_MEDIUM as the default. This means all the messages with UVM_NONEUVM_LOW, and UVM_MEDIUM will be printed, but the messages with UVM_HIGHUVM_FULL, and UVM_DEBUG won’t.

                                                    Messages Printed with the Default Verbosity Threshold

If you run a simulation, you will get the messages like this:

# KERNEL: UVM_INFO /home/runner/env.svh(43) @ 25: uvm_test_top.jb_env.jb_fc [id1] GREEN BUBBLE_GUM  4 UVM_MEDIUM
# KERNEL: UVM_INFO /home/runner/env.svh(44) @ 25: uvm_test_top.jb_env.jb_fc [id1] GREEN BUBBLE_GUM  5 UVM_LOW
# KERNEL: UVM_INFO /home/runner/env.svh(45) @ 25: uvm_test_top.jb_env.jb_fc [id1] GREEN BUBBLE_GUM  6 UVM_NONE
# KERNEL: UVM_INFO /home/runner/env.svh(50) @ 25: uvm_test_top.jb_env.jb_fc [id2] GREEN BUBBLE_GUM 10 UVM_MEDIUM
# KERNEL: UVM_INFO /home/runner/env.svh(51) @ 25: uvm_test_top.jb_env.jb_fc [id2] GREEN BUBBLE_GUM 11 UVM_LOW
# KERNEL: UVM_INFO /home/runner/env.svh(52) @ 25: uvm_test_top.jb_env.jb_fc [id2] GREEN BUBBLE_GUM 12 UVM_NONE
# KERNEL: UVM_INFO /home/runner/env.svh(85) @ 25: uvm_test_top.jb_env.jb_sb [id1] GREEN BUBBLE_GUM 16 UVM_MEDIUM
# KERNEL: UVM_INFO /home/runner/env.svh(86) @ 25: uvm_test_top.jb_env.jb_sb [id1] GREEN BUBBLE_GUM 17 UVM_LOW
# KERNEL: UVM_INFO /home/runner/env.svh(87) @ 25: uvm_test_top.jb_env.jb_sb [id1] GREEN BUBBLE_GUM 18 UVM_NONE
# KERNEL: UVM_INFO /home/runner/env.svh(92) @ 25: uvm_test_top.jb_env.jb_sb [id2] GREEN BUBBLE_GUM 22 UVM_MEDIUM
# KERNEL: UVM_INFO /home/runner/env.svh(93) @ 25: uvm_test_top.jb_env.jb_sb [id2] GREEN BUBBLE_GUM 23 UVM_LOW
# KERNEL: UVM_INFO /home/runner/env.svh(94) @ 25: uvm_test_top.jb_env.jb_sb [id2] GREEN BUBBLE_GUM 24 UVM_NONE

Setting Global Verbosity Threshold

+UVM_VERBOSITY

Let’s change the verbosity threshold. If you just want to change the threshold globally, the easiest way is to use the +UVM_VERBOSITY command-line argument. For example, you can set the threshold as UVM_LOW as follows.

+UVM_VERBOSITY=UVM_LOW

                                                 Messages Printed with +UVM_VERBOSITY=UVM_LOW

When you run a simulation, you will get the messages like this:

# KERNEL: UVM_INFO /home/runner/env.svh(44) @ 25: uvm_test_top.jb_env.jb_fc [id1] GREEN BUBBLE_GUM  5 UVM_LOW
# KERNEL: UVM_INFO /home/runner/env.svh(45) @ 25: uvm_test_top.jb_env.jb_fc [id1] GREEN BUBBLE_GUM  6 UVM_NONE
# KERNEL: UVM_INFO /home/runner/env.svh(51) @ 25: uvm_test_top.jb_env.jb_fc [id2] GREEN BUBBLE_GUM 11 UVM_LOW
# KERNEL: UVM_INFO /home/runner/env.svh(52) @ 25: uvm_test_top.jb_env.jb_fc [id2] GREEN BUBBLE_GUM 12 UVM_NONE
# KERNEL: UVM_INFO /home/runner/env.svh(86) @ 25: uvm_test_top.jb_env.jb_sb [id1] GREEN BUBBLE_GUM 17 UVM_LOW
# KERNEL: UVM_INFO /home/runner/env.svh(87) @ 25: uvm_test_top.jb_env.jb_sb [id1] GREEN BUBBLE_GUM 18 UVM_NONE
# KERNEL: UVM_INFO /home/runner/env.svh(93) @ 25: uvm_test_top.jb_env.jb_sb [id2] GREEN BUBBLE_GUM 23 UVM_LOW
# KERNEL: UVM_INFO /home/runner/env.svh(94) @ 25: uvm_test_top.jb_env.jb_sb [id2] GREEN BUBBLE_GUM 24 UVM_NONE

Since the threshold became lower, you no longer see the messages with UVM_MEDIUM.

Setting Component-specific Verbosity Threshold

set_report_verbosity_level

If you want to set the verbosity threshold to a specific component, you can do it using the set_report_verbosity_level function, which is defined in the uvm_report_object class. For example, you can set the UVM_MEDIUM threshold to the scoreboard as follows (line 5):

class jelly_bean_test extends uvm_test;
  // ...
  task main_phase( uvm_phase phase );
    // ...
    jb_env.jb_sb.set_report_verbosity_level( UVM_MEDIUM );
  endtask: main_phase
endclass: jelly_bean_test

Note that in our example, we still set the global UVM_LOW threshold as we did in the previous section. Component-specific threshold takes precedence over the global threshold.

                                                                 Setting Component-specific Threshold

When you run a simulation, you will get the messages like this:

# KERNEL: UVM_INFO /home/runner/env.svh(44) @ 25: uvm_test_top.jb_env.jb_fc [id1] GREEN BUBBLE_GUM  5 UVM_LOW
# KERNEL: UVM_INFO /home/runner/env.svh(45) @ 25: uvm_test_top.jb_env.jb_fc [id1] GREEN BUBBLE_GUM  6 UVM_NONE
# KERNEL: UVM_INFO /home/runner/env.svh(51) @ 25: uvm_test_top.jb_env.jb_fc [id2] GREEN BUBBLE_GUM 11 UVM_LOW
# KERNEL: UVM_INFO /home/runner/env.svh(52) @ 25: uvm_test_top.jb_env.jb_fc [id2] GREEN BUBBLE_GUM 12 UVM_NONE
# KERNEL: UVM_INFO /home/runner/env.svh(85) @ 25: uvm_test_top.jb_env.jb_sb [id1] GREEN BUBBLE_GUM 16 UVM_MEDIUM
# KERNEL: UVM_INFO /home/runner/env.svh(86) @ 25: uvm_test_top.jb_env.jb_sb [id1] GREEN BUBBLE_GUM 17 UVM_LOW
# KERNEL: UVM_INFO /home/runner/env.svh(87) @ 25: uvm_test_top.jb_env.jb_sb [id1] GREEN BUBBLE_GUM 18 UVM_NONE
# KERNEL: UVM_INFO /home/runner/env.svh(92) @ 25: uvm_test_top.jb_env.jb_sb [id2] GREEN BUBBLE_GUM 22 UVM_MEDIUM
# KERNEL: UVM_INFO /home/runner/env.svh(93) @ 25: uvm_test_top.jb_env.jb_sb [id2] GREEN BUBBLE_GUM 23 UVM_LOW
# KERNEL: UVM_INFO /home/runner/env.svh(94) @ 25: uvm_test_top.jb_env.jb_sb [id2] GREEN BUBBLE_GUM 24 UVM_NONE

The threshold of the scoreboard became UVM_MEDIUM, while the threshold of the functional coverage subscriber remains UVM_LOW.

set_report_verbosity_level_hier

If you want to set the threshold to a component and all its children, you can use the set_report_verbosity_level_hier function, which is defined in the uvm_component class. For example, you can set the UVM_LOW threshold to all the components in the test-bench as follows (line 3). This is actually equivalent to setting +UVM_VERBOSITY=UVM_LOW.

module top;
  // ...
  initial uvm_top.set_report_verbosity_level_hier( UVM_LOW );
endmodule: top

Setting ID-specific Verbosity Threshold

set_report_id_verbosity / set_report_id_verbosity_hier

If you really want to set the verbosity threshold to a specific message ID, you can do it using the set_report_id_verbosity function, which is defined in the uvm_report_object class (or the set_report_id_verbosity_hier function defined in the uvm_component class if you want to set the threshold recursively). For example, you can set the UVM_HIGH threshold to the messages whose ID is "id1" as follows (line 5):

class jelly_bean_test extends uvm_test;
  // ...
  task main_phase( uvm_phase phase );
    // ...
    jb_env.jb_sb.set_report_id_verbosity( "id1", UVM_HIGH );
  endtask: main_phase
endclass: jelly_bean_test

Note that in our example, we still set the global threshold and component-specific threshold as we did in the previous sections. ID-specific threshold takes precedence over the component-specific threshold (and the global threshold).

                                                                       Setting ID-specific Threshold

When you run a simulation, you will get the messages like this:

# KERNEL: UVM_INFO /home/runner/env.svh(44) @ 25: uvm_test_top.jb_env.jb_fc [id1] GREEN BUBBLE_GUM  5 UVM_LOW
# KERNEL: UVM_INFO /home/runner/env.svh(45) @ 25: uvm_test_top.jb_env.jb_fc [id1] GREEN BUBBLE_GUM  6 UVM_NONE
# KERNEL: UVM_INFO /home/runner/env.svh(51) @ 25: uvm_test_top.jb_env.jb_fc [id2] GREEN BUBBLE_GUM 11 UVM_LOW
# KERNEL: UVM_INFO /home/runner/env.svh(52) @ 25: uvm_test_top.jb_env.jb_fc [id2] GREEN BUBBLE_GUM 12 UVM_NONE
# KERNEL: UVM_INFO /home/runner/env.svh(84) @ 25: uvm_test_top.jb_env.jb_sb [id1] GREEN BUBBLE_GUM 15 UVM_HIGH
# KERNEL: UVM_INFO /home/runner/env.svh(85) @ 25: uvm_test_top.jb_env.jb_sb [id1] GREEN BUBBLE_GUM 16 UVM_MEDIUM
# KERNEL: UVM_INFO /home/runner/env.svh(86) @ 25: uvm_test_top.jb_env.jb_sb [id1] GREEN BUBBLE_GUM 17 UVM_LOW
# KERNEL: UVM_INFO /home/runner/env.svh(87) @ 25: uvm_test_top.jb_env.jb_sb [id1] GREEN BUBBLE_GUM 18 UVM_NONE
# KERNEL: UVM_INFO /home/runner/env.svh(92) @ 25: uvm_test_top.jb_env.jb_sb [id2] GREEN BUBBLE_GUM 22 UVM_MEDIUM
# KERNEL: UVM_INFO /home/runner/env.svh(93) @ 25: uvm_test_top.jb_env.jb_sb [id2] GREEN BUBBLE_GUM 23 UVM_LOW
# KERNEL: UVM_INFO /home/runner/env.svh(94) @ 25: uvm_test_top.jb_env.jb_sb [id2] GREEN BUBBLE_GUM 24 UVM_NONE

Because we called the set_report_id_verbosity function to the scoreboard only, the threshold of the functional coverage subscriber remains UVM_LOW even though some messages have the same ID ("id1").

Setting Severity-and-ID-specific Verbosity Threshold

set_report_severity_id_verbosity / set_report_severity_id_verbosity_hier

Although we covered only UVM_INFO severity in this article, you can set the verbosity threshold to a specific severity and message ID using the set_report_severity_id_verbosity function, which is defined in the uvm_report_object class (or the set_report_severity_id_verbosity_hier function defined in the uvm_component class if you want to set the threshold recursively). For example, you can set the UVM_FULL threshold to the messages whose ID is "id2" as follows (line 5):

class jelly_bean_test extends uvm_test;
  // ...
  task main_phase( uvm_phase phase );
    // ...
    jb_env.jb_fc.set_report_severity_id_verbosity( UVM_INFO, "id2", UVM_FULL );
  endtask: main_phase
endclass: jelly_bean_test

Note that in our example, we still set the global threshold and component and ID-specific thresholds as we did in the previous sections. Severity-and-ID-specific threshold takes the highest precedence.

                                                                  Setting Severity-and-ID-specific Threshold

When you run a simulation, you will get the messages like this:

# KERNEL: UVM_INFO /home/runner/env.svh(44) @ 25: uvm_test_top.jb_env.jb_fc [id1] RED APPLE  5 UVM_LOW
# KERNEL: UVM_INFO /home/runner/env.svh(45) @ 25: uvm_test_top.jb_env.jb_fc [id1] RED APPLE  6 UVM_NONE
# KERNEL: UVM_INFO /home/runner/env.svh(48) @ 25: uvm_test_top.jb_env.jb_fc [id2] RED APPLE  8 UVM_FULL
# KERNEL: UVM_INFO /home/runner/env.svh(49) @ 25: uvm_test_top.jb_env.jb_fc [id2] RED APPLE  9 UVM_HIGH
# KERNEL: UVM_INFO /home/runner/env.svh(50) @ 25: uvm_test_top.jb_env.jb_fc [id2] RED APPLE 10 UVM_MEDIUM
# KERNEL: UVM_INFO /home/runner/env.svh(51) @ 25: uvm_test_top.jb_env.jb_fc [id2] RED APPLE 11 UVM_LOW
# KERNEL: UVM_INFO /home/runner/env.svh(52) @ 25: uvm_test_top.jb_env.jb_fc [id2] RED APPLE 12 UVM_NONE
# KERNEL: UVM_INFO /home/runner/env.svh(84) @ 25: uvm_test_top.jb_env.jb_sb [id1] RED APPLE 15 UVM_HIGH
# KERNEL: UVM_INFO /home/runner/env.svh(85) @ 25: uvm_test_top.jb_env.jb_sb [id1] RED APPLE 16 UVM_MEDIUM
# KERNEL: UVM_INFO /home/runner/env.svh(86) @ 25: uvm_test_top.jb_env.jb_sb [id1] RED APPLE 17 UVM_LOW
# KERNEL: UVM_INFO /home/runner/env.svh(87) @ 25: uvm_test_top.jb_env.jb_sb [id1] RED APPLE 18 UVM_NONE
# KERNEL: UVM_INFO /home/runner/env.svh(92) @ 25: uvm_test_top.jb_env.jb_sb [id2] RED APPLE 22 UVM_MEDIUM
# KERNEL: UVM_INFO /home/runner/env.svh(93) @ 25: uvm_test_top.jb_env.jb_sb [id2] RED APPLE 23 UVM_LOW
# KERNEL: UVM_INFO /home/runner/env.svh(94) @ 25: uvm_test_top.jb_env.jb_sb [id2] RED APPLE 24 UVM_NONE

Final Notes

As you might be aware that the threshold-setting functions are defined in the uvm_report_object and uvm_component classes. This means you cannot call the function to a sequence or a non-component object, because they are not derived from these classes.

jelly_bean_sequence   .set_report_verbosity_level( UVM_HIGH ); // You cannot do this.
jelly_bean_transaction.set_report_verbosity_level( UVM_HIGH ); // This won't work either.

Instead, the message in a sequence uses the verbosity threshold of the sequencer the sequence is running on. If the sequence is a virtual sequence (the sequencer is null), then the verbosity threshold of the uvm_top is used. The message in another non-component object or in a module also uses the threshold of the uvm_top.

已标记关键词 清除标记
©️2020 CSDN 皮肤主题: 编程工作室 设计师:CSDN官方博客 返回首页