Cross coverage of a register with selected range and another coverpoint

Hi,

I have following requirement.

I have two coverpoints one is register of 72 bits and another is some variable. Like

bit [71:0] register_a;
int variable;
Covergroup cross_name ;
register_a : coverpoint { bins register_a_bin[18]={};}
variable : coverpoint {bins variable={4};}

 my requirement is, for register_a i should create 18 bins each bin is such that.
  if(0<=register_a[3:0]<=9) first bin should be created like this, similarly remaining 17 bins also  
  if(0<=register_a[7:4]<=9) second bin.

After creating 18 bins with above condition, I need to cross that 18 bins with variable.
Can you suggest me how can i create those 18 bins with that condition for register_a?

Thank you

In reply to cnu:
I can think of a brute force way to do this

covergroup cg_name;
  a: coverpoint register_a{
    {bins bin0 = a with {item[3:0] <= 9};
     bins bin1 = a with {item[7:4] <= 9};
     bins bin2 = a with {item[11:8] <= 9};
     ...
     bins bin17 = a with {item[71:68] <= 9};
    }
 v: coverpoint variable{
     bins bin0 = {4};
    }
 aXv: cross a,v;
endgroup

With a little more effort, you could probably come up with a function to express this in a single bin expression.

In reply to dave_59:

Hi Dave, I tried with your suggestion. but I am getting an error saying that
“a[3:0]”
The Slice operator cannot be applied to an object of this type.

the above error is coming for all of the bins.

Thank you

*In reply to cnu:*Try register_a instead.