user1978273
user1978273

Reputation: 514

How to add values from a queue to systemverilog functional coverage ignore_bins/illegal_bins?

I am writing a configurable SystemVerilog functional coverage coverpoint. I have an enum response_t as follows:

typedef enum bit [1:0] {OK, ERR1, ERR2, ERR3} response_t;

I want to add all the entries of enum to individual coverpoint bins as follows:

response_t r;

r_cp : coverpoint r {
  bins ok = {OK};
  bins err_1 = {ERR1};
  bins err_2 = {ERR2};
  bins err_3 = {ERR3};
}

The coverpoint above is generic. Now I want to make it configurable for users so that users can optionally add few of these bins to ignore/illegal by adding the values to a queue as follows:

class cfg;
  ...
  response_t ignore_bins_q[$];
  response_t illegal_bins_q[$];
endclass

Now I tried to modify my coverpoint as follows:

r_cp : coverpoint r {
  bins ok = {OK};
  bins err_1 = {ERR1};
  bins err_2 = {ERR2};
  bins err_3 = {ERR3};
  ignore_bins ignore = {cfg.ignore_bins_q};
  illegal_bins illegal = {cfg.illegal_bins_q};
}

The tool I am using is vcs, and I get the following error when I tried it this way:

Expression of type 'array' used in left value range is not legal.

How can I work around this problem?

Upvotes: 1

Views: 1048

Answers (1)

dave_59
dave_59

Reputation: 42698

Get rid of the {}'s

ignore_bins ignore = cfg.ignore_bins_q;
illegal_bins illegal = cfg.illegal_bins_q;

Remember that the queues need to be populated by the time the covergroup gets constructed.

Upvotes: 1

Related Questions