?? 1076_10.html
字號:
<html>
<head>
<title>VHDL LRM- Introduction</title>
</head>
<body>
<h1><a name="10">Section 10</a></h1>
<a href="../../HTML/HOMEPG.HTM"><img src="HP.GIF" border=0></a>
<a href="1076_TOC.HTM"><img src="TOP.GIF" BORDER=0></a>
<a href="1076_9.HTM"><img src="LEFT.GIF" BORDER=0></a>
<a href="1076_11.HTM"><img src="RIGHT.GIF" BORDER=0></a>
<HR>
<h1>Scope and visibility</h1>
<p>The rules defining the scope of declarations and the rules defining which identifiers are visible at various points in the text of the description are presented in this section. The formulation of these rules uses the notion of a declarative region.
<h2><a name="10.1"> <a href = "1076_10.HTM#10.1"> 10.1 </a> Declarative region</a></h2>
<p>A declarative region is a portion of the text of the description. A single declarative region is formed by the text of each of the following:
<ol type="a">
<li>An entity declaration, together with a corresponding architecture body.<br>
<p><li>A configuration declaration.<br>
<p><li>A subprogram declaration, together with the corresponding subprogram body.<br>
<p><li>A package declaration, together with the corresponding body (if any).<br>
<p><li>A record type declaration.<br>
<p><li>A component declaration.<br>
<p><li>A block statement.<br>
<p><li>A process statement.<br>
<p><li>A loop statement.<br>
<p><li>A block configuration.<br>
<p><li>A component configuration.<br>
<p><li>A generate statement.
</ol>
<p>In each of these cases, the declarative region is said to be <i>associated</i> with the corresponding declaration or statement. A declaration is said to occur<i> immediately within</i> a declarative region if this region is the innermost region that encloses the declaration, not counting the declarative region (if any) associated with the declaration itself.
<p>Certain declarative regions include disjoint parts. Each declarative region is nevertheless considered as a (logically) continuous portion of the description text. Hence, if any rule defines a portion of text as the text that <i>extends</i> from some specific point of a declarative region to the end of this region, then this portion is the corresponding subset of the declarative region (thus, it does not include intermediate declarative items between the interface declaration and a corresponding body declaration).
<h2><a name="10.2"> <a href = "1076_10.HTM#10.2"> 10.2 </a> Scope of declarations</a></h2>
<p>For each form of declaration, the language rules define a certain portion of the description text called the <i>scope of the declaration</i>. The scope of a declaration is also called the scope of any named entity declared by the declaration. Furthermore, if the declaration associates some notation (either an identifier, a character literal, or an operator symbol) with the named entity, this portion of the text is also called the scope of this notation. Within the scope of a named entity, and only there, there are places where it is legal to use the associated notation in order to refer to the named entity. These places are defined by the rules of visibility and overloading.
<p>The scope of a declaration that occurs immediately within a declarative region extends from the beginning of the declaration to the end of the declarative region; this part of the scope of a declaration is called the <i>immediate scope</i>. Furthermore, for any of the declarations in the following list, the scope of the declaration extends beyond the immediate scope:
<ol type="a">
<li>A declaration that occurs immediately within a package declaration<br>
<p><li>An element declaration in a record type declaration<br>
<p><li>A formal parameter declaration in a subprogram declaration<br>
<p><li>A local generic declaration in a component declaration<br>
<p><li>A local port declaration in a component declaration<br>
<p><li>A formal generic declaration in an entity declaration<br>
<p><li>A formal port declaration in an entity declaration<br>
</ol>
<p>In the absence of a separate subprogram declaration, the subprogram specification given in the subprogram body acts as the declaration, and rule(3) applies also in such a case. In each of these cases, the given declaration occurs immediately within some enclosing declaration, and the scope of the given declaration extends to the end of the scope of the enclosing declaration.
<p>In addition to the above rules, the scope of any declaration that includes the end of the declarative part of a given block (whether it be an external block defined by a design entity or an internal block defined by a block statement) extends into a configuration declaration that configures the given block.
<p>If a component configuration appears as a configuration item immediately within a block configuration that configures a given block, and if the scope of a given declaration includes the end of the declarative part of that block, then the scope of the given declaration extends from the beginning to the end of the declarative region associated with the given component configuration. A similar rule applies to a block configuration that appears as a configuration item immediately within another block configuration, provided that the contained block configuration configures an internal block. Furthermore, the scope of a use clause is similarly extended. Finally, the scope of a library unit contained within a design library is extended along with the scope of the logical library name corresponding to that design library.
<p>NOTE--These scope rules apply to all forms of declaration. In particular, they apply also to implicit declarations.
<h2><a name="10.3"> <a href = "1076_10.HTM#10.3"> 10.3 </a> Visibility</a></h2>
<p>The meaning of the occurrence of an identifier at a given place in the text is defined by the visibility rules and also, in the case of overloaded declarations, by the overloading rules. The identifiers considered in this section include any identifier other than a reserved word or attribute designator that denotes a predefined attribute. The places considered in this section are those where a lexical element (such as an identifier) occurs. The overloaded declarations considered in this section are those for subprograms and enumeration literals.
<p>For each identifier and at each place in the text, the visibility rules determine a set of declarations (with this identifier) that define the possible meanings of an occurrence of the identifier. A declaration is said to be visible at a given place in the text when, according to the visibility rules, the declaration defines a possible meaning of this occurrence. Two cases may arise in determining the meaning of such a declaration:
<ul>
<p>-- The visibility rules determine <i>at most one</i> possible meaning. In such a case, the visibility rules are sufficient to determine the declaration defining the meaning of the occurrence of the identifier, or in the absence of such a declaration, to determine that the occurrence is not legal at the given point.
<p>-- The visibility rules determine <i>more than one</i> possible meaning. In such a case, the occurrence of the identifier is legal at this point if and only if <i>exactly one</i> visible declaration is acceptable for the overloading rules in the given context.
</ul>
<p>A declaration is only visible within a certain part of its scope; this part starts at the end of the declaration except in the declaration of a design unit, in which case it starts immediately after the reserved word <b>is</b> is given after the identifier of the design unit. This rule applies to both explicit and implicit declarations.
<p>Visibility is either by selection or direct. A declaration is visible <i>by selection</i> at places that are defined as follows:
<ol type="a">
<li>For a primary unit contained in a library: at the place of the suffix in a selected name whose prefix denotes the library.<br>
<p><li>For an architecture body associated with a given entity declaration: at the place of the block specification in a block configuration for an external block whose interface is defined by that entity declaration.<br>
<p><li>For an architecture body associated with a given entity declaration: at the place of an architecture identifier (between the parentheses) in the first form of an entity aspect in a binding indication.<br>
<p><li>For a declaration given in a package declaration: at the place of the suffix in a selected name whose prefix denotes the package.<br>
<p><li>For an element declaration of a given record type declaration: at the place of the suffix in a selected name whose prefix is appropriate for the type; also at the place of a choice (before the compound delimiter =>) in a named element association of an aggregate of the type.<br>
<p><li>For a user-defined attribute: at the place of the attribute designator(after the delimiter ') in an attribute name whose prefix denotes a named entity with which that attribute has been associated.<br>
<p><li>For a formal parameter declaration of a given subprogram declaration: at the place of the formal designator in a formal part (before the compound delimiter =>) of a named parameter association element of a corresponding subprogram call.<br>
<p><li>For a local generic declaration of a given component declaration: at the place of the formal designator in a formal part (before the compound delimiter=>) of a named generic association element of a corresponding component instantiation statement; similarly, at the place of the actual designator in an actual part (after the compound delimiter =>, if any) of a generic association element of a corresponding binding indication.<br>
<p><li>For a local port declaration of a given component declaration: at the place of the formal designator in a formal part (before the compound delimiter=>) of a named port association element of a corresponding component instantiation statement; similarly, at the place of the actual designator in an actual part (after the compound delimiter =>, if any) of a port association element of a corresponding binding indication.<br>
<p><li>For a formal generic declaration of a given entity declaration: at the place of the formal designator in a formal part (before the compound delimiter=>) of a named generic association element of a corresponding binding indication; similarly, at the place of the formal designator in a formal part(before the compound delimiter =>) of a generic association element of a corresponding component instantiation statement when the instantiated unit is a design entity or a configuration declaration.<br>
<p><li>For a formal port declaration of a given entity declaration: at the place of the formal designator in a formal part (before the compound delimiter=>) of a named port association element of a corresponding binding specification; similarly, at the place of the formal designator in a formal part (before the compound delimiter =>) of a port association element of a corresponding component instantiation statement when the instantiated unit is a design entity or a configuration declaration.<br>
<p><li>For a formal generic declaration or a formal port declaration of a given block statement: at the place of the formal designator in a formal part (before the compound delimiter =>) of a named association element of a corresponding generic or port map aspect.
</ol>
?? 快捷鍵說明
復制代碼
Ctrl + C
搜索代碼
Ctrl + F
全屏模式
F11
切換主題
Ctrl + Shift + D
顯示快捷鍵
?
增大字號
Ctrl + =
減小字號
Ctrl + -