A parameterized covergroup can be used to sample values of different variables .
covergroup cg ( ref int x , ref int y ); // ' ref ' type arguments
coverpoint x ;
coverpoint y ;
cg cg_inst1 = new( a , b ) ;
cg cg_inst2 = new( c , d ) ;
So essentially we define the covergroup once and pass different actual arguments to sample .
However LRM Section 19.8.1 Overriding the built-in sample method , mentions the following ::
covergroup p_cg with function sample(bit a, int x); // input instead of ' ref ' type
cross x, a;
endgroup : p_cg
It also states the following ( which I am not fully clear about ) ::
"Overriding the predefined sample() method with a triggering function that accepts arguments facilitates
sampling coverage data from contexts other than the scope enclosing the covergroup declaration. For
example, an overridden sample method can be called with different arguments to pass directly to a
covergroup the data to be sampled from within an automatic task or function, or from within a particular
instance of a process, or from within a sequence or property of a concurrent assertion"
I have 3 questions ::
(1) Explanation for the above LRM quote
(2) Advantages of overridden sample() over parameterized covergroup and vice-versa
(3) Does the argument have to be of input direction always when overriding sample() ?