Coverage

Let’s assume :
cp1 : coverpoint a {
bins min_val = {0};
bins max_val = {2047};
bins mid_val[4] = {[0+1:2047-1]};
}
cp2 : coverpoint b {
bins min_val = {0};
bins max_val = {2047};
bins mid_val[4] = {[0+1:2047-1]};
}
cp3 : c {
bins min_val = {0};
bins max_val = {2047};
bins mid_val[4] = {[0+1:2047-1]};
}
Can I change it to more brief syntax ?
cp1 : coverpoint a,b,c {
bins min_val = {0};
bins max_val = {2047};
bins mid_val[4] = {[0+1:2047-1]};
}

In reply to alexd555:

Can I change it to more brief syntax ?


cp1 : coverpoint a,b,c {
bins min_val = {0};
bins max_val = {2047};
bins mid_val[4] = {[0+1:2047-1]};
}

No, This isn’t valid. If you want reduce the code then create a macro.

`define COV_POINT(VAR,MIN,MAX)  coverpoint VAR { \
				bins min_val = {MIN}; \
			        bins max_val = {MAX};\
				bins mid_val[4] = {[MIN+1:MAX-1]};\
                             }



    covergroup abc;
      cp1 : `COV_POINT(a,0,2047)
      cp2 : `COV_POINT(b,0,2047)
      cp3 : `COV_POINT(c,0,2047)
    endgroup

In reply to alexd555:

If this is your only requirement (i.e. you don’t plan to cross these coverpoints), the move the covepoint into a separate covergroup.

covergroup cvrg (ref bit [10:0] arg);
  cp1 : coverpoint arg {
  bins min_val = {0};
  bins max_val = {2047};
  bins mid_val[4] = {[0+1:2047-1]};
}
cvrg cg[3];

cg[0] = new(a);
cg[1] = new(b);
cg[2] = new(c);