If you are not giving weight to your items in your coverage groups, the overall functional coverage number you get on
Specman coverage report might be wrong. Let me explain it using an example. Take a look at following code.
cov_ex : coverage_example;
keep soft cov_ex.a == TRUE;
If you load above code, issue a test command and see the coverage report, it will show you 28%, which is wrong in fact.
Specman calculates the overall coverage numbers hierarchical. For the above code, it calculates as following.
For item a:total bucket = 2
total hit = 1
So, coverage number = 50%
For item b:total bucket = 4
total hit = 1
So, coverage number = 25%
For cross a, b:
total bucket = 4*2 = 8
total hit = 1
So, coverage number = 12.5%
For Overall:
total bucket = 3 (item a, item b and cross a,b)
total hit = (50 + 25 + 12.5) = 87.5
So, coverage number =
29.166% (87.5/3)But, in fact, it should be calculated as following.
Total bucket in the coverage group = 2 + 4 + 8 = 14
Total hit = 1 + 1 + 1 = 3
So, overall coverage should be (3*100/14 =
21.4285%)
This wrong calculation can be avoided by doing following modification in the code. See highlighted "green" code below.
//Weight is total number of buckets
item a using weight=2;
item b using weight=4;
cross a,b using weight=8;
};
cov_ex : coverage_example;
keep soft cov_ex.a == TRUE;
But, all the time, applying weight to every item is not possible, as some code may be imported from third party vendor or some code might be read-only to the user. Also whenever the number of buckets change, user needs to update the weight of particular item. This might not be feasible sometimes.
To avoid this, there is a utility called bucket_counter which was delivered by Clemens Mueller from Cadence. This e code will report total number of buckets in each item and total number of bucket hits. This simple utility will help you calculate the exact number of functional coverage you have.
Please click
here to download the code.
Just load the
ecode along with your environment and read the coverage file. Then issue "
sys.report_buckets()". It will report total number of buckets in each item, and total number of hits, as shown below.
Valid Space size for item a is 2 buckets
Valid Space size for item b is 4 buckets
Valid Space size for item cross__a__b is 8 buckets
total coverage buckets: 14
total coverage buckets hit: 3