⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 00415.html

📁 这是一本关于verilog编程语言的教程,对学习verilog语言有帮助
💻 HTML
字号:
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Frameset//EN">
<html>
<head>
<title>30.10 Reading data from multiple databases and/or different read library providers</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', '00415.html');" onmousedown="onBodyMouseDown();">

<!-- Begin Popups -->
<div class="Element801" id="popup00586">
<div class="Element800">
<div class="Element14">
链接</div>
<div class="Element11">
<div class="Element10">
<a href="00862.html" target="topic">第三十章 SystemVerilog数据读API</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, 'popup00586');"><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="00447.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="00862.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="00416.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.10 Reading data from multiple databases and/or different read library providers</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">
The VPI routine vpi_load_extension() is used to load VPI extensions. Such extensions include reader libraries from such tools as waveform viewers. vpi_load_extension() shall return a pointer to a function pointer structure with the following definition. </p><div class="Element170">
<a href="#" onclick="CopyElementToClipboard('code01052');">Copy Code</a></div>
<div class="Element13"><div class="Element12" id="code01052"><pre class="Element12">typedef struct {
    void *user_data; /* Attach user data here if needed */
    /* Below this point user application MUST NOT modify any values */
    size_t struct_size; /* Must be set to sizeof(s_vpi_extension) */
    long struct_version; /* Set to 1 for SystemVerilog 3.1a */
    PLI_BYTE8 *extension_version;
    PLI_BYTE8 *extension_name;
    /* One function pointer for each of the defined VPI routines:
     - Each function pointer has to have the correct prototype */
    ...
    PLI_INT32 (*vpi_chk_error)(error_info_p);
    ...
    PLI_INT32 (*vpi_vprintf)(PLI_BYTE8 *format, ...);
    ...
} s_vpi_extension, *p_vpi_extension;</pre></div></div>
<p class="Element10">
Subsequent versions of the s_vpi_extension structure shall only extend it by adding members at the end; previously existing entries must not be changed, removed, or re-ordered in order to preserve backward compatability. The struct_size entry allows users to perform basic sanity checks (e.g. before type casting), and the struct_version permits keeping track and checking the version of the s_vpi_extension structure. The structure also has a user_data field to give users a way to attach data to a particular load of an extension if they wish to do so.&nbsp;</p>
<p class="Element10">
&nbsp;</p>
<p class="Element10">
The structure shall have an entry for every VPI routine; the order and synopsis of these entries within the structure shall exactly match the order and synopsis of function definitions in Chapter 27 of the Verilog Standard, IEEE Std 1364-2001. After those entries the SystemVerilog VPI routine additions for assertions vpi_get_assertion_info() and then vpi_register_assertion_cb() shall be added in that order. Then all new reader routines defined in Table 30-3 shall be added in exactly the order noted in the table. If a particular extension does not support a specific VPI routine, then it shall still have an entry (with the correct prototype), and a dummy body that shall always have a return (consistent with the VPI prototype) to signify failure (i.e. NULL or FALSE ). The routine call must also raise the appropriate VPI error, which can be checked by vpi_chk_error(), and/or automatically generate an error message in a manner consistent with the specific VPI routine.&nbsp;</p>
<p class="Element10">
&nbsp;</p>
<p class="Element10">
If tool providers want to add their own implementation extensions, those extensions must only have the effect of making the s_vpi_extension structure larger and any non-standard content must occur after all the standard fields. This permits applications to use the pointer to the extended structure as if it was a p_vpi_extension pointer, yet still allow the applications to go beyond and access or call tool-specific fields or routines in the extended structure. For example, a tool extended s_vpi_extension could be: </p><div class="Element170">
<a href="#" onclick="CopyElementToClipboard('code01053');">Copy Code</a></div>
<div class="Element13"><div class="Element12" id="code01053"><pre class="Element12">typedef struct {
    /* inline a copy of s_vpi_extension */
    /* begin */
    void *user_data;
    ...
    /* end */
    /* “toolZ” extension with one additional routine */
    int (*toolZfunc)(int);
} s_toolZ_extension, *p_toolZ_extension;</pre></div></div>
<p class="Element10">
An example of use of the above extended structure is as follows: </p><div class="Element170">
<a href="#" onclick="CopyElementToClipboard('code01054');">Copy Code</a></div>
<div class="Element13"><div class="Element12" id="code01054"><pre class="Element12">p_vpi_extension h;
p_toolZ_extension hZ;
h = vpi_load_extension(“toolZ”, &lt;args&gt;);
if ( h &amp;&amp; (h-&gt;struct_size &gt;= sizeof(s_toolZ_extension))
&amp;&amp; !(strcmp(h-&gt;extension_version, “...”)
&amp;&amp; !strcmp(h-&gt;extension_name, “toolZ”) ) {
hZ = (p_toolZ_extension) h;
/* Can now use hZ to access all the VPI routines, including toolZ’s
‘toolZfunc’ */
...
}</pre></div></div>
<p class="Element10">
The SystemVerilog tool the user application is running under is responsible for loading the appropriate extension, i.e. the reader API library in the case of the read API. The extension name is used for this purpose, following a specific policy, for example, this extension name can be the name of the library to be loaded. Once the reader API library is loaded all VPI function calls that wish to use the implementation in the library shall be performed using the returned p_vpi_extension pointer as an indirection to call the function pointers specified in s_vpi_extension or the extended vendor specific structure as described above. Note that, as stated earlier, in the case the application is using the built-in routine implementation (i.e. the ones provided by the tool (e.g. simulator) it is running under) then the de-reference through the pointer is not necessary.&nbsp;</p>
<p class="Element10">
&nbsp;</p>
<p class="Element10">
Multiple databases can be opened for read simultaneously by the application. After a vpi_load_extension() call, a top scope handle can be created for that database to be used later to derive any other handles for objects in that database. An example of multiple database access is shown below. In the example, scope1 and scope2 are the top scope handles used to point into database1 and database2 respectively and perform the processing (comparing data in the two databases for example). </p><div class="Element170">
<a href="#" onclick="CopyElementToClipboard('code01055');">Copy Code</a></div>
<div class="Element13"><div class="Element12" id="code01055"><pre class="Element12">p_vpi_extension reader_pX; /* Pointer to reader libraryfunction struct */
p_vpi_extension reader_pY; /* Pointer to reader libraryfunction struct */
vpiHandle scope1, scope2; /* Some scope being looked at */
vpiHandle var_handle; /* Object handle */
vpiHandle some_net; /* Handle of some net */
vpiHandle some_reg; /* Handle of some reg */
vpiHandle vc_trvs_hdl1; /* Traverse handle */
vpiHandle vc_trvs_hdl2; /* Traverse handle */
vpiHandle itr; /* Iterator */
vpiHandle objCollection1, objCollection2; /* Object collection */
vpiHandle trvsCollection1, trvsCollection2; /* Traverse collection */
p_vpi_time time_p; /* time */
PLI_BYTE8 *data1 = “database1”;
PLI_BYTE8 *data2 = “database2”;
/* Initialize the read interface: Post process mode, read from a database */
/* NOTE: Use library from “toolX” */
reader_pX = vpi_load_extension(“toolX”, data1, vpiAccessPostProcess);
/* Get the scope using its name */
/* NOTE: scope handle comes from database: data1 */
scope1 = reader_pX-&gt;vpi_handle_by_name(“top.m1.s1”, NULL);
/* Initialize the read interface: Post process mode, read from a database */
/* NOTE: Use library from “toolY” */
reader_pY = vpi_load_extension(“toolY”, data2, vpiAccessPostProcess);
/* Get the scope using its name */
/* NOTE: scope handle comes from database: data2 */
scope2 = reader_pY-&gt;vpi_handle_by_name(“top.m1.s1”, NULL);
/* Create object collections */
objCollection1 = reader_pX-&gt;vpi_create(vpiObjCollection, NULL, NULL);
objCollection2 = reader_pY-&gt;vpi_create(vpiObjCollection, NULL, NULL);
/* Add data to collection1: All the nets in scope1,
data comes from database1 */
/* ASSUMPTION: (waveform) tool supports this navigation relationship */
itr = reader_pX-&gt;vpi_iterate(vpiNet, scope1);
while (var_handle = reader_pX-&gt;vpi_scan(itr)) {
objCollection1 = reader_pX-&gt;vpi_create(vpiObjCollection, objCollection1,
var_handle);
}
/* Add data to collection2: All the nets in scope2,
data comes from database2 */
/* ASSUMPTION: (waveform) tool supports this navigation relationship */
itr = reader_pY-&gt;vpi_iterate(vpiNet, scope2);
while (var_handle = reader_pY-&gt;vpi_scan(itr)) {
objCollection2 = reader_pY-&gt;vpi_create(vpiObjCollection, objCollection2,
var_handle);
}
/* Initialize the load: focus only on the signals in the object collection:
objCollection */
reader_pX-&gt;vpi_load_init(objCollection1, NULL, 0);
reader_pY-&gt;vpi_load_init(objCollection2, NULL, 0);
/* Demo: Scan the object collection */
itr = reader_pX-&gt;vpi_iterate(vpiMember, objCollection1);
while (var_handle = reader_pX-&gt;vpi_scan(itr)) {
...
}
itr = reader_pY-&gt;vpi_iterate(vpiMember, objCollection2);
while (var_handle = reader_pY-&gt;vpi_scan(itr)) {
...
}
/* Application code here: Access Objects from database1 or database2 */
some_net = ...;
time_p = ...;
some_reg = ...;
....
/* Data querying and processing here */
....
/* free handles*/
reader_pX-&gt;vpi_free_object(...);
reader_pY-&gt;vpi_free_object(...);
/* close databases */
reader_pX-&gt;vpi_close(0, vpiAccessPostProcess, data1);
reader_pY-&gt;vpi_close(0, vpiAccessPostProcess, data2);</pre></div></div>
</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="00862.html" target="topic">第三十章 SystemVerilog数据读API</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="00862.html" target="topic">第三十章 SystemVerilog数据读API</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="&#x6211;&#x8981;&#x5566;&#x514D;&#x8D39;&#x7EDF;&#x8BA1;" 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 + -