Coverage Reference
Coverpoint bins
A coverpoint samples one expression. Its bins name the values you want to have seen.
Syntax
covergroup cg @(posedge clk);
cp_len: coverpoint len {
bins low = {[1:4]}; // one bin for the range
bins each[] = {[5:7]}; // one bin per value
ignore_bins zero = {0};
}
endgroupRules
bins name = {...}makes one bin for all the listed values.bins name[] = {...}makes one bin per value.- With no bins, the tool makes automatic bins, up to
auto_bin_max(64 by default). ignore_binsremoves values from coverage.illegal_binsalso reports an error when hit.- Coverage is the share of bins hit at least
at_leasttimes (1 by default). - A covergroup must be constructed with
new, or it samples nothing.
Example
module tb;
bit [3:0] len;
covergroup cg;
cp_len: coverpoint len {
bins low = {[1:4]};
bins each[] = {[5:7]};
}
endgroup
initial begin
cg c = new();
len = 2; c.sample();
len = 3; c.sample();
len = 5; c.sample();
$display("coverage = %0.1f%%", c.get_coverage());
len = 6; c.sample();
len = 7; c.sample();
$display("coverage = %0.1f%%", c.get_coverage());
end
endmodulecoverage = 50.0%
coverage = 100.0%Common Mistake
One bin where you wanted one per value
bins all_lengths = {[1:8]}; // one bin: a single hit gives 100%Without [], the whole range is one bin. Seeing one length marks every length as covered.
Fix: Write bins all_lengths[] = {[1:8]}; to get eight bins.
Learn It Properly
These lessons teach it step by step, with practice problems.
Standard
IEEE 1800-2023, 19.5.