Cross coverage

Hi,

I have some difficulty in specifying bins for cross coverage:

covergroup cg;
PM: coverpoint port_mode{
bins port_mode_0 = { 0 };
bins port_mode_1 = { 1 };
}
PS0: coverpoint port_speed0{
bins port_speed0 = { [0:6] };
}
PS1: coverpoint port_speed1{
bins port_speed1 = { [0:6] };
}
endgroup

I need to define cross between PM and PS0, PS1:

The conditions are like:
When port_mode is 0, PS0 can assume any value from 0 to 6, but, PS1 cannot have any value (ie PS1 is disabled)

When PM is 1, either PS0, PS1 or both PS0 & PS1 are enabled but they can only have values from 0 to 4 only.
i.e. PM1 & PS0(0,1,2,3,4)
PM1 & PS1(0,1,2,3,4)
PM1&PS0(0,1,2,3,4)&PS1(0,1,2,3,4)
Can somebody please help me how I can do this?

Thanks,

You need to define what it means to have PS0 & PS1 enabled or disabled. i.e. how does PS1 not have a value?

It might help to just think about the crosses you don’t want and ignore them

cross1: cross PM, PS0, PS1 {
  ignore_bins ignore_ = binsof(PM.port_mode_1) &&
              ( binsof(PS0) intersect {[5:6]} || binsof(PS1) intersect {[5:6]} ) 
}