A coverage group is a struct member defined by the cover keyword. A coverage group contains a description of data items for which data are collected over time. A coverage group has an associated event that tells when to sample and collect data. The event must be declared in the same struct as the coverage group. The syntax for a coverage group definition is as follows:
cover event-type [using coverage-group-option, ...] is {coverage-item-definition; ...};
Table 10-1 defines components of a coverage group definition.
event-type | The name of the group. This must be the name of an event type defined in the same struct. The event must not have been defined in a subtype. The event is the sampling event for the coverage group. Coverage data for the group are collected every time the event is emitted. The full name of the coverage group is struct-exp.event-type. The full name must be specified for the show cover command and other coverage commands and methods. |
coverage-group-option | Each coverage group can have its own set of options. The options can appear in any order after the using keyword. The coverage group options listed in Table 10-2 can be specified with the using keyword. |
coverage-item-definition | |
Coverage groups can be extended like other struct members. | |
The empty keyword can be used to define an empty coverage group that will be extended later, using a cover is also struct member with the same name. |
Table 10-2 shows options while defining coverage groups.
Example 10-1 shows sample coverage definitions that use coverage group options.
Example shows coverage group definition. <' type cpu_opcode: [ADD, SUB, OR, AND, JMP, LABEL]; struct inst { reset_done: bool; //Set by some struct in sys. Not shown. opcode: cpu_opcode; //Define enumerated type field. good_opcode: bool; //Define boolean. event info; //Event that defines coverage group name. //Coverage samples are collected when the //data_change event is emitted. cover info using //Define coverage group count_only, //count_only option. radix = HEX, //Display in hex format. weight = 10, //Relative weight compared to //other groups. when = (reset_done == TRUE) //Collect coverage only //when this bool //expression is true. is { item opcode; //Item opcode is to be covered. }; run() is also { //Emit the coverage events in the run() method. emit info; //Emit the event that causes coverage samples to //be taken. };}; //end of struct inst type cpu_state: [START, FETCH1, FETCH2, EXEC]; //Enumerated type. struct cpu { init_complete: bool; //Set by some struct in sys. Not shown. event state_change; //Define event for coverage group. cover state_change using //State machine coverage group. text = "Main state-machine", //Name of coverage group. weight = 5, //Relative weight when = (init_complete == TRUE) //Collect sample only if //bool exp is true. is { //Coverage of HDL state machine state variable. item st: cpu_state = '~/top/cpu/main_cur_state'; }; run() is also { //Emit the coverage events in the run() method. emit state_change; //Emit the event that causes coverage }; //samples to be taken. }; '> End of e code
A coverage group can also be extended like any other struct member by means of the is also keyword. Example 10-2 shows the extension of the coverage group defined in Example 10-1.
Example shows how to extend coverage groups <' extend inst { cover info is also { //Extend the coverage group. item good_opcode; //Item good_opcode is also to be covered //in addition to item opcode. }; }; //end of extension of struct inst '>
There are three types of items in a coverage group: basic coverage items, transition items, and cross items. Figure 10-1 shows the three types of items in a coverage group. These items are discussed in detail in the following sections.