How to Sample data during Functional Coverage?

HI ,

I am getting error while performing Functional coverage check
“Covergroup having sampling event is not allowed to be sampled using the
predefined task ‘sample’.”

I have defined

covergroup covport @ (posedge clock) 
                coverpoint top ;

I have defined new instance before my initial begin block : - covport ck = new()
I am sampling it using handle in my initial begin : ck.sample()

In reply to prashish_143:

The error message you are getting does not seem correct with the code that you have shown. Please contact your vendor for support.

However, it is not usual practice to define both a sampling event (@posedge clk) and then call the sample() method of a covergroup.

Thanks Dave . I have 6 cover points in my design for which Functional coverage needs to be checked. I grouped 6 cover points under one cover group . then created new Instance ck and sampled it but it still giving me the same error -: " Cover group having sampling event is not allowed to be sampled using the predefined task ‘sample’ "

covergroup covport @(ganglion_if.cb);
option.auto_bin_max = 4; //Functional Coverage for Input top_left
coverpoint top_left;
coverpoint top_center;
coverpoint top_right;
coverpoint middle_left;
coverpoint middle_center;
coverpoint middle_right;
endgroup
covport ck = new()

initial begin
repeat(100)@(ganglion_if.cb)
begin
ck.sample();
end
endmodule

In reply to prashish_143:
The way you wrote your code, it would take a sample twice for each
@(ganglion_if.cb)
: once because of the way you declared your covergroup, and once because you are calling ck.sample(). Remove one of them.

Thanks Dave. It’s still not working as expected. When I removed clocking block I got functional coverage as Zero (0)
covergroup covport @(ganglion_if.cb);

If I remove other clocking block , I get syntax error
Following verilog source has syntax error :
“test.sv”, 70: token is ‘(’
ck.sample();
^

In reply to prashish_143:

It’s hard to help you with syntax errors when you show very little code. Try creating a much smaller self-contained example.

Thanks Dave.
The complete functional coverage code in my test bench is this -:

covergroup covport;

option.auto_bin_max = 4; //Functional Coverage for Input top_left
coverpoint top_left;
coverpoint top_center;
coverpoint top_right;
coverpoint middle_left;
coverpoint middle_center;
endgroup

covport ck = new;

initial begin
repeat(100)@(ganglion_if.cb)
begin
initialize();
driver();
ck.sample();
end
end
endprogram

In reply to prashish_143:

That is not a self-contained example. No one can compile that to try to repeat your problem.

The alternate method worked for me and I got 100% coverage. I defined different cover points in different cover groups and sampled them separately one by one. For each covergroup I got 100% coverage. This method is time consuming and makes a code lengthy but it works. Thanks Dave .

Some Important aspects which I found interesting to further explore is -:

  1. Creating array of different cover points in a single cover group ,then sampling them at clock edge and creating new instance for the array. This would be time efficient and optimize the code for complex designs which needs to be verified

  2. Sometimes the urgreport didn’t get updated. The best solution is to delete the previous urgreport every time we execute the coverage command.

hi,
This is Naveen.
Can you please tell me how to check whether the sample method is sampling data or not in functional coverage. In my code it is sampling only for 50 times. And remaining it is not sampling.