In reply to MICRO_91:
The purpose of ref arguments for any method, whether it be the constructor of a covergroup or a task, is that the values of these arguments are tracked for the the lifetime of the covergroup or task call. input arguments copy their values at the point in time the method gets called and never change value until the method gets called again. For the sample() method, it would not make any difference if the arguments were input or ref, they are copying the values at the point in time the sample calling.
These covergroup arguments give you 3 layers of interaction
- values for the type
- values for the instance
- values for the sample
bit W,X,Y,Z,Q;
covergroup cg(bit a, ref bit b) with sample(bit c);
option.per_instance=1;
cp1: coverpoint W { // type covers W
bins hit = {a}; // bin value is set at construction of coverpoint
}
cp2: coverpoint b; // instance covers whatever is passed to b
cross cp1,cp2,c; // sample covers whatever is passed to c
endgroup
cg cg1 = new(0,X); // cp2 tied to X
cg cg2 = new(1,Y); // cp2 tied to Y
...
cg1.sample(Z); // cross W.hit(0), X, Z
cg2.sample(Q); // cross W.hit(1), Y, Q