Functional coverage is a critical aspect of hardware verification, allowing engineers to validate whether all intended design functionalities are exercised during simulation. SystemVerilog provides a wide range of coverage options to control and customize the behavior of functional coverage. These options empower engineers to fine-tune their coverage collection, exclude irrelevant scenarios, and focus on critical conditions.
In this article, we’ll explore the key coverage options available in SystemVerilog and how they can be used effectively.
Key Coverage Options in SystemVerilog
1. option.weight
The option.weight setting allows you to assign a weight to a covergroup or coverpoint. By default, all coverage points contribute equally to overall coverage, but weight lets you prioritize specific coverpoints or covergroups.
Usage:
covergroup cg;
coverpoint opcode {
option.weight = 2; // This coverpoint has double the weight.
}
coverpoint address {
option.weight = 1; // Default weight.
}
endgroup
Here:
opcodewill contribute twice as much to the overall coverage percentage asaddress.
2. option.goal
The option.goal setting specifies the coverage percentage required for a particular coverpoint or covergroup to be considered “complete.” By default, the goal is 100%, but this can be adjusted based on design requirements.
Usage:
covergroup cg;
coverpoint data {
option.goal = 90; // Aim for 90% coverage.
}
endgroup
In this case:
- The
datacoverpoint is deemed complete when 90% of its bins are hit.
3. option.per_instance
The option.per_instance setting determines whether coverage is tracked separately for each instance of a covergroup. By default, coverage is aggregated across all instances, but enabling this option provides per-instance data.
Usage:
covergroup cg;
option.per_instance = 1; // Track coverage per instance.
coverpoint opcode;
endgroup
This is useful in multi-instance environments, such as designs with multiple processing cores, where you want to measure coverage independently for each core.
4. option.comment
The option.comment setting allows you to add descriptive comments to coverpoints or covergroups. This is primarily for documentation purposes, helping reviewers understand the intent of the coverage.
Usage:
covergroup cg;
coverpoint opcode {
option.comment = "Tracks opcode values from 0 to 15.";
}
endgroup
This annotation doesn’t affect simulation but provides clarity for reports and debugging.
5. option.name
The option.name setting overrides the default name assigned to a coverpoint or covergroup in coverage reports. This is useful for simplifying or standardizing naming conventions.
Usage:
covergroup cg;
coverpoint data {
option.name = "Data Coverage Point";
}
endgroup
6. option.auto_bin_max
The option.auto_bin_max setting limits the number of automatically created bins for a coverpoint. By default, SystemVerilog creates a bin for every unique value of a variable, but this can lead to excessive bin creation for variables with large ranges.
Usage:
covergroup cg;
coverpoint addr {
option.auto_bin_max = 10; // Limit bins to 10.
}
endgroup
This helps manage memory and simulation performance when dealing with large variable ranges.
7. option.cross_auto_bin_max
Similar to option.auto_bin_max, this setting applies specifically to cross coverage. It limits the number of automatically created bins for a cross.
Usage:
covergroup cg;
coverpoint opcode;
coverpoint status;
cross opcode, status {
option.cross_auto_bin_max = 20; // Limit cross bins to 20.
}
endgroup
This is crucial when dealing with combinations of variables that result in large bin counts.
8. option.at_least
The option.at_least setting specifies the minimum number of hits required for a bin to be considered “covered.” By default, a single hit suffices, but this can be increased to ensure robustness.
Usage:
covergroup cg;
coverpoint opcode {
option.at_least = 3; // Each bin must be hit at least 3 times.
}
endgroup
This is particularly useful for designs where rare events should be exercised multiple times to ensure reliability.
9. option.strobe
The option.strobe setting determines the signal’s sampling edge for coverage. By default, sampling occurs on the active edge of the covergroup’s clock. The option.strobe can be used to define a custom sampling event.
Usage:
covergroup cg @(posedge clk);
coverpoint opcode {
option.strobe = @(posedge another_clk); // Sample on a different clock.
}
endgroup
This provides flexibility in environments with multiple clocks or asynchronous behavior.
10. option.merge_instances
The option.merge_instances setting controls whether coverage from multiple instances of a covergroup is combined into a single report. By default, this option is enabled.
Usage:
covergroup cg;
option.merge_instances = 0; // Do not merge instance coverage.
coverpoint data;
endgroup
Disabling instance merging is helpful when you want detailed insights into each covergroup instance.
Combining Coverage Options
Coverage options can be combined to create a highly customized coverage model. For example:
covergroup cg @(posedge clk);
coverpoint opcode {
bins opcode_bins[] = {[0:3], [4:7], [8:15]};
option.weight = 2;
option.goal = 95;
option.auto_bin_max = 5;
}
endgroup
In this setup:
opcodeis given a higher priority withweight = 2.- The goal for this coverpoint is reduced to 95%.
- Bins are capped at 5 to manage simulation performance.