返回介绍

29.4.3 Obtaining coverage information

发布于 2020-09-09 22:56:01 字数 5935 浏览 970 评论 0 收藏 0

To obtain coverage information, the vpi_get() function is extended with additional VPI properties that can be obtained from existing handles:

vpi_get(<coverageType>, instance_handle)

Returns the number of covered items of the given coverage type in the given instance. Coverage type is one of the coverage type properties described in Section 29.4.2. For example, given coverage type vpiStatement- Coverage, this call would return the number of covered statements in the instance pointed by instance_handle.

vpi_get(vpiCovered, assertion_handle)
vpi_get(vpiCovered, statement_handle)
vpi_get(vpiCovered, signal_handle)
vpi_get(vpiCovered, fsm_handle)
vpi_get(vpiCovered, fsm_state_handle)

Returns whether the item referenced by the handle has been covered. For handles that can contain multiple coverable entities, such as statement, fsm and signal handles, the return value indicates how many of the entities have been covered.

— For assertion handle, the coverable entities are assertions

— For statement handle, the entities are statements

— For signal handle, the entities are individual signal bits

— For fsm handle, the entities are fsm states

For assertions, vpiCovered implies that the assertion has been attempted, has succeeded at least once and has never failed. More detailed coverage information can be obtained for assertions by the following queries:

vpi_get(vpiAssertAttemptCovered, assertion_handle)

Returns the number of times the assertion has been attempted.

vpi_get(vpiAssertSuccessCovered, assertion_handle)

Returns the number of times the assertion has succeeded non-vacuously or, if assertion handle corresponds to a cover sequence, the number of times the sequence has been matched. Refer to Section 17.11.1 and 17.13 for the definition of vacuity.

vpi_get(vpiAssertVacuousSuccessCovered, assertion_handle)

Returns the number of times the assertion has succeeded vacuously. Refer to Section 17.11.1 and 17.13 for the definition of vacuity.

vpi_get(vpiAssertFailureCovered, assertion_handle)

Returns the number of times the assertion has failed. For any assertion, the number of attempts that have not yet reached any conclusion (success or failure) can be derived from the formula:

in progress = attempts - (successes + vacuous success + failures)

The example below illustrates some of these queries:

module covtest;
    bit on = 1, off = 0;
    logic clk;

    initial begin
        clk = 0;
        forever begin
            #10;
            clk = ~clk;
        end
    end

    always @(false) begin
        anvr: assert(on ##1 on); // assertion will not be attempted
    end

    always @(posedge clk) begin
        aundf: assert (on ##[1:$] off); // assertion will not pass or fail
        afail: assert (on ##1 off); // assertion will always fail on 2nd tick
        apass: assert (on ##1 on); // assertion will succeed on each attempt
    end
endmodule

For this example, the assertions will have the following coverage results:

Table 29-3: Assertion coverage results

vpiCoveredvpiAssertAttempt-
Covered
vpiAssertSuccess-
Covered
vpiAssertFailure-
Covered
anvrfalsefalsefalsefalse
aundffalsetruefalsefalse
afailfalsetruefalsetrue
apasstruetruetruefalse

The number of times an item has been covered can be obtained by the vpiCoveredCount property:

vpi_get(vpiCoveredCount, assertion_handle)
vpi_get(vpiCoveredCount, statement_handle)
vpi_get(vpiCoveredCount, signal_handle)
vpi_get(vpiCoveredCount, fsm_handle)
vpi_get(vpiCoveredCount, fsm_state_handle)

Returns the number of times each coverable entity referred by the handle has been covered. Note that this is only easily interpretable when the handle points to a unique coverable item (such as an individual statement); when handle points to an item containing multiple coverable entities (such as a handle to a block statement containing a number of statements), the result is the sum of coverage counts for each of the constituent entities.

vpi_get(vpiCoveredMax, assertion_handle)
vpi_get(vpiCoveredMax, statement_handle)
vpi_get(vpiCoveredMax, signal_handle)
vpi_get(vpiCoveredMax, fsm_handle)
vpi_get(vpiCoveredMax, fsm_state_handle)

Returns the number of coverable entities pointed by the handle. Note that this shall always return 1 (one) when applied to an assertion or FSM state handle.

vpi_iterate(vpiFsm, instance-handle)

Returns an iterator to all FSMs in an instance.

vpi_handle(vpiFsmStateExpression, fsm-handle)

Returns the handle to the signal or expression encoding the FSM state.

vpi_iterate(vpiFsmStates, fsm-handle)

Returns an iterator to all states of an FSM.

vpi_get_value(fsm_state_handle, state-handle)

Returns the value of an FSM state.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。
列表为空,暂无数据
    我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
    原文