📄 00245.html
字号:
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Frameset//EN">
<html>
<head>
<title>20.2 定义覆盖模型:covergroup</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', '00245.html');" onmousedown="onBodyMouseDown();">
<!-- Begin Popups -->
<div class="Element801" id="popup00423">
<div class="Element800">
<div class="Element14">
链接</div>
<div class="Element11">
<div class="Element10">
<a href="00856.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, 'popup00423');"><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="00244.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="00856.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="00246.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">
20.2 定义覆盖模型:covergroup</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 covergroup construct encapsulates the specification of a coverage model. Each covergroup specification can include the following components:
<ul class="Element636">
<li class="Element606">A clocking event that synchronizes the sampling of coverage points</li>
<li class="Element606">A set of coverage points</li>
<li class="Element606">Cross coverage between coverage points</li>
<li class="Element606">Optional formal arguments</li>
<li class="Element606">Coverage options</li>
</ul>The covergroup construct is a user-defined type. The type definition is written once, and multiple instances of that type can be created in different contexts. Similar to a class, once defined, a covergroup instance can be created via the new() operator. A covergroup can be defined in a module, program, interface, or class. </p><div class="Element170">
<a href="#" onclick="CopyElementToClipboard('code00862');">Copy Code</a></div>
<div class="Element13"><div class="Element12" id="code00862"><pre class="Element12">covergroup_declaration ::= // from Annex A.2.11
<strong><span style="color: #FF0000">covergroup</span></strong> covergroup_identifier[<strong><span style="color: #FF0000">(</span></strong>[tf_port_list]<strong><span style="color: #FF0000">)</span></strong>][coverage_event]<strong><span style="color: #FF0000">;</span></strong>
{coverage_spec_or_option<strong><span style="color: #FF0000">;</span></strong>}
<strong><span style="color: #FF0000">endgroup</span></strong> [<strong><span style="color: #FF0000">:</span></strong> covergroup_identifier]
coverage_spec_or_option ::=
{attribute_instance} coverage_spec
| {attribute_instance} coverage_option<strong><span style="color: #FF0000">;</span></strong>
coverage_option ::=
<strong><span style="color: #FF0000">option.</span></strong>member_identifier <strong><span style="color: #FF0000">=</span></strong> expression
| <strong><span style="color: #FF0000">type_option.</span></strong>member_identifier <strong><span style="color: #FF0000">=</span></strong> expression
coverage_spec ::=
cover_point
| cover_cross
coverage_event ::=
clocking_event
| <strong><span style="color: #FF0000">@@(</span></strong>block_event_expression<strong><span style="color: #FF0000">)</span></strong>
block_event_expression :: =
block_event_expression <strong><span style="color: #FF0000">or</span></strong> block_event_expression
| <strong><span style="color: #FF0000">begin</span></strong> hierarchical_btf_identifier
| <strong><span style="color: #FF0000">end</span></strong> hierarchical_btf_identifier
hierarchical_btf_identifier :: =
hierarchical_tf_identifier
| hierarchical_block_identifier
| hierarchical_identifier [class_scope] method_identifier
variable_decl_assignment ::= // from Annex A.2.4
...
| [covergroup_variable_identifier] = new[(list_of_arguments)] // 16
16. It shall be legal to omit the covergroup_variable_identifer from a covergroup
instantiation only if this implicit instantiation is within a class that has no
other instantiation of the covergroup.</pre></div></div>
<p class="Element10" style="text-align: center">
<strong>Syntax 20-1—Covergroup syntax (excerpt from Annex A)</strong></p><p class="Element10">
</p>
<p class="Element10">
The identifier associated with the covergroup declaration defines the name of the coverage model. Using this name, an arbitrary number of coverage model instances can be created. For example: </p><div class="Element170">
<a href="#" onclick="CopyElementToClipboard('code00863');">Copy Code</a></div>
<div class="Element13"><div class="Element12" id="code00863"><pre class="Element12">covergroup cg; ... endgroup
cg cg_inst = new;</pre></div></div>
<p class="Element10">
The above example defines a covergroup named cg. An instance of cg is declared as cg_inst and created using the new operator. </p>
<p class="Element10">
</p>
<p class="Element10">
A covergroup can specify an optional list of arguments. When the covergroup specifies a list of formal arguments, its instances must provide to the new operator all the actual arguments that are not defaulted. Actual arguments are evaluated when the new operator is executed. A ref argument allows a different variable to be sampled by each instance of a covergroup. Input arguments will not track value of their arguments; they will use the value passed to the new operator. </p>
<p class="Element10">
</p>
<p class="Element10">
If a clocking event is specified, it defines the event at which coverage points are sampled. If the clocking event is omitted, users must procedurally trigger the coverage sampling. This is done via the built-in sample() method (see Section 20.7). Optionally, the strobe option can be used to modify the sampling behavior. When the strobe option is not set (the default), a coverage point is sampled the instant the clocking event takes place, as if the process triggering the event were to call the built-in sample() method. If the clocking event occurs multiple times in a time step, the coverage point will also be sampled multiple times. The strobe option (see Section 20.6.1) can be used to specify that coverage points are sampled in the postponed region, thereby filtering multiple clocking events so that only one sample per time slot is taken. </p>
<p class="Element10">
</p>
<p class="Element10">
As an alternative to a clocking event, a coverage group accepts a block event expression to indicate that the coverage sample is to be triggered by the start or the end of execution of a given named block, task, function, or class method. Block event expressions that specify the begin keyword followed by a hierarchical identifier denoting a named block, task, function, or class method shall be triggered immediately before the corresponding block, task, function, or method begins executing its first statement. Block event expressions that specify the end keyword followed by a hierarchical identifier denoting a named block, task, function, or class method shall be triggered immediately after the corresponding block, task, function, or method executes its last statement.Block event expressions that specify the end of execution shall not be triggered if the block, task, function, or method is disabled. </p>
<p class="Element10">
</p>
<p class="Element10">
A covergroup can contain one or more coverage points. A coverage point can be a variable or an expression. Each coverage point includes a set of bins associated with its sampled values or its value-transitions. The bins can be explicitly defined by the user or automatically created by the tool. Coverage points are discussed in detail in Section 20.4. </p><div class="Element170">
<a href="#" onclick="CopyElementToClipboard('code00864');">Copy Code</a></div>
<div class="Element13"><div class="Element12" id="code00864"><pre class="Element12">enum { red, green, blue } color;
covergroup g1 @(posedge clk);
c: coverpoint color;
endgroup</pre></div></div>
<p class="Element10">
The above example defines coverage group g1 with a single coverage point associated with variable color. The value of the variable color is sampled at the indicated clocking event: the positive edge of signal clk. Since the coverage point does not explicitly define any bins, the tool automatically creates 3 bins, one for each possible value of the enumerated type. Automatic bins are described in Section 20.4.2. </p>
<p class="Element10">
</p>
<p class="Element10">
A coverage group can also specify cross coverage between two or more coverage points or variables. Any combination of more than two variables or previously declared coverage points is allowed. For example: </p><div class="Element170">
<a href="#" onclick="CopyElementToClipboard('code00865');">Copy Code</a></div>
<div class="Element13"><div class="Element12" id="code00865"><pre class="Element12">enum { red, green, blue } color;
bit [3:0] pixel_adr, pixel_offset, pixel_hue;
covergroup g2 @(posedge clk);
Hue: coverpoint pixel_hue;
Offset: coverpoint pixel_offset;
AxC: cross color, pixel_adr; // cross 2 variables (implicitly declared
// coverpoints)
all: cross color, Hue, Offset; // cross 1 variable and 2 coverpoints
endgroup</pre></div></div>
<p class="Element10">
The example above creates coverage group g2 that includes 2 coverage points and two cross coverage items. Explicit coverage points labeled Offset and Hue are defined for variables pixel_offset and pixel_hue. SystemVerilog implicitly declares coverage points for variables color and pixel_adr in order to track their cross coverage. Implicitly declared cover points are described in Section 20.5. </p>
<p class="Element10">
</p>
<p class="Element10">
A coverage group can also specify one or more options to control and regulate how coverage data is structured and collected. Coverage options can be specified for the coverage group as a whole, or for specific items within the coverage group, that is, any of its coverage points or crosses. In general, a coverage option specified at the covergroup level applies to all of its items unless overridden by them. Coverage options are described in Section 20.6.</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="00856.html" target="topic">第二十章 覆盖</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="00856.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 + -