?? 1076_4.html
字號:
<html>
<head>
<title>VHDL LRM- Introduction</title>
</head>
<body>
<h1><a name="4">Section 4</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_3.HTM"><img src="LEFT.GIF" BORDER=0></a>
<a href="1076_5.HTM"><img src="RIGHT.GIF" BORDER=0></a>
<HR>
<h1>Declarations</h1>
<p>
<p>The language defines several kinds of entities that are declared explicitly or implicitly by declarations.
<pre> declaration ::=
type_declaration
| subtype_declaration
| object_declaration
| interface_declaration
| alias_declaration
| attribute_declaration
| component_declaration
| group_template_declaration
| group_declaration
| entity_declaration
| configuration_declaration
| subprogram_declaration
| package_declaration
</pre>
<p>For each form of declaration, the language rules define a certain region of text called the <i>scope</i> of the declaration (see <a href = "1076_10.HTM#10.2"> 10.2 </a> ). Each form of declaration associates an identifier with a named entity. Only within its scope, there are places where it is possible to use the identifier to refer to the associated declared entity; these places are defined by the visibility rules (see <a href = "1076_10.HTM#10.3"> 10.3 </a> ). At such places the identifier is said to be a <i>name</i> of the entity; the name is said to <i>denote</i> the associated entity.
<p>This section describes type and subtype declarations, the various kinds of object declarations, alias declarations, attribute declarations, component declarations, and group and group template declarations. The other kinds of declarations are described in Section 1 and Section 2.
<p>A declaration takes effect through the process of elaboration. Elaboration of declarations is discussed in Section 12.
<h2><a name="4.1"> <a href = "1076_4.HTM#4.1"> 4.1 </a> Type declarations</a></h2>
<p>A type declaration declares a type.
<pre> type_declaration ::=
full_type_declaration
| incomplete_type_declaration
full_type_declaration ::=
<b>type</b> identifier <b>is</b> type_definition ;
type_definition ::=
scalar_type_definition
| composite_type_definition
| access_type_definition
| file_type_definition
</pre>
<p>The types created by the elaboration of distinct type definitions are distinct types. The elaboration of the type definition for a scalar type or a constrained array type creates both a base type and a subtype of the base type.
<p>The simple name declared by a type declaration denotes the declared type,unless the type declaration declares both a base type and a subtype of the base type, in which case the simple name denotes the subtype and the base type is anonymous. A type is said to be <i>anonymous</i> if it has no simple name. For explanatory purposes, this standard sometimes refers to an anonymous type by a pseudo-name, written in italics, and uses such pseudo-names at places where the syntax normally requires an identifier.
<h4>NOTES</h4>
<p>1--Two type definitions always define two distinct types, even if they are lexically identical. Thus, the type definitions in the following two integer type declarations define distinct types:
<pre> <b>type</b> A <b>is range</b> 1 <b>to</b> 10;
<b>type</b> B <b>is range</b> 1 <b>to</b> 10;
</pre>
<p>This applies to type declarations for other classes of types as well.
<p>2--The various forms of type definition are described in Section 3. Examples of type declarations are also given in that section.
<h2><a name="4.2"> <a href = "1076_4.HTM#4.2"> 4.2 </a> Subtype declarations</a></h2>
<p>A subtype declaration declares a subtype.
<pre> subtype_declaration ::=
<b>subtype</b> identifier <b>is</b> subtype_indication ;
subtype_indication ::=
[ <i>resolution_function</i>_name ] type_mark [ constraint ]
type_mark ::=
<i>type</i>_name
| <i>subtype</i>_name
constraint ::=
range_constraint
| index_constraint
</pre>
<p>A type mark denotes a type or a subtype. If a type mark is the name of a type,the type mark denotes this type and also the corresponding unconstrained subtype. The base type of a type mark is, by definition, the base type of the type or subtype denoted by the type mark.
<p>A subtype indication defines a subtype of the base type of the type mark.
<p>If a subtype indication includes a resolution function name, then any signal declared to be of that subtype will be resolved, if necessary, by the named function (see <a href = "1076_2.HTM#2.4"> 2.4 </a> ); for an overloaded function name, the meaning of the function name is determined by context (see <a href = "1076_2.HTM#2.3"> 2.3 </a> and <a href = "1076_10.HTM#10.5"> 10.5 </a> ). It is an error if the function does not meet the requirements of a resolution function (see <a href = "1076_2.HTM#2.4"> 2.4 </a> ).The presence of a resolution function name has no effect on the declarations of objects other than signals or on the declarations of files, aliases,attributes, or other subtypes.
<p>If the subtype indication does not include a constraint, the subtype is the same as that denoted by the type mark. The condition imposed by a constraint is the condition obtained after evaluation of the expressions and ranges forming the constraint. The rules defining compatibility are given for each form of constraint in the appropriate section. These rules are such that if a constraint is compatible with a subtype, then the condition imposed by the constraint cannot contradict any condition already imposed by the subtype on its values. An error occurs if any check of compatibility fails.
<p>The direction of a discrete subtype indication is the same as the direction of the range constraint that appears as the constraint of the subtype indication. If no constraint is present, and the type mark denotes a subtype, the direction of the subtype indication is the same as that of the denoted subtype. If no constraint is present, and the type mark denotes a type, the direction of the subtype indication is the same as that of the range used to define the denoted type. The direction of a discrete subtype is the same as the direction of its subtype indication.
<p>A subtype indication denoting an access type or a file type may not contain are solution function. Furthermore, the only allowable constraint on a subtype indication denoting an access type is an index constraint (and then only if the designated type is an array type).
<p>NOTE--A subtype declaration does not define a new type.
<h2><a name="4.3"> <a href = "1076_4.HTM#4.3"> 4.3 </a> Objects</a></h2>
<p>An <i>object</i> is a named entity that contains (has) a value of a given type. An object is one of the following:
<ul>
<p>-- An object declared by an object declaration (see <a href = "1076_4.HTM#4.3.1"> 4.3.1 </a> )
<p>-- A loop or generate parameter (see <a href = "1076_8.HTM#8.9"> 8.9 </a> and <a href = "1076_9.HTM#9.7"> 9.7 </a> )
<p>-- A formal parameter of a subprogram (see <a href = "1076_2.HTM#2.1.1"> 2.1.1 </a> )
<p>-- A formal port (see <a href = "1076_1.HTM#1.1.1.2"> 1.1.1.2 </a> and <a href = "1076_9.HTM#9.1"> 9.1 </a> )
<p>-- A formal generic (see <a href = "1076_1.HTM#1.1.1.1"> 1.1.1.1 </a> and <a href = "1076_9.HTM#9.1"> 9.1 </a> )
<p>-- A local port (see <a href = "1076_4.HTM#4.5"> 4.5 </a> )
<p>-- A local generic (see <a href = "1076_4.HTM#4.5"> 4.5 </a> )
<p>-- An implicit signal GUARD defined by the guard expression of a block statement (see <a href = "1076_9.HTM#9.1"> 9.1 </a> )
</ul>
<p>In addition, the following are objects, but are not named entities:
<ul>
<p>-- An implicit signal defined by any of the predefined attributes 'DELAYED,'STABLE, 'QUIET, and 'TRANSACTION (see <a href = "1076_14.HTM#14.1"> 14.1 </a> )
<p>-- An element or slice of another object (see <a href = "1076_6.HTM#6.3"> 6.3 </a> , <a href = "1076_6.HTM#6.4"> 6.4 </a> , and <a href = "1076_6.HTM#6.5"> 6.5 </a> )
<p>-- An object designated by a value of an access type (see <a href = "1076_3.HTM#3.3"> 3.3 </a> )
</ul>
<p>There are four classes of objects: constants, signals, variables, and files. The variable class of objects also has an additional subclass: shared variables. The class of an explicitly declared object is specified by the reserved word that must or may appear at the beginning of the declaration of that object. For a given object of a composite type, each subelement of that object is itself an object of the same class and subclass, if any, as the given object. The value of a composite object is the aggregation of the values of its subelements.
<p>Objects declared by object declarations are available for use within blocks,processes, subprograms, or packages. Loop and generate parameters are implicitly declared by the corresponding statement and are available for use only within that statement. Other objects, declared by interface declarations,create channels for the communication of values between independent parts of a description.
<h3><a name="4.3.1"> <a href = "1076_4.HTM#4.3.1"> 4.3.1 </a> Object declarations</a></h3>
<p>An object declaration declares an object of a specified type. Such an object is called an <i>explicitly declared object</i>.
<pre> object_declaration ::=
constant_declaration
| signal_declaration
| variable_declaration
| file_declaration
</pre>
<p>An object declaration is called a <i>single-object declaration</i> if its identifier list has a single identifier; it is called a <i>multiple-object declaration</i> if the identifier list has two or more identifiers. A multiple-object declaration is equivalent to a sequence of the corresponding number of single-object declarations. For each identifier of the list, the equivalent sequence has a single-object declaration formed by this identifier,followed by a colon and by whatever appears at the right of the colon in the multiple-object declaration; the equivalent sequence is in the same order as the identifier list.
<p>A similar equivalence applies also for interface object declarations (see <a href = "1076_4.HTM#4.3.2"> 4.3.2 </a> ).
<p>NOTE--The subelements of a composite, declared object are not declared objects.
<h4><a name="4.3.1.1"> <a href = "1076_4.HTM#4.3.1.1"> 4.3.1.1 </a> Constant declarations</a></h4>
?? 快捷鍵說明
復制代碼
Ctrl + C
搜索代碼
Ctrl + F
全屏模式
F11
切換主題
Ctrl + Shift + D
顯示快捷鍵
?
增大字號
Ctrl + =
減小字號
Ctrl + -