Search code examples
validationcode-coveragesystem-verilog

How to generate autobins for all variables of a struct easily


Say I have the following covergroup and struct:

typedef struct {
    int x;
    bit [17:0] y;
    logic z;
    // ... assume many more variables
} a2b_req_t;

a2b_req_t a2b_req;

covergroup a2b_req_cg @(a2b_req_event);
    A2B_REQ: coverpoint a2b_req;
endgroup

The above is syntactically incorrect, because you cannot have a coverpoint on a struct, but only its member variables. Without creating coverpoints for each member variable, how can I generate autobins for each member variable?


Solution

  • There's no easy way to do this other than to explicitly write a coverpoint for each member variable.