Covergroup with sampling event

Hi ,

I have tried to sample the cover group by having a sample event @(posedge clk) it was showing errors like


Error-[SNACGWC] Illegal sample call for covergroup
testbench.sv, 28
func_coverage, "c_group"
  Covergroup having sampling event is not allowed to be sampled using the 
  predefined task 'sample'.

I just used a basic example below
edaplayground

So can I know why we can’t use a sample event for covergroup for sampling
Are they is any way we can sample even using the event ?

In reply to SUNODH:

Although not a good practice, there is nothing illegal about declaring a sampling event and calling the sample method. Try a different tool.

In reply to dave_59:

Hi dave_59 ,

You said it was not a good practice can I know why it was not?

and working for other tools thank you for your help.

Thanks & Regards
Sunodh

In reply to SUNODH:

You said it was not a good practice can I know why it was not?

In your code you have mentioned the sampling event already ::


 covergroup c_group @( posedge clk );  //  Samples automatically on each posedge of clk 
   .......

Since the sampling is done automatically there is no need for user to call sample() .