Download as pptx, pdf, or txt
Download as pptx, pdf, or txt
You are on page 1of 12

SYSTEMVERILOG COVERAGE

Objectives

• Code Coverage
• Functional Coverage
• Cross Coverage
• Coverage Options
Introduction:

There are two types of coverage metrics.


1.Code coverage..
2. Functional coverage.

• Code Coverage
Code coverage measures how much of the “design Code”
is exercised.
This includes, execution of design blocks, Number of Lines,
Conditions, FSM, Toggle and Path.
Simulator tool will automatically extracts the code coverage from
the design code.
Contd..
Functional Coverage:
Functional coverage is a user-defined metric that measures how much of the
design specification has been exercised in verification.

There are two types of functional coverage,

Data-oriented Coverage - Checks combinations of data values have occurred.


We can get Data-oriented coverage by writing Coverage groups, coverage
points and also by cross coverage.

Control-oriented Coverage - Checks whether sequences of behaviors have


occurred. We can get assertion coverage by writing SystemVerilog Assertions.
Defining the functional coverage is covered in next chapters.
Defining the coverage model:
Coverage model is defined using Covergroup construct.
The covergroup construct is a user-defined type. The type definition is written once, and
multiple instances of that type can be created in different contexts.

Each covergroup specification can include,


• A clocking event that synchronizes the sampling of coverage points
• A set of coverage points
• Cross coverage between coverage points
• Optional formal arguments
• Coverage options
Example-1:
covergroup cov_grp;
cov_p1: coverpoint a;
endgroup

cov_grp cov_inst = new();


cov_inst.sample();
Defining coverage points:
A coverage point can be an integral variable or an integral expression.
Each coverage point is associated with “bin”.

1. Automatic/Implicit Bins:
Automatically single bin will be created for each value of the coverpoint variable
range. These are called automatic, or implicit, bins.
For an “n” bit integral coverpoint variable, 2n number of automatic bins will get
created.
module cov;
logic clk;
logic [7:0] addr;
Below are the bins, will get created automatically, logic wr_rd;
for addr: c1.auto[0] c1.auto[1] c1.auto[2] …
c1.auto[255]
for wr_rd: c2.auto[0] covergroup cg @(posedge clk);
c1: coverpoint addr;
c2: coverpoint wr_rd;
endgroup : cg
cg cover_inst = new();
endmodule
Cntd..
Explicit bins:
“bins” keyword is used to declare the bins explicitly to an variable.

Bins are explicitly declared with in curly braces { } along with the bins keyword
followed by bin name and variable value/range, immediately after the coverpoint
identifier.
Ex:
covergroup cg @(posedge clk);
c1: coverpoint addr { bins b1 = {0,2,7};
bins b2[3] = {11:20};
bins b3 = {[30:40],[50:60],77};
bins b4[] = {[79:99],[110:130],140};
bins b5[] = {160,170,180};
bins b6 = {200:$};
bins b7 = default;}
c2: coverpoint wr_rd {bins wrrd};
endgroup : cg
Cntd..
bins for transitions:

Example:
covergroup cg @(posedge clk);
c1: coverpoint addr{ bins b1 = (10=>20=>30);
bins b2[] = (40=>50),(80=>90=>100=>120);
bins b3 = (1,5 => 6, 7);}
c2: coverpoint wr_rd;
endgroup : cg

ignore_bins:

covergroup cg @(posedge clk);


c1: coverpoint addr{ ignore_bins b1 = {6,60,66};
ignore_bins b2 = (30=>20=>10); }
endgroup : cg
Cntd..
illegal_bins:

covergroup cg @(posedge clk);


c1: coverpoint addr{ illegal_bins b1 = {7,70,77};
ignore_bins b2 = (7=>70=>77);}
endgroup : cg
Cross Coverage
Cross Coverage is specified between the cover points or variables. Cross
coverage is specified using the cross construct.

Expressions cannot be used directly in a cross; a coverage point must be


explicitly defined first.

Cross coverage by cover_point name:


bit [3:0] a, b;
covergroup cg @(posedge clk);
c1: coverpoint a;
c2: coverpoint b;
c1Xc2: cross c1,c2;
endgroup : cg

Cross coverage by variable name:


bit [3:0] a, b;
covergroup cov @(posedge clk);
aXb : cross a, b;
endgroup
Cntd..
Coverage options:

EX:
covergroup cg @(posedge clk);
c1: coverpoint addr { option.auto_bin_max = 128;}
c2: coverpoint wr_rd { option.atleast = 2;}
c1Xc2: cross c1, c2 { option.cross_auto_bin_max = 128;}
endgroup : cg

You might also like