<- Click here to Toggle
Chapter 1-5
Chapter 5-10
Chapter 10-15
Chapter 15-20
Chapter 20-25
Chapter 25-30
SystemVerilog Coverage API - Miscellaneous
$coverage_get(coverage_type, scope_def, modules_or_instance)
This function obtains the current coverage value for the given coverage type over the given portion of the hierarchy.
The scope of this function is specified as per $coverage_control.
The return value is an integer, with the following meanings.
2 (‘SV_COV_OVERFLOW)
The value exceeds a number that can be represented as an integer.
-1 (‘SV_COV_ERROR)
An error occurred (typically due to using incorrect arguments).
0 (‘SV_COV_NOCOV)
No coverage is available for that coverage type on that/those hierarchy(ies).
+pos_num
The maximum coverage number (where pos_num > 0), which is the sum of all coverable items of that type over the given hierarchy(ies).
$coverage_merge
$coverage_merge(coverage_type, "name")
This function loads and merges coverage data for the specified coverage into the simulator. name is an arbitrary string used in an implementation-specific way, to locate the appropriate coverage database, i.e., tools are allowed to store coverage files any place they want with any extension. If name does not exist or does not correspond to a coverage database from the same design, an error shall occur.
The return values from this function are:
‘SV_COV_OK
the coverage data has been found and merged.
‘SV_COV_NOCOV
the coverage data has been found, but did not contain the coverage type requested.
‘SV_COV_ERROR
the coverage data was not found or it did not correspond to this design, or another error.
$coverage_save
$coverage_save(coverage_type, "name")
This function saves the current state of coverage to the tool’s coverage database and associates it with the given name. This name will be mapped in an implementation-specific way into some file or set of files in the coverage database. Data saved to the database shall be retrieved later by using $coverage_merge and supplying the same name.
The return values from this function are:
‘SV_COV_OK
The coverage data was successfully saved.
‘SV_COV_NOCOV
No such coverage is available in this design (nothing was saved).
‘SV_COV_ERROR
Some error occurred during the save. If an error occurs, the tool shall automatically remove the coverage database entry for name to preserve the coverage database integrity.
FSM recognition
Coverage tools need to have automatic recognition of many of the common FSM coding idioms in Verilog/ SystemVerilog. However, the standard does prescribe a means by which non-automatic FSM extraction occurs.
Identification of an FSM consists of identifying the following items:
- » The state register (or expression)
- » The next state register (this is optional)
- » The legal states.
