Sum of Coverpoints

Hi,
May I know how I can write another coverpoint that simply sums the other coverpoints instead of crossing them?
Thank you.

In example below, I just need to know celln_o has toggled 0 to 16, celln_u has toggled 0 to 16, tmonin_o has toggled 0 to 4 and tmonin_u has toggled 0 to 4.

class n_class;
    rand n_struct n_randc;
    constraint c {
      n_randc.celln_o  < 17;
      n_randc.celln_u  < 17;
      n_randc.tmonin_o <  5;
      n_randc.tmonin_u <  5;
      n_randc.celln_o  != n_randc.celln_u  ;
      n_randc.tmonin_o != n_randc.tmonin_u ;
    }

    covergroup cg;
      celln_o  : coverpoint n_randc.celln_o  { bins b1[] = {[0:16]}; }
      celln_u  : coverpoint n_randc.celln_u  { bins b1[] = {[0:16]}; }
      tmonin_o : coverpoint n_randc.tmonin_o { bins b1[] = {[0:4]}; }
      tmonin_u : coverpoint n_randc.tmonin_u { bins b1[] = {[0:4]}; }
      chgdis   : coverpoint n_randc.chgdis  ;
    endgroup      

    function new();
      cg = new();
    endfunction // new
    
  endclass

Could you elaborate more on what you mean by “sums the other coverpoints”?
You also mentioned that you want to know that celln_o has toggled 0 to 16, Do you mean toggle (transition) coverage of 0 to 16 or state coverage of all values of 0 to 16?

I will try my best to explain another way.
If I were to cross celln_o, celln_u, tmonin_o and tmonin_u, then the total combination would be 17x17x5x5=7225 combinations
But I only require 17+17+5+5=44 combinations.
How would one write a coverpoint for 17+17+5+5 ?

Honestly, it’s still unclear to me, but I can sense from your answer that you already have what you want covered in the coverpoints celln_o, celln_u, tmonin_o and tmonin_u.

But if you are interested in covering only some specific combinations of the values of celln_o, celln_u, tmonin_o and tmonin_u, you can create a cross and specify those combinations by ignoring any combination that doesn’t meet your requirement. Here is a simple example that you might look at

module m;
  
  logic [3:0] a, b;

  covergroup cg;
    // Cover values 0 to 7 of a
    cp_a : coverpoint a { bins val[] = {[0:7]};}
    // Cover values 0 to 14 of b
    cp_b : coverpoint b { bins val[] = {[0:14]};}

    aXb : cross cp_a, cp_b {
      // By default cross all values of 0 to 7 of a with 0 to 14 of b.
     
      // If you want to exclude some combinations
      ignore_bins ignore = binsof(cp_a) intersect {5};
      // If you want to define illegal combinations
      illegal_bins illegal = binsof(cp_b) intersect {15};
    }
  endgroup

  cg cg_inst = new();

endmodule

Actually, I would like to use get_coverage() to check if it hits 100% for the 44 combinations.

Currently, I have I coded this way:

for (int i=0;
	 n_inst.cg.celln_o.get_coverage() < 100.00 ||
	 n_inst.cg.celln_u.get_coverage() < 100.00 ||
	 n_inst.cg.tmonin_o.get_coverage() < 100.00 ||
	 n_inst.cg.tmonin_u.get_coverage() < 100.00;
	 i++) begin
      assert(n_inst.randomize());

So is there a better way I could write a coverpoint so that I can use get_coverage() on that and simplify the above for loop condition.

If that had been mentioned earlier, it would have been much more helpful :)
I would assume you also would like to get 100% on chgdis if that’s the case then why not calling get_coverage on the covergroup level i.e. n_inst.cg.get_coverage() < 100.0 ?
otherwise, one suggestion is splitting cg into 2 covergroups.

1 Like

Oh I didn’t know we could do that!
Thank you for your help.
Apologies for the unclear posts :)

1 Like