Writing functions in Covergroup

All I am working on understanding how to use functions to create coverpoint and cross bins. Consider the following example code:

module top;

logic [5:0] small_bv;

covergroup cg;
  cp : coverpoint small_bv {
    bins b0 = {'d0};
    bins b_interting[] = {['d1:'d62]} with (bins_interesting_func(item));
    bins  b63 = {'d63};
  }
end group

function automatic bins_interesting_func(logic [5:0] val);
  automatic boolean not_prime = 0;
  if (int'(val) > 1) begin
    for(int i=2; i < int'(val)/2; i++) begin
      if ((int'(val) % i) == 0) begin
        not_prime = 1;
        break;
      end
    end
  end
  if (not_prime == 0) return 1 else return 0;
endfunction

initial begin
  for (int sim_loop=0; sim_loop<256; sim_loop++) begin
    small_bv = $urandom;
  end
end

endmodule

With this example I have a small bit_vector in which I am randomizing the values. I am creating a dynamic list of bins based on if the value of the variable for the coverpoint is a PrimeNumber.

Yes I know the PrimeNumber search is brute force, you cannot use the $sqrt operator inside a covergroup function call?

Questions:
Is the word “item” a SV keyword of some sort meaning the variable referenced in the coverpoint?

The return type of the function is not declared, I can see in my analysis of running this code (BTW this was hand transcribed from another system so there may be a typo or two) that I do indeed get a bunch of bins that are only the prime values. I got what I wanted but I need to understand the mechanisms better for my real problem.

I will be posting an update as I try to get a function to build bins for the cross product, see my previous example: Building Sparse Cross Coverage Bins for arrays of enum'ed datatypes
for some ideas of what I am trying to solve.

Thanks in advance to anyone who can answer my couple of questions.
TomT…

Did you make any progress on this?
This is something that interests me as well.

As for your question:

Is the word “item” a SV keyword of some sort meaning the variable referenced in the coverpoint?

no, the keyword item is a reference to the item from the array manipulation methods, but I would say you should do something like this:

covergroup cg;
  // not tested!!!
  cp : coverpoint small_bv {
    bins b0 = {'d0};
    bins b_interting[] = {['d1:'d62]}.find() with (bins_interesting_func(item));
    bins  b63 = {'d63};
  }
endgroup

The return of the array find() method is a queue filled by the return value of the bins_interesting_func(item) where item is the one iterated on.
See: 7.12.4 Iterator index querying.

As mentioned in the code, it is not tested, but I don’t see why it shouldn’t work and it would be nice if someone can chime in and comment.