有没有办法保护covergroup bins的创建

Is there a way to guard the creation of covergroup bins

有没有办法保护创建明确命名的 bin,如此处所示

coverpoints_bins: coverpoint signal_a
bins a1 = {1};
bins a2 = {2};
bins a4 = {4}; <--- create bin a4 only if parameter "CREATE_A4 is 1"

例如这样的事情:

coverpoints_bins: coverpoint signal_a
bins a1 = {1};
bins a2 = {2};
bins a4 = {4} create_iff(CREATE_A4 == 1); 

注意:create_iff 只是一些伪代码函数,用于防止创建 bin,除非条件为真

因为据我所知,iff 条件不能防止垃圾箱的创建,但 iff 只能防止垃圾箱命中

您可以使用 with 子句来 select bins

bins a4 = {4} with (CREATE_A4 == 1); 

这可能会生成一条警告消息,提示您设置的垃圾箱为空。另一种方法是使用 bin 集合数组。

int my_bins[];
...
if (CREATE_A4 == 1) // execute this before constructing the covergroup
   my_bins = {1,2,4};
else
   my_bins = {1,2};

...
coverpoints_bins: coverpoint signal_a
bins a[] = my_bins;