?? 1076_7.html
字號:
(-5) <b>rem</b> (-3) = -2
(-5) <b>mod</b> (-3) = -2
5 <b>rem</b> (-3) = 2
5 <b>mod</b> (-3) = -1
</pre>
<p>NOTE--Because of the precedence rules (see <a href = "1076_7.HTM#7.2"> 7.2 </a> ), the expression "-5 <b>rem</b> 2" is interpreted as "-(5 <b>rem</b> 2)" and not as "(-5) <b>rem</b> 2".
<h3><a name="7.2.7"> <a href = "1076_7.HTM#7.2.7"> 7.2.7 </a> Miscellaneous operators</a></h3>
<p>The unary operator <b>abs</b> is predefined for any numeric type.<br><br>
<center>
<table border="1">
<tr><td align="center"><b>Operator</b><td align="center"><b>Operation</b><td align="center"><b>Operand type</b><td align="center"><b>Result type</b></tr>
<tr><td align="center"><b>abs</b><td align="center">Absolute value<td align="center">Any numeric type<td align="center">Same numeric type</tr>
</table>
</center>
<p>
<p>The <i>exponentiating</i> operator ** is predefined for each integer type and for each floating point type. In either case the right operand, called the exponent, is of the predefined type INTEGER.<br><br>
<center>
<table border="1">
<tr><td align="center"><b>Operator</b><td align="center"><b>Operation</b><td><b>Left operand type</b><td><b>Right operand type</b><td><b>Result type</b></tr>
<tr><td rowspan="2" align="center">**<td rowspan="2" align="center">Exponentiation<td>Any integer type<td>INTEGER<td>Same as left</tr>
<tr><td>Any floating point type<td>INTEGER<td>Same as left</tr>
</table>
</center>
<p>
<p>Exponentiation with an integer exponent is equivalent to repeated multiplication of the left operand by itself for a number of times indicated by the absolute value of the exponent and from left to right; if the exponent is negative, then the result is the reciprocal of that obtained with the absolute value of the exponent. Exponentiation with a negative exponent is only allowed for a left operand of a floating point type. Exponentiation by a zero exponent results in the value one. Exponentiation of a value of a floating point type is approximate.
<h2><a name="7.3"> <a href = "1076_7.HTM#7.3"> 7.3 </a> Operands</a></h2>
<p>The operands in an expression include names (that denote objects, values, or attributes that result in a value), literals, aggregates, function calls, qualified expressions, type conversions, and allocators. In addition, an expression enclosed in parentheses may be an operand in an expression. Names are defined in <a href = "1076_6.HTM#6.1"> 6.1 </a> ; the other kinds of operands are defined in the following subclauses.
<h3><a name="7.3.1"> <a href = "1076_7.HTM#7.3.1"> 7.3.1 </a> Literals</a></h3>
<p>A literal is either a numeric literal, an enumeration literal, a string literal, a bit string literal, or the literal <b>null</b>.
<pre> literal ::=
numeric_literal
| enumeration_literal
| string_literal
| bit_string_literal
| <b>null</b>
numeric_literal ::=
abstract_literal
| physical_literal
</pre>
<p>Numeric literals include literals of the abstract types <i>universal_integer</i> and <i>universal_real</i>, as well as literals of physical types. Abstract literals are defined in <a href = "1076_13.HTM#13.4"> 13.4 </a> ; physical literals are defined in <a href = "1076_3.HTM#3.1.3"> 3.1.3 </a> .
<p>Enumeration literals are literals of enumeration types. They include both identifiers and character literals. Enumeration literals are defined in <a href = "1076_3.HTM#3.1.1"> 3.1.1 </a> .
<p>String and bit string literals are representations of one-dimensional arrays of characters. The type of a string or bit string literal must be determinable solely from the context in which the literal appears, excluding the literal itself but using the fact that the type of the literal must be a one-dimensional array of a character type. The lexical structure of string and bit string literals is defined in Section 13, Lexical Elements.
<p>For a nonnull array value represented by either a string or bit string literal,the direction and bounds of the array value are determined according to the rules for positional array aggregates, where the number of elements in the aggregate is equal to the length (see <a href = "1076_13.HTM#13.6"> 13.6 </a> and <a href = "1076_13.HTM#13.7"> 13.7 </a> ) of the string or bit string literal. For a null array value represented by either a string or bit string literal, the direction and leftmost bound of the array value are determined as in the non-null case. If the direction is ascending, then the rightmost bound is the predecessor (as given by the 'PRED attribute) of the leftmost bound; otherwise the rightmost bound is the successor (as given by the 'SUCC attribute) of the leftmost bound.
<p>The character literals corresponding to the graphic characters contained within a string literal or a bit string literal must be visible at the place of the string literal.
<p>The literal <b>null</b> represents the null access value for any access type.
<p>Evaluation of a literal yields the corresponding value.
<p><i>Examples:</i>
<pre>
3.14159_26536 -- A literal of type <i>universal_real.</i>
5280 -- A literal of type <i>universal_integer.</i>
10.7 ns -- A literal of a physical type.
O"4777" -- A bit-string literal.
"54LS281" -- A string literal.
"" -- A string literal representing a null array.
</pre>
<h3><a name="7.3.2"> <a href = "1076_7.HTM#7.3.2"> 7.3.2 </a> Aggregates</a></h3>
<p>An aggregate is a basic operation (see the introduction to Section 3) that combines one or more values into a composite value of a record or array type.
<pre> aggregate ::=
( element_association { , element_association } )
element_association ::=
[ choices => ] expression
choices ::= choice { | choice }
choice ::=
simple_expression
| discrete_range
| <i>element</i>_simple_name
| <b>others</b>
</pre>
<p>Each element association associates an expression with elements (possibly none). An element association is said to be <i>named</i> if the elements are specified explicitly by choices; otherwise, it is said to be <i>positional</i>. For a positional association, each element is implicitly specified by position in the textual order of the elements in the corresponding type declaration.
<p>Both named and positional associations can be used in the same aggregate, with all positional associations appearing first (in textual order) and all named associations appearing next (in any order, except that no associations may follow an <b>others</b> association). Aggregates containing a single element association must always be specified using named association in order to distinguish them from parenthesized expressions.
<p>An element association with a choice that is an element simple name is only allowed in a record aggregate. An element association with a choice that is a simple expression or a discrete range is only allowed in an array aggregate: a simple expression specifies the element at the corresponding index value, whereas a discrete range specifies the elements at each of the index values in the range. The discrete range has no significance other than to define the set of choices implied by the discrete range. In particular, the direction specified or implied by the discrete range has no significance. An element association with the choice <b>others</b> is allowed in either an array aggregate or a record aggregate if the association appears last and has this single choice; it specifies all remaining elements, if any.
<p>Each element of the value defined by an aggregate must be represented once and only once in the aggregate.
<p>The type of an aggregate must be determinable solely from the context in which the aggregate appears, excluding the aggregate itself but using the fact that the type of the aggregate must be a composite type. The type of an aggregate in turn determines the required type for each of its elements.
<h4><a name="7.3.2.1"> <a href = "1076_7.HTM#7.3.2.1"> 7.3.2.1 </a> Record aggregates</a></h4>
<p>If the type of an aggregate is a record type, the element names given as choices must denote elements of that record type. If the choice <b>others</b> is given as a choice of a record aggregate, it must represent at least one element. An element association with more than one choice, or with the choice <b>others</b>, is only allowed if the elements specified are all of the same type. The expression of an element association must have the type of the associated record elements.
<p>A record aggregate is evaluated as follows. The expressions given in the element associations are evaluated in an order (or lack thereof) not defined by the language. The expression of a named association is evaluated once for each associated element. A check is made that the value of each element of the aggregate belongs to the subtype of this element. It is an error if this check fails.
<h4><a name="7.3.2.2"> <a href = "1076_7.HTM#7.3.2.2"> 7.3.2.2 </a> Array aggregates</a></h4>
<p>For an aggregate of a one-dimensional array type, each choice must specify values of the index type, and the expression of each element association must be of the element type. An aggregate of an n-dimensional array type, where n is greater than 1, is written as a one-dimensional aggregate in which the index subtype of the aggregate is given by the first index position of the array type, and the expression specified for each element association is an (n-1)-dimensional array or array aggregate, which is called a <i>subaggregate</i>. A string or bit string literal is allowed as a subaggregate in the place of any aggregate of a one-dimensional array of a character type.
<p>Apart from a final element association with the single choice <b>others</b>,the rest (if any) of the element associations of an array aggregate must be either all positional or all named. A named association of an array aggregate is allowed to have a choice that is not locally static, or likewise a choice that is a null range, only if the aggregate includes a single element association and this element association has a single choice. An <b>others</b> choice is locally static if the applicable index constraint is locally static.
<p>The subtype of an array aggregate that has an <b>others</b> choice must be determinable from the context. That is, an array aggregate with an <b>others</b> choice may only appear
<ol type="a">
<li>As an actual associated with a formal parameter or formal generic declared to be of a constrained array subtype (or subelement thereof)
<li>As the default expression defining the default initial value of a port declared to be of a constrained array subtype
<li>As the result expression of a function, where the corresponding function result type is a constrained array subtype
<li>As a value expression in an assignment statement, where the target is a declared object, and the subtype of the target is a constrained array subtype (or subelement of such a declared object)
<li>As the expression defining the initial value of a constant or variable object, where that object is declared to be of a constrained array subtype
<li>As the expression defining the default values of signals in a signal declaration, where the corresponding subtype is a constrained array subtype
<li>As the expression defining the value of an attribute in an attribute specification, where that attribute is declared to be of a constrained array subtype
<li>As the operand of a qualified expression whose type mark denotes a constrained array subtype
<li>i) As a subaggregate nested within an aggregate, where that aggregate itself appears in one of these contexts
</ol>
<p>The bounds of an array that does not have an <b>others</b> choice are determined as follows. If the aggregate appears in one of the contexts in the preceding list, then the direction of the index subtype of the aggregate is that of the corresponding constrained array subtype; otherwise, the direction of the index subtype of the aggregate is that of the index subtype of the base type of the aggregate. For an aggregate that has named associations, the leftmost and rightmost bounds are determined by the direction of the index subtype of the aggregate and the smallest and largest choices given. For a positional aggregate, the leftmost bound is determined by the applicable index constraint if the aggregate appears in one of the contexts in the preceding list; otherwise, the leftmost bound is given by S'LEFT where S is the index subtype of the base type of the array. In either case, the rightmost bound is determined by the direction of the index subtype and the number of elements.
<p>The evaluation of an array aggregate that is not a subaggregate proceeds in two steps. First, the choices of this aggregate and of its subaggregates, if any,are evaluated in some order (or lack thereof) that is not defined by the language. Second, the expressions of the element associations of the array aggregate are evaluated in some order that is not defined by the language; the expression of a named association is evaluated once for each associated element. The evaluation of a subaggregate consists of this second step (the first step is omitted since the choices have already been evaluated).
<p>For the evaluation of an aggregate that is not a null array, a check is made that the index values defined by choices belong to the corresponding index subtypes, and also that the value of each element of the aggregate belongs to the subtype of this element. For a multidimensional aggregate of dimension n, a check is made that all (n-1)-dimensional subaggregates have the same bounds. It is an error if any one of these checks fails.
<h3><a name="7.3.3"> <a href = "1076_7.HTM#7.3.3"> 7.3.3 </a> Function calls</a></h3>
<p>A function call invokes the execution of a function body. The call specifies the name of the function to be invoked and specifies the actual parameters, if any, to be associated with the formal parameters of the function. Execution of the function body results in a value of the type declared to be the result type in the declaration of the invoked function.
<pre> function_call ::=
?? 快捷鍵說明
復制代碼
Ctrl + C
搜索代碼
Ctrl + F
全屏模式
F11
切換主題
Ctrl + Shift + D
顯示快捷鍵
?
增大字號
Ctrl + =
減小字號
Ctrl + -