<- Click here to Toggle
Chapter 1-5
Chapter 5-10
Chapter 10-15
Chapter 15-20
Chapter 20-25
Chapter 25-30
SystemVerilog Assertion API - Static Information
This section defines how to obtain assertion handles and other static assertion information.
Obtaining Assertion Handles
SystemVerilog extends the VPI module iterator model (i.e., the instance) to encompass assertions. The assertion API permits iteration on assertions from interface instance handles and obtaining static information on assertions used in interfaces.
Iterate all assertions in the design: use a NULL reference handle (ref) to vpi_iterate() , e.g.,
itr = vpi_iterate(vpiAssertion, NULL);
while (assertion = vpi_scan(itr)) {
/* process assertion */
}
Iterate all assertions in an instance: pass the appropriate instance handle as a reference handle to
vpi_iterate() ,
itr = vpi_iterate(vpiAssertion, instanceHandle);
while (assertion = vpi_scan(itr)) {
/* process assertion */
}
Obtain the assertion by name: extend vpi_handle_by_name to also search for assertion names in the appropriate scope(s), e.g.,
vpiHandle = vpi_handle_by_name(assertName, scope)
To obtain an assertion of a specific type, e.g. cover assertions, the following approach should be used:
vpiHandle assertion;
itr = vpi_iterate(vpiAssertionType, NULL);
while (assertion = vpi_scan(itr)) {
if (vpi_get(vpiAssertionType, assertion) == vpiCoverType) {
/* process cover type assertion */
}
}
Obtaining static assertion information
The following information about an assertion is considered to be static.
- » Assertion name
- » Instance in which the assertion occurs
- » Module definition containing the assertion
- » Assertion type
- » Sequence
- » Assert
- » Cover
- » Property
- » Immediate Assert
- » Assertion source information: the file, line, and column where the assertion is defined.
- » Assertion clocking block/expression.
Using vpi_get_assertion_info
Static information can be obtained directly from an assertion handle, as shown below.
typedef struct t_vpi_source_info {
PLI_BYTE8 *fileName;
PLI_INT32 startLine;
PLI_INT32 startColumn;
PLI_INT32 endLine;
PLI_INT32 endColumn;
} s_vpi_source_info, *p_vpi_source_info;
This call obtains all the static information associated with an assertion.
The inputs are a valid handle to an assertion and a pointer to an existing s_vpi_assertion_info data structure. On success, the function returns TRUE and the s_vpi_assertion_info data structure is filled in as appropriate.
Assertions can occur in modules and interfaces: for assertions defined in modules, the instance field in the s_vpi_assertion_info structure shall contain the handle to the appropriate module or interface instance.
Extending vpi_get() and vpi_get_str():
In addition to vpi_get_assertion_info , the following existing VPI functions are also extended:
vpi_get(), vpi_get_str()
vpi_get() can be used to query the following VPI property from a handle to an assertion:
vpiAssertionDirective returns one of vpiSequenceType, vpiAssertType, vpiCoverType, vpiPropertyType, vpiImmediateAssertType
vpiLineNo returns the line number where the assertion is declared.
vpi_get_str() can be used to obtain the following VPI properties from an assertion handle:
vpiFileName returns the filename of the source file where the assertion was declared.
vpiName returns the name of the assertion.
vpiFullName returns the fully qualified name of the assertion.
