电子表设计与验证(学习)
计时模块验证
利用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