首页 > 其他分享 >SystemVerilog -- 10.2 SystemVerilog Coverpoint Bins

SystemVerilog -- 10.2 SystemVerilog Coverpoint Bins

时间:2024-05-12 11:08:48浏览次数:13  
标签:bin 10.2 SystemVerilog -- cg range mode ncsim bins

SystemVerilog Coverpoint Bins

该构造允许在 coverpoint 变量的给定可能值范围内为每个值创建一个单独的 bin。bin

Usage

coverpoint mode {
  // Manually create a separate bin for each value
  bins zero = {0};
  bins one  = {1};

  // Allow SystemVerilog to automatically create separate bins for each value
  // Values from 0 to maximum possible value is split into separate bins
  bins range[] = {[0:$]};

  // Create automatic bins for both the given ranges
  bins c[] = {[2:3], [5:7]};

  // Use fixed number of automatic bins. Entire ranges is broken up into 4 bins
  bins range[4] = {[0:$]};

  // If the number of bins cannot be equally divided for the given range, then 
  // the last bin will include remaining items; Here there are 13 values to be 
  // distributed into 4 bins which yields:
  bins range[4] = {[1:10], 1, 3, 6};
  
  // A single bin to store all other values that don't belong to any other bin
  bins others = default;
}

Examples

module tb;
  bit [2:0] mode;

  // This covergroup does not get sample automatically because the sample event is missing in declaration
  covergroup cg;
    cooverpoint mode {
      bins one  = {1};
      bins five = {5};
    }
  endgroup

  // Stimulus : Simply randomize mode to have different values and manually sample each time
  initial begin
    cg cg_inst = new ();
    for (int i = 0; i < 5; i++) begin
      #10 mode = $random;
      $display ("[%0t] mode = 0x%0h", $time, mode);
      cg_inst.sample ();
    end
    $display ("Coverage = %0.2f %%", cg_inst.get_inst_coverage());
  end
endmodule

模拟日志

ncsim> run
[10] mode = 0x4
[20] mode = 0x1
[30] mode = 0x1
[40] mode = 0x3
[50] mode = 0x5
Coverage = 100.00 %
ncsim: *W,RNQUIE: Simulation is complete.

Automatic Bins

covergroup cg;
  coverpoint mode {
    // Declares a separate bin for each values -> Here there will 8 bins
    bins range[] = {[0:$]};
  }
endgroup

模拟日志

ncsim> run
[10] mode = 0x4
[20] mode = 0x1
[30] mode = 0x1
[40] mode = 0x3
[50] mode = 0x5
Coverage = 50.00 %
ncsim: *W,RNQUIE: Simulation is complete.

Fixed Number of automatic bins

covergroup cg;
  coverpoint mode {
    // Declares 4 bins for the total range of 8 values
    // So bib0->[0:1] bib1->[2:3] bib2->[4:5] bib3->[6:7]
    bins range[4] = {[0:$]};
  }
endgroup

mode从未获得 6 或 7 的值,因此 bin3 不会被命中。但是所有其它 bins 都被 hit,因此覆盖率为 75%。

模拟日志

ncsim> run
[10] mode = 0x4
[20] mode = 0x1
[30] mode = 0x1
[40] mode = 0x3
[50] mode = 0x5
Coverage = 75.00 %
ncsim: *W,RNQUIE: Simulation is complete.

Split fixed number of bins between a given range

covergroup cg;
  coverpoint mode {
    // defines 3 bins
    // Two bins for values from 1:4, and one bin for value 7 
    // bin1->[1,2] bin2->[3:4 bin3->7
    bins range[3] = {[1:4], 7};
  }
endgroup

只有 2/3 的 bin s被 hit,因此覆盖率为 66.7%。具体来说, bin1 和 bin2 被 hit 是因为对 mode 的采样分别为 1 和 [3,4]。

模拟日志

ncsim> run
[10] mode = 0x4
[20] mode = 0x1
[30] mode = 0x1
[40] mode = 0x3
[50] mode = 0x5
Coverage = 66.67 %
ncsim: *W,RNQUIE: Simulation is complete.

