I recently posted an article called Setting up and using Code Coverage. As I mentioned there, code coverage is useful for seeing what portions of your code have been exercised. What code coverage can’t do though is to ensure functional correctness – this is where functional coverage comes into play. Functional coverage allows you to determine when you have exposed your code to a sufficient enough set of stimulus, including hitting corner cases, that you have a high confidence in its functionality.
My background includes experience as a hardware verification engineer, where the teams I was part of used both code coverage and functional coverage as essential tools in test development. In the Wikipedia section on SystemVerilog (a hardware description and verification language) there is a nice write-up on Coverage where the difference between code coverage and functional coverage is discussed.
What is a Coverpoint?
I wanted to employ some functional coverage as a guide to my unit test development. In the SystemVerilog language mentioned above, they have the concept of coverpoints and covergroups (group of coverpoints). I found a nice document called SystemVerilog Testbench Automation Tutorial where there is some good information about these concepts starting in the section titled “Functional Coverage”.
A coverpoint is essentially a measurement point where an event (such as values taken on by a variable) can be recorded, along with bins for how many times specific values (or range of values) occurred for that event.