How to create a separate bins from single cover group.
In below even though i enabled bins only for only Burst_len =4; and Busrt_len =1 .
But i see 16 bins created in coverage database instead of only 2 bins created i.e for Burst_len =4 and Busrt_len =1;
And i am not able to get 100% coverage even though i covered all the scenario for specific module.
Please tell how to create only two bins for below code .
I have created a covergroup with all the 16 bins because for some other module i may need same bus coverage class with all the bins .
Hi there
Your code creates 16 bins at all times, but only SAMPLES a certain number of them, according to your config.
This means that if you configure for 2 bins, then the other 14 bins will never be sampled, which is not your intention of the other 14 bins never being created.
You could instead assign an option.weight to each coverpoint, using the configuration value to set the weight to 1 for values you want to be sampled, and 0 for values you want to ignore.
The coverpoints / bins will still be created, but with a weight of 0, meaning that unwanted bins will not adversely affect your coverage.
Because option.weight can only be used at covergroup or coverpoint level, you would rephrase your code so that instead of one covergroup with one coverpoint and lots of bins, you would still have a single covergroup, but instantiating 1 coverpoint of various weights per possible configuration option, each coverpoint having a single “hit” bin for when a hit occurs.
Hi Raku
The quickest way would be to conditionally instantiate one covergroup per configuration value, each with a single coverpoint, but that ends up with a lot of covergroups everywhere!
If you only ever had a few configured options and did want to do it that way to avoid having unhit zero-weight bins in your coverage report, then you would only need to declare the covergroup once. You could parameterise the value you wanted it to cover, and the conditionally instantiate once per possible value.
Here is an example for a solution if you are certain you do not want to see any unwanted values, whether contributing to coverage scores or not. Although it hides all unwanted values, unlike the first solution it does not automatically scale and needs to be rewritten whenever the range of possible burst values changes. This, along with the multiple covergroups, is why I do not favour this solution.
// Requires a global sampling signal and covergroup declared outside the class - ugly!
event e_sample_burst_len;
covergroup cg_burst_len(input bit [3:0] cfg_value, ref bit [4:0] burst_len) @(e_sample_burst_len);
option.per_instance = 1;
cp_hit : coverpoint burst_len {
bins HIT = {cfg_value};
}
endgroup
cg_burst_len cg_burst_len_1;
cg_burst_len cg_burst_len_2;
<snip>
cg_burst_len cg_burst_len_16;
function void build_phase (uvm_phase phase);
<snip>
if (burst_cfg[0]) cg_burst_len_1 = new(0, burst_len);
if (burst_cfg[1]) cg_burst_len_2 = new(1, burst_len);
<snip>
if (burst_cfg[15]) cg_burst_len_16 = new(15, burst_len);
endfunction
// And then the following instead of cg_*.sample()
-> e_sample_burst_len;
By the way, you have a ranging problem in your definition of burst_len - it can only carry values 0 to 15 but your covergroup checks for values 1 to 16.
class Bus_trans;
bit [3:0] burst_len;
endclass
<snip>
Burst_Length : coverpoint tr.burst_len
bins burst_len_16 = {16} iff (conf.burst_len_en[15] == 1);
There is a much easier way to do this using the new bin set_covergroup_expression construct introduced in 1800-2012. This allows you to create an array of values and use that array as the set of values for bins.
class BUS_coverage
Bus_trans tr;
Bus_conf conf;
bit [3:0] bin_set[$];
covergroup Bus_trans_coverage;
Burst_Length : coverpoint tr.burst_len
{
bins burst_len[] = bin_set;
endgroup
function new (string _name = "", Bus_conf cf1);
this.name = _name;
this.conf = cf1;
foreach(conf.burst_len_en[i]) if (conf.burst_len_en[i]) bin_set.push_back(i);
Bus_trans_coverage = new();
endfunction
Sorry, I did not have time to compile this for typos.
Ya thanks for taking time and showing the solution with example.
Also i too don’t prefer second way of creating many covergroups because i have so many other parameters for coverage so there will lot of covergroups created .