📄 00441.html
字号:
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Frameset//EN">
<html>
<head>
<title>30.8.4.1 Traversing value changes of objects</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', '00441.html');" onmousedown="onBodyMouseDown();">
<!-- Begin Popups -->
<div class="Element801" id="popup00579">
<div class="Element800">
<div class="Element14">
链接</div>
<div class="Element11">
<div class="Element10">
<a href="00440.html" target="topic">30.8.4 Reading an object</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, 'popup00579');"><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="00440.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="00440.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="00442.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">
30.8.4.1 Traversing value changes of objects</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">
After getting a traverse vpiHandle, the application can do a forward or backward walk or jump traversal by using vpi_goto() on a vpiTrvsObj object type with the new traverse properties. </p>
<p class="Element10">
</p>
<p class="Element10">
Here is a sample code segment for the complete process from handle creation to traversal. </p><div class="Element170">
<a href="#" onclick="CopyElementToClipboard('code01047');">Copy Code</a></div>
<div class="Element13"><div class="Element12" id="code01047"><pre class="Element12">p_vpi_extension reader_p; /* Pointer to VPI reader extension structure */
vpiHandle instanceHandle; /* Some scope object is inside */
vpiHandle var_handle; /* Object handle */
vpiHandle vc_trvs_hdl; /* Traverse handle */
vpiHandle itr;
p_vpi_value value_p; /* Value storage */
p_vpi_time time_p; /* Time storage */
PLI_INT32 code; /* return code */
...
/* Initialize the read interface: Access data from memory */
/* NOTE: Use built-in VPI (e.g. that of simulator application is running
under) */
reader_p = vpi_load_extension(NULL, NULL, vpiAccessLimitedInteractive);
if (reader_p == NULL) ... ; /* Not successful */
/* Initialize the load: Access data from simulator) memory, for scope
instanceHandle and its subscopes */
/* NOTE: Call marks access for all the objects in the scope */
vpi_load_init(NULL, instanceHandle, 0);
itr = vpi_iterate(vpiVariables, instanceHandle);
while (var_handle = vpi_scan(itr)) {
/* Demo how to force the load, this part can be skipped in general */
if (vpi_get(vpiIsLoaded, var_handle) == 0) { /* not loaded*/
/* Load data: object-based load, one by one */
if (!vpi_load(var_handle)); /* Data not found ! */
break;
}
/*-- End of Demo how to force the load, this part can be skipped in general */
/* Create a traverse handle for read queries */
vc_trvs_hdl = vpi_handle(vpiTrvsObj, var_handle);
/* Go to minimum time */
vc_trvs_hdl = vpi_goto(vpiMinTime, vc_trvs_hdl, NULL, NULL);
/* Get info at the min time */
time_p->type = vpiSimTime;
vpi_get_time(vc_trvs_hdl, time_p); /* Minimum time */
vpi_printf(...);
vpi_get_value(vc_trvs_hdl, value_p); /* Value */
vpi_printf(...);
if (vpi_get(vpiHasDataVC, vc_trvs_hdl)) { /* Have any VCs ? */
for (;;) { /* All the elements in time */
vc_trvs_hdl = vpi_goto(vpiNextVC, vc_trvs_hdl, NULL, &code);
if (!code) {
/* failure (e.g. already at MaxTime or no more VCs) */
break; /* cannot go further */
}
/* Get Max time: Set bits of s_vpi_time type field */
/* time_p->type = vpiMaxTime & vpiSimTime; */
/* vpi_get_time(vc_trvs_hdl, time_p); */
time_p->type = vpiSimTime;
vpi_get_time(vc_trvs_hdl, time_p); /* Time of VC */
vpi_get_value(vc_trvs_hdl, value_p); /* VC data */
}
}
}
/* free handles */
vpi_free_object(...);</pre></div></div>
<p class="Element10">
The code segment above declares an interactive access scheme, where only a limited history of values is provided by the tool (e.g. simulator). It then creates a Value Change (VC) traverse handle associated with an object whose handle is represented by var_handle but only after vpi_load_init() is called. It then creates a traverse handle, vc_trvs_hdl. With this traverse handle, it first calls vpi_goto() to move to the minimum time where the value has changed. It moves the handle (internal index) to that time by calling vpi_goto() with a vpiMinTime argument. It then repeatedly calls vpi_goto() with a vpiNextVC to move the internal index forward repeatedly until there is no value change left. vpi_get_time() gets the actual time where this VC is, and data is obtained by vpi_get_value(). The application can also choose to call vpi_goto() with a time_p argument to automatically get the VC time instead of calling vpi_get_time() separately to get this information. </p>
<p class="Element10">
</p>
<p class="Element10">
The traverse and collection handles can be freed when they are no longer needed using vpi_free_object().</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="00440.html" target="topic">30.8.4 Reading an object</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="00440.html" target="topic">30.8.4 Reading an object</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 + -