Creating Specific coverpoint bins based on another fields - Functional Coverage

Hi,
I got to do the coverage analysis in the Monitor of my UVC.
Following is the piece of code

class es_monitor extends uvm_monitor;
  bit[7:0] seq_num;    // 256 values
  bit[15:0] dest_addrs;     // Out of 65536 values, only 256 are valid
  bit[15:0] valid_dest_addr[256];   // This array determines the valid 256 destination addresses

  covergroup cov1;
    des_addr: coverpoint dest_addrs    // Is it valid to have this kind of coverpint ??
              {
               addrs_bins[] = { valid_dest_addr[0], valid_dest_addr[1] ............ valid_dest_addr[255] }  // VALID ??
              }
    cp_seq_num: coverpoint seq_num;
    cross des_addr, cp_seq_num;        // For every valid destination, all seq num are generated or not
  endgroup : cov1

  // code....
endclass

I have embedded covergroup.
My goal is to cover that for every valid destination (256 valid destinations) all the sequence numbers are generated or not? (cross coverage)
How can I create only 256 valid coverage bins for ‘dest_addrs’ based on ‘valid_dest_addr’ array field

FYI: valid_dest_addr[256] array will be populated using the ‘config’ in the run_phase

Can any one help me in writing the covergroup and coverpoints for my scenario ?

Regards,
Santosh Kumar

In reply to santosh_kumar_vangala:

You can do something like the following to create bins for values inside the valid_dest_addr


     bins addrs_bins[] = des_addr with (item inside {valid_dest_addr} );

However the glitch here is that the Covergroup has to be constructed (via new()) after the valid_dest_addr array is populated, otherwise it will be meaningless.

In reply to ayehia:
And another glitch is if a covergroup is embedded in a class, it must be constructed inside the constructor of the class. So if you are unable to get the config while construing the class, you will have to define the covergroup outside this class (either a standalone covergroup, or defined in another class that gets constructed when you are able to construct the covergroup.

Note, you probably just want

 bins addrs_bins[] = valid_dest_addr;

In reply to dave_59:

Thanks for the response Dave and ayehia

As per your suggestion, I decided to define the covergroup outside the class

covergroup cov1(ref bit[15:0] dest_addrs, input bit[15:0] valid_dest_addr); // CORRECT ???
                                           
  des_addr: coverpoint dest_addrs { addrs_bins[] = valid_dest_addr; }
endgroup : cov1

class es_monitor extends uvm_monitor;
  bit[7:0] seq_num;    // 256 values
  bit[15:0] dest_addrs;     // Out of 65536 values, only 256 are valid
  bit[15:0] valid_dest_addr[256];   // This array determines the valid 256 destination addresses
   // code....
endclass

When I’ve compiled above code, a compilation error is arising
valid_dest_addr : Invalid coverpoint/cross name specified in cover bin defintion

Is my covergroup definition correct?

In reply to santosh_kumar_vangala:

Probably you should use the variable “valid_dest_addr” also as a ref bit when you define the covergroup outside the class.