电子表设计与验证(计时模块验证)

电子表设计与验证(学习)

计时模块验证

利用UVM搭建简单的验证平台并收集功能覆盖率

package timer_pkg;
 import uvm_pkg::*;
 `include "uvm_macros.svh"
class timer_trans extends uvm_sequence_item;
  rand int up;
  rand int dn;
  rand int flag;
       int rsp;
  constraint timer{
   
                   up inside {
   [0:1]};
                   dn inside {
   [0:1]};
                   up + dn inside {
   [0:1]};
                   flag inside {
   [0:3]};
                   if (flag > 0)  
                       up + dn == 1;
                   if (flag == 0) up + dn == 0;
                   };

  `uvm_object_utils_begin(timer_trans)
   `uvm_field_int(up,UVM_ALL_ON)
   `uvm_field_int(dn,UVM_ALL_ON)
   `uvm_field_int(flag,UVM_ALL_ON)
  `uvm_object_utils_end
   
   function new (string name = "timer_trans");
     super.new(name);
   endfunction
endclass

class timer_coverage extends uvm_component;
   local virtual timer_inter intf;
   `uvm_component_utils(timer_coverage)
   covergroup timer_cover;
     up:coverpoint intf.up{
   
       type_option.weight = 0;
       bins up_s = {
   1};
       bins up_x = {
   0};
      }
     dn:coverpoint intf.dn{
   
        type_option.weight = 0;
        bins dn_s = {
   1};
        bins dn_x = {
   0};
      }
     flag: coverpoint intf.flag{
   
       type_option.weight = 0;
       bins hour = {
   1};
       bins min = {
   2};
       bins sec = {
   3};
       bins nomal = {
   0};
       }
     hour: coverpoint intf.hour{
   
       type_option.weight = 0;
       bins zero = {
   0};
       bins lo = {
   [1:10]};
       bins mo = {
   [11:21]};
       bins hi = {
   [22:23]};
       }
     min:  coverpoint intf.min{
   
       type_option.weight = 0;
       bins min_zero = {
   0};
       bins min_lo = {
   [1:10]};
       bins min_mo = {
   [11:50]};
       bins min_hi = {
   [51:59]};
       }
     sec:  coverpoint intf.sec{
   
       type_option.weight = 0;
       bins sec_zero = {
   0};
       bins sec_lo = {
   [1:10]};
       bins sec_mo = {
   [11:50]};
       bins sec_hi = {
   [51:59]};
       }
     msec
  • 0
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 1
    评论
评论 1
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值