# Sanity check on dynamic bins

**URL:** <https://verificationacademy.com/forums/t/sanity-check-on-dynamic-bins/44827>\
**Category:** Coverage\
**Created:** [January 5, 2024, 4:38pm UTC](https://verificationacademy.com/forums/t/sanity-check-on-dynamic-bins/44827 "2024-01-05T16:38:17Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![campo85](https://verificationacademy.com/forums/letter_avatar_proxy/v4/letter/c/c67d28/32.png) [@campo85](https://verificationacademy.com/forums/u/campo85)\
**Post date:** [January 5, 2024, 4:38pm UTC](https://verificationacademy.com/forums/t/sanity-check-on-dynamic-bins/44827/1 "2024-01-05T16:38:17Z")

</div>

Hi all, I’m very new to coverage and I have the following issue. Let’s say I’m defining a cover point as the following :

```auto
logic [MAX_SLOT-1:0] new_slot_alloc

covergroup fcov_slot_coverage (input int SS) @ (posedge clk);
   cp_sees_new_slot : coverpoint new_slot_alloc {
           bins new_slot[new_slot_alloc-1] = bins_queue_onehot_compute(SS);
           }
endgroup

function automatic bins_queue_onehot_t bins_queue_onehot_compute(int bin_cnt);
  bins_queue_onehot_t bins_q;
  for (int i = 0; i < MAX_SLOT; i += 1) begin
    if ( i != bin_cnt ) begin
      bins_q.push_back({MAX_SLOT{1'b1}} & 1'b1 << i);
    end
  end
  return bins_q;
endfunction

for (genvar SS = 0; SS < MAX_SLOT; SS++) begin : g_loop
     fcov_slot_coverage cg_slot = new(SS);
end

```

The idea behind is, to create a covergroup for every slot. The signal new\_slot\_alloc it’s a onehot signal by design so I essentially want to create a coverpoint contianing MAX\_SLOT -1 bins and each bins has a hit value corresponding to one of the possible onehot compination in new\_slot\_alloc (removing the combination for the slot itself). Just a quick example, let’s say MAX\_SLOT is equal to 5, for slot 0 (SS = 0) I would expect the bins to be :

- new\_slot[0] hits for 5’b00010
- new\_slot[1] hits for 5’b00100
- new\_slot[2] hits for 5’b01000
- new\_slot[3] hits for 5’b10000  
For slot 1 :
- new\_slot[0] hits for 5’b00001
- new\_slot[1] hits for 5’b00100
- new\_slot[2] hits for 5’b01000
- new\_slot[3] hits for 5’b10000  
etc…

The question is, is there a way to print the configuration of each coverpoint ? Or is there a way to sanity check this ?

---

<div class="post-metadata">

**Author:** ![dave\_59](https://verificationacademy.com/forums/user_avatar/verificationacademy.com/dave_59/32/4499_2.png) [@dave\_59](https://verificationacademy.com/forums/u/dave_59)\
**Post date:** [January 5, 2024, 5:35pm UTC](https://verificationacademy.com/forums/t/sanity-check-on-dynamic-bins/44827/2 "2024-01-05T17:35:13Z")

</div>

Most tools have the ability to print out detailed coverage reports for each bin. Check your tool’s User Manual.

It’s not clear to me whay you need the generated covergroup instances if they are all sampling the same `new_slot_alloc` signal. You need to hit all combinations without excluding the slot to get 100% coverage.

You probably meant to write

```
bins new_slot[MAX_SLOT] = bins_queue_onehot_compute(SS);

```

Also, the following may be easier to read

```
bins_q.push_back(MAX_SLOT'(1'b1 << i));

```
