?? 1076_3.html
字號:
<b>signal</b> DATA_LINE : DATA_IN ;
-- Defines a data input line.
<b>variable</b> MY_MEMORY : MEMORY (0 <b>to</b> 2<sup>n-1</sup>) ;
-- Defines a memory of 2<sup>n</sup> 32-bit words.
</pre>
<p>NOTE--The rules concerning constrained type declarations mean that a type declaration with a constrained array definition such as
<pre> <b>type</b> T <b>is</b> <b>array</b> (POSITIVE <b>range</b> MINIMUM <b>to</b> MAX) <b>of</b> ELEMENT;
</pre>
<p>is equivalent to the sequence of declarations
<pre> <b>subtype</b> <i>index_subtype</i> <b>is</b> POSITIVE <b>range</b> MINIMUM <b>to</b> MAX;
<b>type</b> <i>array_type</i> <b>is array</b> (<i>index_subtype</i> <b>range</b> <>) <b>of</b> ELEMENT;
<b>subtype</b> T <b>is</b> <i>array</i>_<i>type</i> (<i>index_subtype)</i>;
</pre>
<p>where <i>index_subtype</i> and <i>array_type</i> are both anonymous. Consequently, T is the name of a subtype and all objects declared with this type mark are arrays that have the same index range.
<h4><a name="3.2.1.1"> <a href = "1076_3.HTM#3.2.1.1"> 3.2.1.1 </a> Index constraints and discrete ranges</a></h4>
<p>An index constraint determines the index range for every index of an array type and, thereby, the corresponding array bounds.
<p>For a discrete range used in a constrained array definition and defined by a range, an implicit conversion to the predefined type INTEGER is assumed if each bound is either a numeric literal or an attribute, and if the type of both bounds (prior to the implicit conversion) is the type <i>universal_integer</i>. Otherwise, both bounds must be of the same discrete type, other than <i>universal_integer</i>; this type must be determined independently of the context, but using the fact that the type must be discrete and that both bounds must have the same type. These rules apply also to a discrete range used in an iteration scheme (see <a href = "1076_8.HTM#8.9"> 8.9 </a> ) or a generation scheme (see <a href = "1076_9.HTM#9.7"> 9.7 </a> ).
<p>If an index constraint appears after a type mark in a subtype indication, then the type or subtype denoted by the type mark must not already impose an index constraint. The type mark must denote either an unconstrained array type or an access type whose designated type is such an array type. In either case, the index constraint must provide a discrete range for each index of the array type, and the type of each discrete range must be the same as that of the corresponding index.
<p>An index constraint is <i>compatible</i> with the type denoted by the type mark if and only if the constraint defined by each discrete range is compatible with the corresponding index subtype. If any of the discrete ranges defines a null range, any array thus constrained is a <i>null array</i>, having no components. An array value <i>satisfies</i> an index constraint if at each index position the array value and the index constraint have the same index range. (Note, however, that assignment and certain other operations on arrays involve an implicit subtype conversion.)
<p>The index range for each index of an array object is determined as follows:
<ul>
<p>-- For a variable or signal declared by an object declaration, the subtype indication of the corresponding object declaration must define a constrained array subtype (and thereby, the index range for each index of the object). The same requirement exists for the subtype indication of an element declaration, if the type of the record element is an array type, and for the element subtype indication of an array type definition, if the type of the array element is itself an array type.
<p>-- For a constant declared by an object declaration, the index ranges are defined by the initial value, if the subtype of the constant is unconstrained; otherwise, they are defined by this subtype (in which case the initial value is the result of an implicit subtype conversion).
<p>-- For an attribute whose value is specified by an attribute specification, the index ranges are defined by the expression given in the specification, if the subtype of the attribute is unconstrained; otherwise, they are defined by this subtype (in which case the value of the attribute is the result of an implicit subtype conversion).
<p>-- For an array object designated by an access value, the index ranges are defined by the allocator that creates the array object (see <a href = "1076_7.HTM#7.3.6"> 7.3.6 </a> ).
<p>-- For an interface object declared with a subtype indication that defines a constrained array subtype, the index ranges are defined by that subtype.
<p>-- For a formal parameter of a subprogram that is of an unconstrained array type and that is associated in whole (see <a href = "1076_4.HTM#4.3.2.2"> 4.3.2.2 </a> ), the index ranges are obtained from the corresponding association element in the applicable subprogram call.
<p>-- For a formal parameter of a subprogram that is of an unconstrained array type and whose subelements are associated individually (see <a href = "1076_4.HTM#4.3.2.2"> 4.3.2.2 </a> ), the index ranges are obtained as follows:
<p> The directions of the index ranges of the formal parameter are that of the type of the formal; the high and low bounds of the index ranges are respectively determined from the maximum and minimum values of the indices given in the association elements corresponding to the formal.
<p>-- For a formal generic or a formal port of a design entity or of a block statement that is of an unconstrained array type and that is associated in whole, the index ranges are obtained from the corresponding association element in the generic map aspect (in the case of a formal generic) or port map aspect (in the case of a formal port) of the applicable (implicit or explicit) binding indication.
<p>-- For a formal generic or a formal port of a design entity or of a block statement that is of an unconstrained array type and whose subelements are associated individually, the index ranges are obtained as follows:
<p> The directions of the index ranges of the formal generic or formal port are that of the type of the formal; the high and low bounds of the index ranges are respectively determined from the maximum and minimum values of the indices given in the association elements corresponding to the formal.
<p>-- For a local generic or a local port of a component that is of an unconstrained array type and that is associated in whole, the index ranges are obtained from the corresponding association element in the generic map aspect (in the case of a local generic) or port map aspect (in the case of a local port) of the applicable component instantiation statement.
<p>-- For a local generic or a local port of a component that is of an unconstrained array type and whose subelements are associated individually, the index ranges are obtained as follows:
<p> The directions of the index ranges of the local generic or local port are that of the type of the local; the high and low bounds of the index ranges are respectively determined from the maximum and minimum values of the indices given in the association elements corresponding to the local.
</ul>
<p>If the index ranges for an interface object, or member of an interface object, are obtained from the corresponding association element (when associating in whole) or elements (when associating individually), then they are determined either by the actual part(s) or by the formal part(s) of the association element(s), depending upon the mode of the interface object, as follows:
<ul>
<p>-- For an interface object or member of an interface object whose mode is <b>in</b>, <b>inout</b>, or <b>linkage</b>, if the actual part includes a conversion function or a type conversion, then the result type of that function or the type mark of the type conversion must be a constrained array subtype, and the index ranges are obtained from this constrained subtype;otherwise, the index ranges are obtained from the object or value denoted by the actual designator(s).
<p>-- For an interface object or member of an intercace object whose mode is <b>out</b>, <b>buffer</b>, <b>inout</b>,or <b>linkage</b>, if the formal part includes a conversion function or a type conversion, then the parameter subtype of that function or the type mark of the type conversion must be a constrained array subtype, and the index ranges are obtained from this constrained subtype; otherwise, the index ranges are obtained from the object denoted by the actual designator(s).
</ul>
<p>For an interface object of mode <b>inout</b> or <b>linkage</b>, the index ranges determined by the first rule must be identical to the index ranges determined by the second rule.
<p><i>Examples:</i>
<pre> <b>type</b> Word <b>is</b> <b>array</b> (NATURAL <b>range</b> <>) <b>of</b> BIT;
<b>type</b> Memory <b>is</b> <b>array</b> (NATURAL <b>range</b> <>) <b>of</b> Word (31 <b>downto</b> 0);
<b>constant</b> A_Word: Word := "10011";
-- The index range of A_Word is 0 <b>to</b> 4
<b>entity</b> E <b>is</b>
<b>generic</b> (ROM: Memory);
<b>port</b> (Op1, Op2: <b>in</b> Word; Result: <b>out</b> Word);
<b>end</b> <b>entity</b> E;
-- The index ranges of the generic and the ports are defined by the actuals associated
-- with an instance bound to E; these index ranges are accessible via the predefined
-- array attributes (see <a href = "1076_14.HTM#14.1">14.1 </a> ).
<b>signal</b> A, B: Word (1 <b>to</b> 4);
<b>signal</b> C: Word (5 <b>downto</b> 0);
Instance: <b>entity</b> E
<b>generic</b> <b>map</b> ((1 <b>to</b> 2) => (<b>others</b> => '0'))
<b>port</b> <b>map</b> (A, Op2(3 <b>to</b> 4) => B (1 <b>to</b> 2), Op2(2) => B (3), Result => C (3 <b>downto</b> 1));
-- In this instance, the index range of ROM is 1 <b>to</b> 2 (matching that of the actual),
-- The index range of Op1 is 1 <b>to</b> 4 (matching the index range of A), the index range
-- of Op2 is 2 <b>to</b> 4, and the index range of Result is (3 <b>downto</b> 1)
-- (again matching the index range of the actual).
</pre>
<h4><a name="3.2.1.2"> <a href = "1076_3.HTM#3.2.1.2"> 3.2.1.2 </a> Predefined array types</a></h4>
<p>The predefined array types are STRING and BIT_VECTOR, defined in package STANDARD in Section 14.
<p>The values of the predefined type STRING are one-dimensional arrays of the predefined type CHARACTER, indexed by values of the predefined subtype POSITIVE:
<pre> <b>subtype</b> POSITIVE <b>is</b> INTEGER <b>range</b> 1 <b>to</b> INTEGER'HIGH ;
<b>type</b> STRING <b>is</b> <b>array </b>(POSITIVE <b>range</b> <>) <b>of</b> CHARACTER ;
</pre>
<p>The values of the predefined type BIT_VECTOR are one-dimensional arrays of the predefined type BIT, indexed by values of the predefined subtype NATURAL:
<pre> <b>subtype</b> NATURAL <b>is</b> INTEGER <b>range</b> 0 <b>to</b> INTEGER'HIGH ;
<b>type</b> BIT_VECTOR <b>is</b> <b>array</b> (NATURAL <b>range</b> <>) <b>of</b> BIT ;
</pre>
<p><i>Examples:</i>
<pre> <b>variable</b> MESSAGE : STRING(1 <b>to</b> 17) := "THIS IS A MESSAGE" ;
<b>signal</b> LOW_BYTE : BIT_VECTOR (0 <b>to</b> 7) ;
</pre>
<h3><a name="3.2.2"> <a href = "1076_3.HTM#3.2.2"> 3.2.2 </a> Record types</a></h3>
<p>A record type is a composite type, objects of which consist of named elements. The value of a record object is a composite value consisting of the values of its elements.
<pre> record_type_definition ::=
<b>record</b>
element_declaration
{ element_declaration }
<b>end</b> <b>record</b> [ <i>record_type</i>_simple_name ]
element_declaration ::=
identifier_list : element_subtype_definition ;
identifier_list ::= identifier { , identifier }
element_subtype_definition ::= subtype_indication
</pre>
<p>Each element declaration declares an element of the record type. The identifiers of all elements of a record type must be distinct. The use of a name that denotes a record element is not allowed within the record type definition that declares the element.
<p>An element declaration with several identifiers is equivalent to a sequence of single element declarations. Each single element declaration declares a record element whose subtype is specified by the element subtype definition.
<p>If a simple name appears at the end of a record type declaration, it must repeat the identifier of the type declaration in which the record type definition is included.
<p>A record type definition creates a record type; it consists of the element declarations in the order in which they appear in the type definition.
<p><i>Example:</i>
<pre> <b>type</b> DATE <b>is</b>
<b>record</b>
DAY :INTEGER <b>range</b> 1 <b>to</b> 31;
MONTH :MONTH_NAME;
YEAR :INTEGER <b>range</b> 0 <b>to</b> 4000;
<b>end</b> <b>record</b>;
</pre>
<h2><a name="3.3"> <a href = "1076_3.HTM#3.3"> 3.3 </a> Access types</a></h2>
<p>An object declared by an object declaration is created by the elaboration of the object declaration and is denoted by a simple name or by some other form of name. In contrast, objects that are created by the evaluation of allocators (see <a href = "1076_7.HTM#7.3.6"> 7.3.6 </a> ) have no simple name. Access to such an object is achieved by an <i>access value</i> returned by an allocator; the access value is said to <i>designate</i> the object.
<pre> access_type_definition ::= <b>access</b> subtype_indication
</pre>
<p>For each access type, there is a literal <b>null</b> that has a null access value designating no object at all. The null value of an access type is the default initial value of the type. Other values of an access type are obtained by evaluation of a special operation of the type, called an <i>allocator</i>. Each such access value designates an object of the subtype defined by the subtype indication of the access type definition. This subtype is called the <i>designated subtype</i> and the base type of this subtype is called the <i>designated type</i>. The designated type must not be a file type.
<p>An object declared to be of an access type must be an object of class variable. An object designated by an access value is always an object of class variable.
<p>The only form of constraint that is allowed after the name of an access type in a subtype indication is an index constraint. An access value belongs to a corresponding subtype of an access type either if the access value is the null value or if the value of the designated object satisfies the constraint.
<p><i>Examples:</i>
<pre> <b>type</b> ADDRESS <b>is access</b> MEMORY;
<b>type</b> BUFFER_PTR <b>is access</b> TEMP_BUFFER;
</pre>
?? 快捷鍵說明
復制代碼
Ctrl + C
搜索代碼
Ctrl + F
全屏模式
F11
切換主題
Ctrl + Shift + D
顯示快捷鍵
?
增大字號
Ctrl + =
減小字號
Ctrl + -