Hello again, AFAIK, there is no construct within the language itself to "generate" coverage groups or coverage points automatically from corresponding constraints. You'd have to use other means to accomplish something like that, e.g. using scripts that parse your code looking for constraints that are to be mapped to coverage points.
Concerning your other matter, I wasn't clear exactly on your coverage objective. From your initial example I gathered that you just wanted to know even vs. odd. If you want to capture the actual even values that have been sampled, in a scalable way, explore the following options. Note that these are merely suggestions, i.e. I have not tried them to see whether they give you exactly what you want. Also, for wider rdata (e.g. 8 bits or wider) you should ask yourself whether you are really interested in covering every single even value in the corresponding range. I doubt it.
covergroup Covgrp; rdata_even_values : coverpoint (rdata) iff (rdata % 2 == 0) { bins values[] = default; } endgroup
Problem with the above is that default bins are not included in coverage calculations, according to the LRM.
You could try the bin specification "bins values[] = {0 : $ }" instead, but now you have to find a way to discard the odd values. Using an ignore_bins here has scalability issues again. In Vera, there used to be a sort of "step" operator that can be used to specify incremental but non-contiguous ranges. This operator is not available in SystemVerilog.
Another possible solution, using automatic bin creation (please consult the LRM for details):
covergroup Covgrp; rdata_even_values : coverpoint (rdata) iff (rdata % 2 == 0); option.auto_bin_max = endgroup
I believe though that the bins are pre-created and hence the problem would again be the inclusion of odd value bins.
Lastly, as mentioned, likely you are not interested in all even values of a large range. Consider then something like
covergroup Covgrp; even_rdata_min : coverpoint (rdata == 0); even_rdata_max : coverpoint (rdata == 2**$bits(rdata)-2); even_rdata_almost_min : coverpoint (rdata == 2); even_rdata_almost_max : coverpoint (rdata == 2**$bits(rdata)-4); even_rdata_others : coverpoint (rdata >= 4 and rdata <= 2**$bits(rdata)-6); endgroup
I guess the point is that you may need to be "creative" with coverage implementation. All the more reason to leverage the full SV OOP framework by using designated coverage classes that contain coverage group instances.
Good luck, Hans |