UVM糖果爱好者教程 - 27.打印消息冗余度

UVM具有丰富的报告功能。 本文介绍如何使用冗长阈值来过滤消息。

预定义的冗余度级别

UVM预先定义了六个详细程度; UVM_NONE到UVM_DEBUG。 这些级别只不过是整数枚举值(图中的括号显示值)。 带有UVM_NONE级别的消息始终打印,而具有其他详细级别的消息如果需要打印则需要更高的阈值。

UVM糖果爱好者教程 - 27.打印消息冗余度_第1张图片    

             预定于的冗余度级别

冗余度级别举例

作为一个例子,我添加了几个具有不同详细级别的uvm_info宏给功能覆盖率收集器和记分板。 这个宏有三个参数; `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

下图总结了上述两个组件中定义的消息。

UVM糖果爱好者教程 - 27.打印消息冗余度_第2张图片

默认冗余度阈值

如果我们不指定任何冗余度阈值,则UVM将默认使用UVM_MEDIUM。这意味着将打印所有带有UVM_NONE,UVM_LOW和UVM_MEDIUM的消息,但是带有UVM_HIGH,UVM_FULL和UVM_DEBUG的消息不会。

UVM糖果爱好者教程 - 27.打印消息冗余度_第3张图片

如果你运行一个仿真,你会得到这样的打印信息:

# 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

设置全局冗余度阈值

+UVM_VERBOSITY

让我们改变冗余度阈值。如果您只是想全局更改阈值,最简单的方法是使用+ UVM_VERBOSITY命令行参数。例如,您可以将阈值设置为UVM_LOW,如下所示。

+UVM_VERBOSITY=UVM_LOW

UVM糖果爱好者教程 - 27.打印消息冗余度_第4张图片

如果你运行一个仿真,你会得到这样的信息:

# 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

由于阈值变低,因此不再使用UVM_MEDIUM查看信息。

设置特定组件的冗余度阈值

set_report_verbosity_level

如果要将冗余度阈值设置到特定组件,可以使用uvm_report_object类中定义的set_report_verbosity_level函数执行此操作。例如,您可以将UVM_MEDIUM阈值设置到记分板,如下所示(第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

请注意,在我们的例子中,我们仍然像上一节那样设置全局UVM_LOW阈值。特定于组件的阈值优先于全局阈值。

UVM糖果爱好者教程 - 27.打印消息冗余度_第5张图片

如果你运行一个仿真,你会得到这样的信息:

# 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

记分板的阈值变为UVM_MEDIUM,而功能覆盖用户的阈值保持UVM_LOW。

set_report_verbosity_level_hier

如果要将阈值设置为组件及其所有子项,则可以使用在uvm_component类中定义的set_report_verbosity_level_hier函数。例如,您可以将UVM_LOW阈值设置为测试台中的所有组件,如下所示(第3行)。这实际上相当于设置+ UVM_VERBOSITY = UVM_LOW。

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

设置特定ID的冗余度阈值

set_report_id_verbosity / set_report_id_verbosity_hier

如果您确实需要将冗余度阈值设置为特定的消息ID,则可以使用在uvm_report_object类中定义的set_report_id_verbosity函数(或者,如果要递归设置阈值,请在uvm_component类中定义set_report_id_verbosity_hier函数) 。例如,您可以按如下方式(第5行)为ID为“id1”的消息设置UVM_HIGH阈值:
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

请注意,在我们的示例中,我们仍像前面章节中那样设置全局阈值和组件特定阈值。特定于ID的阈值优先于特定于组件的阈值(和全局阈值)。

UVM糖果爱好者教程 - 27.打印消息冗余度_第6张图片

如果你运行一个仿真,你会得到这样的信息:

# 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

由于我们仅设置记分板的set_report_id_verbosity函数,所以即使某些消息具有相同的ID(“id1”),功能覆盖用户的阈值仍然为UVM_LOW。

设置严重性和特定ID的冗余度阈值

set_report_severity_id_verbosity / set_report_severity_id_verbosity_hier

虽然我们只介绍了本文中的UVM_INFO严重性,但可以使用set_report_severity_id_verbosity函数将冗余度阈值设置为特定严重性和消息ID,该函数在uvm_report_object类中定义(如果要递归设置阈值,则可使用uvm_component类中定义set_report_severity_id_verbosity_hier函数)。例如,您可以按如下方式(第5行)为ID为“id2”的消息设置UVM_FULL阈值:
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

请注意,在我们的示例中,我们仍像前面部分中那样设置全局阈值和组件以及ID特定的阈值。特定于严重性和ID的阈值具有最高优先级。

UVM糖果爱好者教程 - 27.打印消息冗余度_第7张图片

如果你运行一个仿真,你会得到这样的信息:

# 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

最终注释

您可能已经知道,阈值设置函数是在uvm_report_object和uvm_component类中定义的。 这意味着您不能在序列或非component对象调用该函数,因为它们不是从这些类派生的。

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.

相反,序列中的消息使用序列运行的sequencer的冗余度阈值。 如果序列是一个虚拟序列(sequencer为空),则使用uvm_top的冗余度阈值。 另一个非组件对象或模块中的消息也使用uvm_top的阈值。


与往常一样,您可以在EDA Playground上查看和运行代码。

你可能感兴趣的:(system,verilog,UVM,UVM糖果爱好者教程)