📄 00339.html
字号:
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Frameset//EN">
<html>
<head>
<title>28.4.2 Placing assertions callbacks</title>
<meta http-equiv="Content-Type" content="text/html; charset=GB2312" />
<meta name="generator" content="Doc-O-Matic" />
<meta http-equiv="Content-Style-Type" content="text/css" />
<link rel="STYLESHEET" href="default.css" type="text/css" />
<script type="text/javascript" src="scripts.js"></script>
</head>
<body class="Element700" onload="onBodyLoadEx('systemverilog31a.html', 'topic', '00339.html');" onmousedown="onBodyMouseDown();">
<!-- Begin Popups -->
<div class="Element801" id="popup00524">
<div class="Element800">
<div class="Element14">
链接</div>
<div class="Element11">
<div class="Element10">
<a href="00337.html" target="topic">28.4 Dynamic information</a></div>
</div>
</div>
</div>
<!-- End Popups -->
<!-- Begin Page Header -->
<div class="Element710" id="areafixed">
<div class="Element92">
<table width="100%" cellspacing="0" cellpadding="0">
<tr><td width="33%">
<div class="Element1">
<a href="#" onmousedown="showPopup(this, 'popup00524');"><img src="seealsolink.png" border="0" alt="" title=""></a> SystemVerilog 3.1a语言参考手册</div>
</td><td width="34%">
<div class="Element2">
</div>
</td><td width="33%">
<div class="Element90">
<a href="00338.html" target="topic"><img src="btn_prev_lightblue.gif" border="0" alt="Previous" title="Previous" onmouseover="switchImage(this, 'btn_prev_lightblue_hover.gif');" onmouseout="switchImage(this, 'btn_prev_lightblue.gif');"></a><a href="00337.html" target="topic"><img src="btn_up_lightblue.gif" border="0" alt="Up" title="Up" onmouseover="switchImage(this, 'btn_up_lightblue_hover.gif');" onmouseout="switchImage(this, 'btn_up_lightblue.gif');"></a><a href="00340.html" target="topic"><img src="btn_next_lightblue.gif" border="0" alt="Next" title="Next" onmouseover="switchImage(this, 'btn_next_lightblue_hover.gif');" onmouseout="switchImage(this, 'btn_next_lightblue.gif');"></a></div>
</td></tr></table><div class="Element5">
28.4.2 Placing assertions callbacks</div>
</div>
</div>
<!-- End Page Header -->
<!-- Begin Client Area -->
<div class="Element720" id="areascroll">
<div class="Element721">
<!-- Begin Page Content -->
<div class="Element58">
<a name="描述"></a><div class="Element11">
<div class="Element10">
<p class="Element10">
Use vpi_register_assertion_cb() to place an assertion callback; the prototype is: </p><div class="Element170">
<a href="#" onclick="CopyElementToClipboard('code00988');">Copy Code</a></div>
<div class="Element13"><div class="Element12" id="code00988"><pre class="Element12">/* typedef for vpi_register_assertion_cb callback function */
typedef PLI_INT32 (vpi_assertion_callback_func)(
PLI_INT32 reason, /* callback reason */
p_vpi_time cb_time, /* callback time */
vpiHandle assertion, /* handle to assertion */
p_vpi_attempt_info info, /* attempt related information */
PLI_BYTE8 *user_data /* user data entered upon registration */
);
vpiHandle vpi_register_assertion_cb(
vpiHandle assertion, /* handle to assertion */
PLI_INT32 reason, /* reason for which callbacks needed */
vpi_assertion_callback_func *cb_rtn,
PLI_BYTE8 *user_data /* user data to be supplied to cb */
);
typedef struct t_vpi_assertion_step_info {
PLI_INT32 matched_expression_count;
vpiHandle *matched_exprs; /* array of expressions */
p_vpi_source_info *exprs_source_info; /* array of source info */
PLI_INT32 stateFrom, stateTo;/* identify transition */
} s_vpi_assertion_step_info, *p_vpi_assertion_step_info;
typedef struct t_vpi_attempt_info {
union {
vpiHandle failExpr;
p_vpi_assertion_step_info step;
} detail;
s_vpi_time attemptStartTime; /* Time attempt triggered */
} s_vpi_attempt_info, *p_vpi_attempt_info;</pre></div></div>
<p class="Element10">
where reason is any of the following. </p><div class="Element170">
<a href="#" onclick="CopyElementToClipboard('code00989');">Copy Code</a></div>
<div class="Element13"><div class="Element12" id="code00989"><pre class="Element12">cbAssertionStart
an assertion attempt has started. For most assertions one attempt starts each and every clock tick.
cbAssertionSuccess
when an assertion attempt reaches a success state.
cbAssertionFailure
when an assertion attempt fails to reach a success state.
cbAssertionStepSuccess
progress one step an attempt. By default, step callbacks are not enabled on any assertions; they are
enabled on a per-assertion/per-attempt basis (see Section 28.5.2), rather than on a per-assertion basis.
cbAssertionStepFailure
failure to progress by one step along an attempt. By default, step callbacks are not enabled on any assertions;
they are enabled on a per-assertion/per-attempt basis (see Section 28.5.2), rather than on a perassertion
basis.
cbAssertionDisable
whenever the assertion is disabled (e.g., as a result of a control action).
cbAssertionEnable
whenever the assertion is enabled.
cbAssertionReset
whenever the assertion is reset.
cbAssertionKill
when an attempt is killed (e.g., as a result of a control action).</pre></div></div>
<p class="Element10">
These callbacks are specific to a given assertion; placing such a callback on one assertion does not cause the callback to trigger on an event occurring on a different assertion. If the callback is successfully placed, a handle to the callback is returned. This handle can be used to remove the callback via vpi_remove_cb(). If there were errors on placing the callback, a NULL handle is returned. As with all other calls, invoking this function with invalid arguments has unpredictable effects. </p>
<p class="Element10">
</p>
<p class="Element10">
Once the callback is placed, the user-supplied function shall be called each time the specified event occurs on the given assertion. The callback shall continue to be called whenever the event occurs until the callback is removed. </p>
<p class="Element10">
</p>
<p class="Element10">
The callback function shall be supplied the following arguments:
<ol class="Element630">
<li value="1" class="Element600">the reason for the callback</li>
<li value="2" class="Element600">a pointer to the time of the callback</li>
<li value="3" class="Element600">the handle for the assertion</li>
<li value="4" class="Element600">a pointer to an attempt information structure</li>
<li value="5" class="Element600">a reference to the user data supplied when the callback was registered.</li>
</ol>The t_vpi_attempt_info attempt information structure contains details relevant to the specific event that occurred.
<ul class="Element630">
<li class="Element600">On disable, enable, reset and kill callbacks, the returned p_vpi_attempt_info info pointer is NULL and no attempt information is available.</li>
<li class="Element600">On start and success callbacks, only the attemptStartTime field is valid.</li>
<li class="Element600">On a cbAssertionFailure callback, the attemptStartTime and detail.failExpr fields are valid.</li>
<li class="Element600">On a step callback, the attemptStartTime and detail.step fields are valid.</li>
</ul>On a step callback, the detail describes the set of expressions matched in satisfying a step along the assertion, along with the corresponding source references. In addition, the step also identifies the source and destination “states” needed to uniquely identify the path being taken through the assertion. State ids are just integers, with 0 identifying the origin state, 1 identifying an accepting state, and any other number representing some intermediate point in the assertion. It is possible for the number of expressions in a step to be 0 (zero), which represents an unconditional transition. In the case of a failing transition, the information provided is just as that for a successful one, but the last expression in the array represents the expression where the transition failed. </p>
<p class="Element10">
</p>
<p class="Element10">
NOTES </p>
<p class="Element10">
1—In a failing transition, there shall always be at least one element in the expression array. </p>
<p class="Element10">
2—Placing a step callback results in the same callback function being invoked for both success and failure steps. </p>
<p class="Element10">
3—The content of the cb_time field depends on the reason identified by the reason field, as follows:
<ul class="Element630">
<li class="Element600">cbAssertionStart — cb_time is the time when the assertion attempt has been started.</li>
<li class="Element600">cbAssertionSuccess, cbAssertionFailure — cb_time is the time when the assertion succeeded/failed.</li>
<li class="Element600">cbAssertionStepSuccess, cbAssertionStepFailure — cb_time is the time when the assertion attempt step succeeded/failed.</li>
<li class="Element600">cbAssertionDisable, cbAssertionEnable, cbAssertionReset, cbAssertionKill — cb_time is the time when the assertion attempt was disabled/enabled/reset/killed.</li>
</ul>4—In contrast to cb_time, the content of attemptStartTime is always the start time of the actual attempt of an assertion. It can be used as an unique ID that distinguishes the attempts of any given assertion.</p></div>
</div>
<a name="Group"></a><div class="Element14">
<a onclick="toggleVisibilityStored('Group');" class="a_Element14"><img src="sectionminus.png" border="0" alt="" title="" id="imgGroup">Group</a></div>
<div id="divGroup">
<div class="Element11">
<div class="Element10">
<p class="Element10">
<a href="00337.html" target="topic">28.4 Dynamic information</a></p></div>
</div>
</div>
<a name="Links"></a><div class="Element14">
<a onclick="toggleVisibilityStored('链接');" class="a_Element14"><img src="sectionminus.png" border="0" alt="" title="" id="img链接">链接</a></div>
<div id="div链接">
<div class="Element11">
<div class="Element10">
<a href="00337.html" target="topic">28.4 Dynamic information</a></div>
</div>
</div>
</div>
<!-- End Page Content -->
<!-- Begin Page Footer -->
<hr width="98%" align="center" size="1" color="#CCCCCC" />
<table align="center" cellpadding="0" cellspacing="0" border="0">
<tbody>
<tr height="10">
<td></td>
</tr>
<tr align="center">
<td>
<script type="text/javascript"><!--
google_ad_client = "pub-5266859600380184";
google_ad_width = 468;
google_ad_height = 60;
google_ad_format = "468x60_as";
google_ad_type = "text_image";
google_ad_channel ="";
google_page_url = document.location;
//--></script>
<script type="text/javascript"
src="http://pagead2.googlesyndication.com/pagead/show_ads.js">
</script>
</td>
</tr>
<tr height="15">
<td></td>
</tr>
<tr align="center">
<td>
<font size=2>除非特别声明,原文版权归作者所有,如有转摘请注明原作者以及译者(<a href="http://www.fpgatech.net/" target="_blank">FPGA技术网</a>)信息。<br />
如果您对本主题有何建议或意见,请登陆<a href="http://www.fpgatech.net/forum/forumdisplay.php?fid=18" target="_blank">FPGA开发者家园</a>提交,您的参与是我们前进的动力。</font>
<script language="javascript" type="text/javascript" src="http://js.users.51.la/195685.js"></script>
<noscript><a href="http://www.51.la/?195685" target="_blank"><img alt="我要啦免费统计" src="http://img.users.51.la/195685.asp" style="border:none" /></a></noscript>
</td>
</tr>
</tbody>
</table>
<!-- End Page Footer -->
</div>
</div>
<!-- End Client Area -->
</body></html>
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -