Create conditional coverpoints

In reply to DavidRosenwasser:

A piece of advice: it would be much better to use parameters or an enumerated type top represent all these values. Then if the values changes you only have to make an edit in one place

enum bit [31:0] {
	  CTRL_REG          = 32'hB000_0000,
	  BAUD_RATE_REG     = 32'hB000_0004,
	  BUFFER_SIZE_REG   = 32'hB000_0008,
	  INTERRUPT_ENABLE  = 32'hB000_000C,
          ...
} REG_ADDR;
enum bit [31:0] {
          BAUD_10MHZ          = 32'h0000_079E,
          START_STATE_MACHINE = 32'h1111_1111,
          ...
} REG_COMD;

covergroup cov_model_cg;
       // cast needed if waddr and wdata are not already enum types. coverpoint contains 
       // only bins for enumerated values. 
       CADDR: coverpoint REG_ADDR'(configuration.waddr); 
       CCOMD: coverpoint REG_COMD'(configuration.wdata); 
       cross CADDR,CCOMD;
endgroup

If you do not use enumerated types, you will have to create an explicit bin for each value as you did in your original example.

This assumes all registers accept all commands. If there are a few that don’t, you would have to put an ignore_bin in the cross

cross CADDR,CCOMD {
  ignore_bins X_Y = binsof(CADDR) intersect(X_REG) && binsof(CCOMD) intersect (Y_command);
}

If it starts getting more complicated than that, you might consider creating sets of commands to cross, or forgetting doing the cross altogether and creating a coverpoint for each register/command combination.