Create conditional coverpoints

Hello – I’m trying to do 2 things:

  1. Check that every writable register has been written to
  2. Check that the specific data of interest (e.g. enable, set clock rate, reset, etc.) has been written to the writable registers

I’m not sure how to create a conditional coverpoint to check #2. Filtered example below:

  
covergroup cov_model_cg;    
    coverpoint configuration.waddr
    {    
	  bins CTRL_REG              = {32'hB000_0000};
	  bins BAUD_RATE_REG         = {32'hB000_0004};
	  bins BUFFER_SIZE_REG       = {32'hB000_0008};
	  bins INTERRUPT_ENABLE      = {32'hB000_000C};
          .
          .
          .
    }

    coverpoint configuration.wdata
    {
      // bins BAUD_10MHZ = {'h0000_079E} with (configuration.waddr == BAUD_RATE_REG);  // does not work, most preferred
      // bins BAUD_10MHZ = {'h0000_079E} with (configuration.waddr == 32'hB008_2004); // does not work
    }      
    cross configuration.waddr, configuration.wdata {
	//  bins START_STATE_MACHINE = binsof (CTRL_REG) intersect {32'h1111_1111}; // does not work
        //  bins START_STATE_MACHINE = binsof (32'hB000_0000) intersect {32'h1111_1111}; // does not work
	}


In the example above, I’m trying to create bins for the condition when the data and address is what I’m interested in (10MHZ baud rate selected, state machined started). Not sure if this is possible, or if cross coverage/with/iff will work.

Thanks in advance.

In reply to DavidRosenwasser:

It looks like you want to use a cross, but I’m not certain. What are constants 32’h1111_1111, 32’hB008_2004, 'h0000_079E supposed to mean?

In reply to dave_59:

When data 32’h1111_1111 is written to address 32’hB000_0000 (CTRL_REG), the state machine that transmits the payload for some serial interface begins. I want to capture that data & address combination to ensure that my randomized and/or directed testing covers that condition (state machine start).

Similarly, when data 32’h0000_079E is written to address 32’hB000_0004 (BAUD_RATE_REG), the payload will transmit with a 10MHz clock (just as an example). I want to capture that data & address combination as well to show that I’ve executed a payload transmission with a 10MHz clock.

Thanks for responding

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.

In reply to dave_59:

Thanks for the answer. Conceptually that works for me. However when I try it I get a SIGSEGV (Bad handle/ref) error, which to do this day I’m not sure how to debug.


	enum bit [31:0] {
	        BAUD_RATE_REG =  32'hB008_2000 , 
	        CTRL_REG =  32'hB008_2004 
	} REG_ADDR; 

	enum bit [31:0] {
		BAUD_10MHZ = 32'h0000_079E,
		START_SM = 32'h1111_1111
	} REG_DATA; 

  covergroup axi_cov_model_cg;
	ADDR_CP: coverpoint REG_ADDR'(configuration.waddr);  //SIGSEGV error

What does the

coverpoint REG_ADDR'(configuration.waddr);

line do? Form an array?

In reply to DavidRosenwasser:

The cast is needed to make sure the coverpoint expression is an enumerated type if
waddr
was not already declared that way. The bad handle error probably means
configuration
was null at the time you called sample().

Regarding how to debug a null handle, that is easily dealt with by setting breakpoint in your code, which tool specific. This Mentor/Siemens EDA sponsored public forum is not for discussing tool specific usage or issues. Please read your tool’s user manual or contact your tool vendor directly for support.