📄 00762.html
字号:
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Frameset//EN">
<html>
<head>
<title>E.5 Semantic constraints</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', '00762.html');" onmousedown="onBodyMouseDown();">
<!-- Begin Popups -->
<div class="Element801" id="popup00771">
<div class="Element800">
<div class="Element14">
链接</div>
<div class="Element11">
<div class="Element10">
<a href="00883.html" target="topic">附录E DPI C-layer</a>, <a href="01034.html" target="topic">主题</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, 'popup00771');"><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="00761.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="00883.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="00763.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">
E.5 Semantic constraints</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">
Formal and actual arguments of both imported tasks or functions and exported tasks or functions are bound by the principle “What You Specify Is What You Get.” This principle is binding both for the caller and for the callee, in C code and in SystemVerilog code. For the callee, it guarantees the actual arguments are as specified for the formal ones. For the caller, it means the function call arguments shall conform with the types of the formal arguments, which might require type-coercion on the caller side. </p>
<p class="Element10">
</p>
<p class="Element10">
Another way to state this is that no compiler (either C or SystemVerilog) can make argument coercions between a caller’s declared formals and the callee’s declared the formals. This is because the callee’s formal arguments are declared in a different language than the caller’s formal arguments; hence there is no visible relationship between the two sets of formals. Users are expected to understand all argument relationships and provide properly matched types on both sides of the interface (see Annex E.6.2). </p>
<p class="Element10">
</p>
<p class="Element10">
In SystemVerilog code, the compiler can change the formal arguments of a native SystemVerilog task or function and modify its code accordingly, because of optimizations, compiler pragmas, or command line switches. The situation is different for imported tasks and functions. A SystemVerilog compiler cannot modify the C code, perform any coercions, or make any changes whatsoever to the formal arguments of an imported task or function. </p>
<p class="Element10">
</p>
<p class="Element10">
A SystemVerilog compiler shall provide any necessary coercions for the actual arguments of every imported task and function call. For example, a SystemVerilog compiler might truncate or extend bits of a packed array if the widths of the actual and formal arguments are different. Similarly, a C compiler can provide coercion for C types based on the relationship of the arguments in the exported task’s and function’s C prototype (formals) and the exported task’s and function’s C call site (actuals). However, a C compiler cannot provide such coercion for SystemVerilog types. </p>
<p class="Element10">
</p>
<p class="Element10">
Thus, in each case of an inter-language function call, either C to SystemVerilog or SystemVerilog to C, the compilers expect but cannot enforce that the types on either side are compatible. It is therefore the user’s responsibility to ensure that the imported/exported function types exactly match the types of the corresponding tasks or functions in the foreign language.</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="00883.html" target="topic">附录E DPI C-layer</a></p></div>
</div>
</div>
<a name="主题"></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">
<div class="Element212">
<div class="TableDiv">
<table cellspacing="0" class="Table0">
<tr>
<td class="Element200" valign="top" width="50%">
<div class="Element201">
主题 </div></td><td class="Element204" valign="top" width="50%">
<div class="Element205">
描述 </div></td></tr><tr>
<td class="Element202" valign="top" width="50%">
<div class="Element203">
<a href="00763.html" target="topic">E.5.1 Types of formal arguments</a> </div></td><td class="Element206" valign="top" width="50%">
<div class="Element207">
The principle “What You Specify Is What You Get” guarantees the types of formal arguments of imported functions — an actual argument is guaranteed to be of the type specified for the formal argument, with the exception of open arrays (for which unspecified ranges are statically unknown). Formal arguments, other than open arrays, are fully defined by imported declaration; they shall have ranges of packed or unpacked arrays exactly as specified in the imported declaration. Only the SystemVerilog declaration site of the imported function is relevant for such formal arguments.<br><br>Formal arguments defined as open arrays have the size and... <a href="00763.html" target="topic">more</a> </div></td></tr><tr>
<td class="Element202" valign="top" width="50%">
<div class="Element203">
<a href="00764.html" target="topic">E.5.2 input arguments</a> </div></td><td class="Element206" valign="top" width="50%">
<div class="Element207">
Formal arguments specified in SystemVerilog as input must not be modified by the foreign language code. See also Section 27.4.1.2. </div></td></tr><tr>
<td class="Element202" valign="top" width="50%">
<div class="Element203">
<a href="00765.html" target="topic">E.5.3 output arguments</a> </div></td><td class="Element206" valign="top" width="50%">
<div class="Element207">
The initial values of formal arguments specified in SystemVerilog as output are undetermined and implementation-dependent. See also Section 27.4.1.2. </div></td></tr><tr>
<td class="Element202" valign="top" width="50%">
<div class="Element203">
<a href="00766.html" target="topic">E.5.4 Value changes for output and inout arguments</a> </div></td><td class="Element206" valign="top" width="50%">
<div class="Element207">
The SystemVerilog simulator is responsible for handling value changes for output and inout arguments. Such changes shall be detected and handled after the control returns from C code to SystemVerilog code. </div></td></tr><tr>
<td class="Element202" valign="top" width="50%">
<div class="Element203">
<a href="00767.html" target="topic">E.5.5 context and non-context tasks and functions</a> </div></td><td class="Element206" valign="top" width="50%">
<div class="Element207">
Also refer to Section 27.4.3.<br><br>Some DPI imported tasks or functions or other interface functions called from them require that the context of their call be known. It takes special instrumentation of their call instances to provide such context; for example, a variable referring to the “current instance” might need to be set. To avoid any unnecessary overhead, imported tasks and function calls in SystemVerilog code are not instrumented unless the imported tasks or function is specified as context in its SystemVerilog import declaration.<br><br>All DPI export tasks and functions require that the context of their call is known. This... <a href="00767.html" target="topic">more</a> </div></td></tr><tr>
<td class="Element202" valign="top" width="50%">
<div class="Element203">
<a href="00768.html" target="topic">E.5.6 pure functions</a> </div></td><td class="Element206" valign="top" width="50%">
<div class="Element207">
See also Section 27.4.2.<br><br>Only non-void functions with no output or inout arguments can be specified as pure. Functions specified as pure in their corresponding SystemVerilog import declarations shall have no side effects; their results need to depend solely on the values of their input arguments. Calls to such functions can be removed by SystemVerilog compiler optimizations or replaced with the values previously computed for the same values of the input arguments.<br><br>Specifically, a pure function is assumed not to directly or indirectly (i.e., by calling other functions):<br>— perform any file operations<br>— read or write anything in the... <a href="00768.html" target="topic">more</a> </div></td></tr><tr>
<td class="Element202" valign="top" width="50%">
<div class="Element203">
<a href="00769.html" target="topic">E.5.7 Memory management</a> </div></td><td class="Element206" valign="top" width="50%">
<div class="Element207">
See also Section 27.4.1.4.<br><br>The memory spaces owned and allocated by C code and SystemVerilog code are disjoined. Each side is responsible for its own allocated memory. Specifically, C code shall not free the memory allocated by SystemVerilog code (or the SystemVerilog compiler) nor expect SystemVerilog code to free the memory allocated by C code (or the C compiler). This does not exclude scenarios in which C code allocates a block of memory, then passes a handle (i.e., a pointer) to that block to SystemVerilog code, which in turn calls a C function that directly (if it is the standard... <a href="00769.html" target="topic">more</a> </div></td></tr></table></div></div>
</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="00883.html" target="topic">附录E DPI C-layer</a>, <a href="01034.html" target="topic">主题</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 + -