标签:bin,10.2,SystemVerilog,--,cg,range,mode,ncsim,bins
From: https://www.cnblogs.com/sys-123456/p/18187360

相关文章

  • 数据段和代码段相关
    1、实际上,对于在STM32F103这类资源紧缺的单片机芯片中:代码段保存在Flash上,直接在Flash上运行(当然也可以重定位到内存里)数据段暂时先保存在Flash上,然后在使用前被复制到内存里(只读数据段(ROdata)不复制)函数入口地址、函数参数、临时变量、const修饰的局部常量在运行到对应代码......
  • 浅谈Vue.js与原生开发
    在现代的Web开发中,前端框架的选择是至关重要的。Vue.js作为一款流行的前端框架,与传统的原生开发相比,有许多明显的区别。模版语法与HTMLVue.js使用特殊的模板语法来创建动态视图,这样开发者可以更方便地表达复杂的逻辑。通过指令(例如v-if、v-for等)和模板表达式,Vue.js简化了数据的......
  • Docker Compose 备忘清单
    DockerCompose备忘清单Docker-compsoe是一个开源项目,用于定义和运行多容器Docker应用程序的工具。由Docker社区维护。通过一个YAML文件来配置应用程序的服务,以便可以使用一个命令启动、停止和重启整个应用程序。DockerCompose开源地址DockerCompose发行地址github......
  • 基于webapi的websocket聊天室(二)
    上一篇-基于webapi的websocket聊天室(一)消息超传缓冲区的问题在上一篇中我们定义了一个聊天室WebSocketChatRoom。但是每个游客只分配了400个字节的发言缓冲区,大概100字。如果需要发送更多内容呢?难道直接增大缓冲区?这是一个办法。但还有其他办法。多次接受消息可以多次调......
  • ROS2速记
    工作空间进行ROS2相关代码的开发,首先需要一个工作空间任意创建文件夹,一般是以dev_workspace类似的命名方法。工作空间数量不唯一常见的结构应该是四个文件夹:buildinstalllogsrcsrc,代码空间,未来编写的代码、脚本,都需要人为的放置到这里;build,编译空间,保存编译过程中产生的......
  • C - Sigma Problem
    C-SigmaProblemhttps://atcoder.jp/contests/abc353/tasks/abc353_c 思路暴力TLE观察a1a2...an序列计算目标是,两两结合并并求模sum=sigma(ai+aj)%1e8ai,aj<=1e8ai+aj可能溢出,也可能不溢出于是我们考虑,统计所有溢出的个数。 对数组进行排序,......
  • Android开发&Kotlin学习笔记
    为了做《基于安卓定位的考勤系统》,学了一些杂乱的知识,在这里简单记录一下。除了在C#桌面应用开发中感性的体会到了些XML布局的知识以及课上学习的Java知识,其他也算是零基础了。GoogleAndroidDeveloper的课程2023/10/25:跟着官方文档先快速入门一下基本内容。截至目前来看官方......
  • SpringBoot速记
    本篇以SpringBoot快速构建一个基础项目,在构建的同时记录相关的知识。常见的架构图: 其中,config中可以引入第三方的jar包controller中存放控制类一个简单的例子如下: mapper中存放对数据库的操作接口 pojo中是实体对象类,常与数据表对应 service中存放服务类:......
  • 内部类
    packageDemo10;importjava.applet.Applet;publicclassTest{publicstaticvoidmain(String[]args){//没有名字初始化类,不用将实例保存到变量中newApple().eat();newUservice(){@Overridepublicvoidhello(){}};}}classApple{publicvoid......
  • 【攻防技术系列】-- Python沙箱逃逸
    Python是一种强大而灵活的编程语言,但在某些情况下,可能需要运行不受信任的代码,同时又希望限制它的行为,以防止对系统的不良影响。这时,Python沙箱就成为一种有用的工具,它可以帮助你在安全的环境中运行不受信任的代码。本文将探讨Python沙箱的概念、常见的沙箱技术以及如何避免沙......