?? 1076_4.html
字號:
<p>A constant declaration declares a <i>constant</i> of the specified type. Such a constant is an <i>explicitly declared constant</i>.
<pre> constant_declaration ::=
<b>constant</b> identifier_list : subtype_indication [ := expression ] ;
</pre>
<p>If the assignment symbol ":=" followed by an expression is present in a constant declaration, the expression specifies the value of the constant; the type of the expression must be that of the constant. The value of a constant cannot be modified after the declaration is elaborated.
<p>If the assignment symbol ":=" followed by an expression is not present in a constant declaration, then the declaration declares a <i>deferred</i> <i>constant</i>. Such a constant declaration may only appear in a package declaration. The corresponding full constant declaration, which defines the value of the constant, must appear in the body of the package (see <a href = "1076_2.HTM#2.6"> 2.6 </a> ).
<p>Formal parameters of subprograms that are of mode <b>in</b> may be constants,and local and formal generics are always constants; the declarations of such objects are discussed in <a href = "1076_4.HTM#4.3.2"> 4.3.2 </a> . A loop parameter is a constant within the corresponding loop (see <a href = "1076_8.HTM#8.9"> 8.9 </a> ); similarly, a generate parameter is a constant within the corresponding generate statement (see <a href = "1076_9.HTM#9.7"> 9.7 </a> ). A subelement or slice of a constant is a constant.
<p>It is an error if a constant declaration declares a constant that is of a file type, an access type, or a composite type that has a subelement that is a file type or an access type.
<p>NOTE--The subelements of a composite, declared constant are not declared constants.
<p><i>Examples:</i>
<pre> <b>constant</b> TOLERANCE : DISTANCE := 1.5 nm;
<b>constant</b> PI : REAL := 3.141592;
<b>constant</b> CYCLE_TIME : TIME := 100 ns;
<b>constant</b> Propagation_Delay : DELAY_LENGTH; -- a deferred constant
</pre>
<h4><a name="4.3.1.2"> <a href = "1076_4.HTM#4.3.1.2"> 4.3.1.2 </a> Signal declarations</a></h4>
<p>A signal declaration declares a <i>signal</i> of the specified type. Such a signal is an <i>explicitly declared signal</i>.
<pre> signal_declaration ::=
<b>signal</b> identifier_list : subtype_indication [ signal_kind ] [ := expression ] ;
signal_kind ::= <b>register</b> | <b>bus</b>
</pre>
<p>If the name of a resolution function appears in the declaration of a signal or in the declaration of the subtype used to declare the signal, then that resolution function is associated with the declared signal. Such a signal is called a <i>resolved</i> <i>signal</i>.
<p>If a signal kind appears in a signal declaration, then the signals so declared are <i>guarded</i> signals of the kind indicated. For a guarded signal that is of a composite type, each subelement is likewise a guarded signal. For a guarded signal that is of an array type, each slice (see <a href = "1076_6.HTM#6.5"> 6.5 </a> ) is likewise a guarded signal. A guarded signal may be assigned values under the control of Boolean-valued <i>guard expressions</i> (or <i>guards</i>).
<p>When a given guard becomes False, the drivers of the corresponding guarded signals are implicitly assigned a null transaction (see <a href = "1076_8.HTM#8.4.1"> 8.4.1 </a> ) to cause those drivers to turn off. A disconnection specification (see <a href = "1076_5.HTM#5.3"> 5.3 </a> ) is used to specify the time required for those drivers to turn off.
<p>If the signal declaration includes the assignment symbol followed by an expression, it must be of the same type as the signal. Such an expression is said to be a <i>default expression</i>. The default expression defines a <i>default value</i> associated with the signal or, for a composite signal,with each scalar subelement thereof. For a signal declared to be of a scalar subtype, the value of the default expression is the default value of the signal. For a signal declared to be of a composite subtype, each scalar subelement of the value of the default expression is the default value of the corresponding subelement of the signal.
<p>In the absence of an explicit default expression, an implicit default value is assumed for a signal of a scalar subtype or for each scalar subelement of a composite signal, each of which is itself a signal of a scalar subtype. The implicit default value for a signal of a scalar subtype T is defined to be that given by T'LEFT.
<p>It is an error if a signal declaration declares a signal that is of a file type or an access type. It is also an error if a guarded signal of a scalar type is neither a resolved signal nor a subelement of a resolved signal.
<p>A signal may have one or more <i>sources</i>. For a signal of a scalar type,each source is either a driver (see <a href = "1076_12.HTM#12.6.1"> 12.6.1 </a> ) or an <b>out</b>, <b>inout</b>,<b>buffer</b>, or <b>linkage</b> port of a component instance or of a block statement with which the signal is associated. For a signal of a composite type, each composite source is a collection of scalar sources, one for each scalar subelement of the signal. It is an error if, after the elaboration of a description, a signal has multiple sources and it is not a resolved signal. It is also an error if, after the elaboration of a description, a resolved signal has more sources than the number of elements in the index range of the type of the formal parameter of the resolution function associated with the resolved signal.
<p>If a subelement or slice of a resolved signal of composite type is associated as an actual in a port map aspect (either in a component instantiation statement or in a binding indication), and if the corresponding formal is of mode <b>out</b>, <b>inout</b>, <b>buffer</b>, or <b>linkage</b>, then every scalar subelement of that signal must be associated exactly once with such a formal in the same port map aspect, and the collection of the corresponding formal parts taken together constitute one source of the signal. If a resolved signal of composite type is associated as an actual in a port map aspect, that is equivalent to each of its subelements being associated in the same port map aspect.
<p>If a subelement of a resolved signal of composite type has a driver in a given process, then every scalar subelement of that signal must have a driver in the same process, and the collection of all of those drivers taken together constitute one source of the signal.
<p>The default value associated with a scalar signal defines the value component of a transaction that is the initial contents of each driver (if any) of that signal. The time component of the transaction is not defined, but the transaction is understood to have already occurred by the start of simulation.
<p><i>Examples:</i>
<pre> <b>signal</b> S : STANDARD.BIT_VECTOR (1 <b>to</b> 10) ;
<b>signal</b> CLK1, CLK2 : TIME ;
<b>signal</b> OUTPUT : WIRED_OR MULTI_VALUED_LOGIC;
</pre>
<h4>NOTES</h4>
<p>1--Ports of any mode are also signals. The term <i>signal</i> is used in this standard to refer to objects declared either by signal declarations or by port declarations (or to subelements, slices, or aliases of such objects). It also refers to the implicit signal GUARD (see <a href = "1076_9.HTM#9.1"> 9.1 </a> ) and to implicit signals defined by the predefined attributes 'DELAYED, 'STABLE, 'QUIET, and 'TRANSACTION. The term <i>port</i> is used to refer to objects declared by port declarations only.
<p>2--Signals are given initial values by initializing their drivers. The initial values of drivers are then propagated through the corresponding net to determine the initial values of the signals that make up the net (see <a href = "1076_12.HTM#12.6.3"> 12.6.3 </a> ).
<p>3--The value of a signal may be indirectly modified by a signal assignment statement (see <a href = "1076_8.HTM#8.4"> 8.4 </a> ); such assignments affect the future values of the signal.
<p>4--The subelements of a composite, declared signal are not declared signals.
<p><i>Cross-References:</i> Disconnection specifications, <a href = "1076_5.HTM#5.3"> 5.3 </a> ; Disconnection statements, <a href = "1076_9.HTM#9.5"> 9.5 </a> ; Guarded assignment, <a href = "1076_9.HTM#9.5"> 9.5 </a> ; Guarded blocks, <a href = "1076_9.HTM#9.1"> 9.1 </a> ; Guarded targets, <a href = "1076_9.HTM#9.5"> 9.5 </a> ; Signal guard, <a href = "1076_9.HTM#9.1"> 9.1 </a> .
<h4><a name="4.3.1.3"> <a href = "1076_4.HTM#4.3.1.3"> 4.3.1.3 </a> Variable declarations</a></h4>
<p>A variable declaration declares a <i>variable</i> of the specified type. Such a variable is an <i>explicitly declared variable</i>.
<pre> variable_declaration ::=
[ <b>shared</b> ] <b>variable</b> identifier_list : subtype_indication [ := expression ] ;
</pre>
<p>A variable declaration that includes the reserved word <b>shared</b> is a <i>shared variable declaration</i>. A shared variable declaration declares a <i>shared variable</i>. Shared variables are a subclass of the variable class of objects. More than one process may access a given shared variable; however,if more than one process accesses a given shared variable during the same simulation cycle (see <a href = "1076_12.HTM#12.6.4"> 12.6.4 </a> ), neither the value of the shared variable after the access nor the value read from the shared variable is defined by the language. A description is erroneous if it depends on whether or how an implementation sequentializes access to shared variables.
<p>If the variable declaration includes the assignment symbol followed by an expression, the expression specifies an initial value for the declared variable; the type of the expression must be that of the variable. Such an expression is said to be an <i>initial value expression</i>.
<p>If an initial value expression appears in the declaration of a variable, then the initial value of the variable is determined by that expression each time the variable declaration is elaborated. In the absence of an initial value expression, a default initial value applies. The default initial value for a /variable of a scalar subtype T is defined to be the value given by T'LEFT. The default initial value of a variable of a composite type is defined to be the aggregate of the default initial values of all of its scalar subelements, each of which is itself a variable of a scalar subtype. The default initial value of a variable of an access type is defined to be the value <b>null</b> for that type.
<h4>NOTES</h4>
<p>1--The value of a variable may be modified by a variable assignment statement (see <a href = "1076_8.HTM#8.5"> 8.5 </a> ); such assignments take effect immediately.
<p>2--The variables declared within a given procedure persist until that procedure completes and returns to the caller. For procedures that contain wait statements, a variable may therefore persist from one point in simulation time to another, and the value in the variable is thus maintained over time. For processes, which never complete, all variables persist from the beginning of simulation until the end of simulation.
<p>3--The subelements of a composite, declared variable are not declared variables.
<p>4--Since the language does not guarantee the synchronization of accesses to shared variables by multiple processes in the same simulation cycle, the use of shared variables in this manner is non portable and nondeterministic. For example, consider the following architecture:
<pre> <b>architecture</b> UseSharedVariables <b>of</b> SomeEntity is
<b>subtype</b> ShortRange <b>is</b> INTEGER <b>range</b> 0 <b>to</b> 1;
<b>shared</b> <b>variable</b> Counter: ShortRange := 0;
<b>begin</b>
PROC1: <b>process</b>
<b>begin</b>
Counter := Counter + 1; -- The subtype check may or may not fail.
<b>wait</b>;
<b>end</b> <b>process</b> PROC1;
PROC2: <b>process</b>
<b>begin</b>
Counter := Counter - 1; -- The subtype check may or may not fail.
<b>wait</b>;
<b>end</b> <b>process</b> PROC2;
<b> end</b> <b>architecture</b> UseSharedVariables;
</pre>
<p>In particular, the value of Counter after the execution of both processes is not guaranteed to be either 0 or 1, even if Counter is declared to be of type INTEGER.
<p>5--Variables declared immediately within entity declarations, architecture bodies, packages, package bodies, and blocks must be shared variables. Variables declared immediately within subprograms and processes must not be shared variables.
<p><i>Examples:</i>
<pre> <b>variable</b> INDEX : INTEGER <b>range</b> 0 <b>to</b> 99 := 0 ;
-- Initial value is determined by the initial value expression
<b>variable</b> COUNT : POSITIVE ;
-- Initial value is POSITIVE'LEFT; that is,1.
<b>variable</b> MEMORY : BIT_MATRIX (0 <b>to</b> 7, 0 <b>to</b> 1023) ;
-- Initial value is the aggregate of the initial values of each element
</pre>
<h4><a name="4.3.1.4"> <a href = "1076_4.HTM#4.3.1.4"> 4.3.1.4 </a> File declarations</a></h4>
<p>A file declaration declares a <i>file</i> of the specified type. Such a file is an <i>explicitly declared file</i>.
<pre> file_declaration ::=
<b>file</b> identifier_list : subtype_indication [ file_open_information ] ;
file_open_information ::= [ <b>open</b> <i>file_open_kind</i>_expression ] <b>is</b> file_logical_name
file_logical_name ::= <i>string</i>_expression
</pre>
<p>The subtype indication of a file declaration must define a file subtype.
<p>If file open information is included in a given file declaration, then the file declared by the declaration is opened (see <a href = "1076_3.HTM#3.4.1"> 3.4.1 </a> ) with an implicit call to FILE_OPEN when the file declaration is elaborated (see <a href = "1076_12.HTM#12.3.1.4"> 12.3.1.4 </a> ). This implicit call is to the FILE_OPEN procedure of the first form, and it associates the identifier with the file parameter F, the file logical name with the External_Name parameter, and the file open kind expression with the Open_Kind parameter. If a file open kind expression is not included in the file open information of a given file declaration, then the default value of READ_MODE is used during elaboration of the file declaration.
<p>If file open information is not included in a given file declaration, then the file declared by the declaration is not opened when the file declaration is elaborated.
<p>The file logical name must be an expression of predefined type STRING. The value of this expression is interpreted as a logical name for a file in the host system environment. An implementation must provide some mechanism to associate a file logical name with a host-dependent file. Such a mechanism is not defined by the language.
<p>The file logical name identifies an external file in the host file system that is associated with the file object. This association provides a mechanism for either importing data contained in an external file into the design during simulation or exporting data generated during simulation to an external file.
<p>If multiple file objects are associated with the same external file, and each file object has an access mode that is read-only (see <a href = "1076_3.HTM#3.4.1"> 3.4.1 </a> ), then values read from each file object are read from the external file associated with the file object. The language does not define the order in which such values are read from the external file, nor does it define whether each value is read once or multiple times (once per file object).
<p>The language does not define the order of and the relationship, if any, between values read from and written to multiple file objects that are associated with the same external file. An implementation may restrict the number of file objects that may be associated at one time with a given external file.
<p>If a formal subprogram parameter is of the class <b>file</b>, it must be associated with an actual that is a file object.
<p><i>Examples:</i>
<pre> <b>type</b> IntegerFile <b>is</b> <b>file</b> <b>of</b> INTEGER;
<b>file</b> F1: IntegerFile; -- No implicit FILE_OPEN is performed
-- during elaboration.
?? 快捷鍵說明
復(fù)制代碼
Ctrl + C
搜索代碼
Ctrl + F
全屏模式
F11
切換主題
Ctrl + Shift + D
顯示快捷鍵
?
增大字號
Ctrl + =
減小字號
Ctrl + -