TWiki
>
P1076 Web
>
VHDL2017
>
LCS2016_034
(2017-07-16,
JimLewis
)
(raw view)
E
dit
A
ttach
---+ Language Change Specification for Protected Types with Generic Clause ---++ | <sticky><b>LCS Number:</b></sticky> | LCS-2016-034 | | <sticky><b>Version:</b> </sticky> | 10 | | <sticky><b>Date:</b> </sticky> | 10-Mar-2017 | | <sticky><b>Status:</b> </sticky> | Voting | | <sticky><b>Author:</b> </sticky> | Jim Lewis | | <sticky><b>Email:</b> </sticky> | [[Main.JimLewis]] | | <sticky><b>Source Doc:</b></sticky> | [[GenericTypes][Protected Types with Generic Clause]] | | <sticky><b>More Doc:</b></sticky> | [[LCS2016_034_history][history]] | | <sticky><b>Summary:</b> </sticky> | Protected Types with Generic Clause | <noautolink> <sticky> ---++ Style Notes Changes are shown in %RED%red font%ENDCOLOR%. Deletions are %RED%<del>crossed out</del>%ENDCOLOR%. Editing notes in %GREEN%green font%ENDCOLOR%. ---++ Reviewing Notes This LCS borrows heavily from the 1076-2008 addition of generics to packages and subprograms. See LCS-2006-133 and LCS-2006-134 ---++ Details of Language Change ---+++ 5.6 Protected types ---++++ 5.6.2 Protected type declarations ---+++++ 034.1: after 1st paragraph of 5.6.2 production for protected type declaration on page 58 <pre> protected_type_declaration ::= protected %RED%protected_type_header%ENDCOLOR% protected_type_declarative_part end protected [ protected_type_simple_name ] %RED%protected_type_header ::= [ generic_clause [ generic_map_aspect ; ] ]%ENDCOLOR%</pre> ---+++++ 034.2: Immediately after BNF productions for protected type declaration on page 58 %GREEN%[Author Comment: First paragraph provided for editing location reference]%ENDCOLOR% If a simple name appears at the end of a protected type declaration, it shall repeat the identifier of the type declaration in which the protected type definition is included. <font color="red">If the protected type header is empty, the protected type declared by a protected type declaration is called a simple protected type. If the protected type header contains a generic clause and no generic map aspect, the protected type is called an uninstantiated protected type. If the protected type header contains both a generic clause and a generic map aspect, the protected type is called a generic-mapped protected type. A protected type declared with a generic clause in which every generic declaration has a default, and with no generic map aspect, is still considered to be an uninstantiated protected type and is not a generic-mapped protected type with default associations for all of the generic declarations.</font> ---+++++ 034.3: Add example following other examples in 5.6.2 on page 59 just before 5.6.3 <pre><font color="red"> -- A protected type with a generic clause type ScoreBoardGenericPType is protected generic ( type ExpectedType ; type ActualType ; function check(Actual : ActualType ; Expected : ExpectedType) return boolean ) ; ... end protected ScoreBoardGenericPType ; </font></pre> ---++++ 034.4: New section: 5.6.4 Protected type instantiation definition <font color="red">A protected type instantiation declaration defines an instance of an uninstantiated protected type. The instance is called an instantiated protected type. A protected type instantiation declaration is the conjunction of a type declaration (see 6.2) and a protected type instantiation definition. </font> <pre>%RED%protected_type_instantiation_definition ::= new uninstantiated_protected_type_name [ generic_map_aspect ]%ENDCOLOR%</pre> <font color="red">The uninstantiated protected type name shall denote an uninstantiated protected type declared in a protected type declaration. The generic map aspect, if present, optionally associates a single actual with each formal generic (or member thereof) in the corresponding protected type declaration. Each formal generic (or member thereof) shall be associated at most once. The generic map aspect is described in 6.5.7.2. The protected type instantiation declaration is equivalent to a protected type declaration and a protected type body that jointly define a generic-mapped protected type. The simple name of the generic-mapped protected type declaration is the identifier of the protected type instantiation declaration. The generic-mapped protected type declaration has the generic clause of the uninstantiated protected type declaration, the generic map aspect of the protected type instantiation declaration, and the declarations of the uninstantiated protected type declaration. The meaning of any identifier appearing anywhere in the generic-mapped protected type declaration or protected type body is that associated with the corresponding occurrence of the identifier in the protected type instantiation declaration, the uninstantiated protected type declaration, or the uninstantiated protected type body, respectively, except that an identifier that denotes the uninstantiated protected type denotes, instead, the generic-mapped protected type. If the protected type instantiation declaration occurs immediately within an enclosing package declaration, the generic-mapped protected type body occurs at the end of the package body corresponding to the enclosing package declaration. If there is no such package body, then there is implicitly a package body corresponding to the enclosing package declaration, and that implicit body contains the generic-mapped protected type body. Examples: </font><pre><font color="red"> -- See 5.6.2 for declaration of ScoreBoardGenericPType type ScoreBoardPType_slv is new ScoreBoardGenericPType generic map ( ExpectedType => std_logic_vector, ActualType => std_logic_vector, check => std_match ) ; </font></pre> ---+++ 6.2 Type declarations ---++++ 034.5: Modify the production for type definition on page 64 <pre> type_definition ::= scalar_type_definition | composite_type_definition | access_type_definition | file_type_definition | protected_type_definition %RED% | protected_type_instance_definition%ENDCOLOR%</pre> ---+++ 6.4.2.4 Variable declarations ---++++ 034.6: Modify the production for variable delcaration as below on page 70 <pre>variable_declaration ::= [ shared ] variable identifier_list : subtype_indication %RED%[ generic_map_aspect ]%ENDCOLOR% [ := expression ] ;</pre> ---++++ 034.7: New paragraph. Becomes 2nd paragraph after the above variable declaration production on page 70 <font color="red">When a generic map aspect is present, the subtype indication shall denote an uninstantiated protected type declared in a protected type declaration. The generic map aspect, in this case, optionally associates a single actual with each formal generic (or member thereof) in the corresponding protected type declaration. Each formal generic (or member thereof) shall be associated at most once. The generic map aspect is described in 6.5.7.2. For a variable declaration whose type is specified by an uninstantiated protected type and generic map aspect there is an equivalent implicit protected type instance declaration and a variable declaration whose type is the implicitly defined protected type instance. The implicit protected type instance is defined immediately prior to the variable declaration in the same declarative region. A reference to the variable declaration whose type is an uninstantiated protected type and a generic map aspect is the same as a reference to a variable declaration whose type is an explicitly declared protected type instance. The implicitly defined protected type instance declaration does not have a simple name. It is an error if the subtype denotes an uninstantiated protected type and a formal generic does not get a value through either association or a default value. It is an error if a generic map aspect is present and the subtype indication is not an uninstantiated protected type. </font> ---++++ 034.8: Edit Examples at end of 6.4.2.4 on page 71 Examples: <pre>%RED%<strike> variable INDEX: INTEGER range 0 to 99 := 0; -- Initial value is determined by the initial value expression variable COUNT: POSITIVE; -- Initial value is POSITIVE'LEFT; that is,1 variable MEMORY: BIT_MATRIX (0 to 7, 0 to 1023); -- Initial value is the aggregate of the initial values of each element shared variable Counter: SharedCounter; -- See 5.6.2 and 5.6.3 for the definitions of SharedCounter shared variable addend, augend, result: ComplexNumber; -- See 5.6.2 and 5.6.3 for the definition of ComplexNumber variable bit_stack: VariableSizeBitArray; -- See 5.6.2 and 5.6.3 for the definition of VariableSizeBitArray; </strike> architecture A of E is -- See 5.6.2, 5.6.3, and 5.6.4 for related protected type declarations shared variable Counter: SharedCounter; shared variable addend, augend, result: ComplexNumber; shared variable ScoreBoard_slv : ScoreBoardPType_slv ; shared variable ScoreBoard_int : ScoreBoardGenericPType generic map ( ExpectedType => integer, ActualType => integer, check => std.standard."=" ) ; begin process variable INDEX: INTEGER range 0 to 99 := 0; -- Initial value is determined by the initial value expression variable COUNT: POSITIVE; -- Initial value is POSITIVE'LEFT; that is 1 variable MEMORY: BIT_MATRIX (0 to 7, 0 to 1023); -- Initial value is the aggregate of -- the initial values of each element variable bit_stack: VariableSizeBitArray; begin . . . </font></pre> ---+++ 6.5.2 Interface object declarations ---++++ 034.9: Page 73, First paragraph of section 6.5.2 <font color="green">[comment: Either need to add constants allowed as a generic to a protected type, or be more general. Edit takes the path of being more general since it removes the redundant and difficult to maintain text.]</font> An interface object declaration declares an interface object of a specified type. Interface objects include <font color="red"><strike>interface constants that appear as generics of a design entity, a component, a block, a package, or a subprogram, or as constant parameters of subprograms; interface signals that appear as ports of a design entity, component, or block, or as signal parameters of subprograms; interface variables that appear as variable parameters of subprograms; interface files that appear as file parameters of subprograms.</strike> interface constants, interface signals, interface variables, and interface files.</font> ---+++ 6.5.3 Interface type declarations ---++++ 034.10: Page 75, First paragraph of section 6.5.3 <font color="green">[Yield: to LCS_2016_049 if it is accepted]</font> An interface type declaration declares an interface type that appears <font color="red"><strike>as a generic of a design entity, a component, a block, a package, or a subprogram.</strike> in a generic clause.</font> ---+++ 6.5.4 Interface subprogram declarations ---++++ 034.11: Page 76, First paragraph of section 6.5.4 An interface subprogram declaration declares an interface subprogram that appears <font color="red"><strike>as a generic of a design entity, a component, a block, a package, or a subprogram.</strike> in a generic clause.</font> ---+++ 6.5.4 Interface subprogram declarations ---++++ 034.12: Page 77, First 2 paragraphs of the page <font color="red"><strike> Within an entity declaration, an architecture body, a component declaration, or an uninstantiated subprogram or package declaration that declares a given interface subprogram, the name of the given interface subprogram denotes an undefined subprogram declaration and body. The name of an interface subprogram declaration of a block statement (including an implied block statement representing a component instance or a bound design entity), a generic-mapped package or a generic-mapped subprogram denotes the subprogram specified as the corresponding actual in a generic association list.</strike></font> <font color="red">Within a construct that has an interface subprogram declaration, but does not map it, the name of the given interface subprogram denotes an undefined subprogram declaration and body. Within a construct that maps a given interface subprogram declaration, the name of the given interface subprogram denotes the subprogram specified as the corresponding actual in a generic association list.</font> ---+++ 6.5.5 Interface package declarations ---++++ 034.13: Page 77, First paragraph of section 6.5.5 An interface package declaration declares an interface package that appears <font color="red"><strike>as a generic of a design entity, a component, a block, a package, or a subprogram.</strike> in a generic clause.</font> ---++++ 034.14: Page 77, last two paragraphs of section 6.5.5 <font color="red"><strike> Within an entity declaration, an architecture body, a component declaration, or an uninstantiated subprogram or package declaration that declares a given interface package, the name of the given interface package denotes an undefined instance of the uninstantiated package. The name of an interface package declaration of a block statement (including an implied block statement representing a component instance or a bound design entity), a generic-mapped package or a genericmapped subprogram denotes the instantiated package specified as the corresponding actual in a generic association list.</strike></font> <font color="red">Within a construct that has an interface package declaration, but does not map it, the name of the given interface package denotes an undefined instance of the uninstantiated package. Within a construct that maps a given interface package declaration, the name of the given interface package denotes the instantiated package specified as the corresponding actual in a generic association list.</font> ---+++ 6.5.6 Interface lists ---++++ 6.5.6.1 General ---+++++ 034.15: Page 78, First paragraph of section 6.5.6.1 An interface list contains <font color="red"><strike>the</strike></font> interface declarations<font color="red">.</font> <font color="red"><strike>required by a subprogram, a component, a design entity, a block statement, or a package.</strike></font> ---+++ 6.5.6.2 Generic clauses ---++++ 034.16: first paragraph in 6.5.6.2 on page 78 Generics provide a channel for information to be communicated to a block, a package, <font color="red"><strike>or</strike>, </font> a subprogram<font color="red">, or a protected type </font> from its environment. The following applies to external blocks defined by design entities, to internal blocks defined by block statements, and to packages <font color="red"><strike>and</strike>, </font> subprograms <font color="red">, and protected types</font>. ---++++ 034.17: third paragraph (BNF counts as a paragraph) in 6.5.6.2 on page 78 The generics of a block, a package, <font color="red"><strike>or</strike>, </font> a subprogram <font color="red">, or a protected type </font> are defined by a generic interface list. Each interface element in such a generic interface list declares a formal generic. ---++++ 034.18: P79 note on bottom of page in 6.5.6.2 NOTE-Generics may be used to control structural, dataflow, or behavioral characteristics of a block, a package, <font color="red"><strike>or</strike></font> a subprogram, <font color="red">or a protected type, </font> or may simply be used as documentation. In particular, generics may be used to specify the size of ports; the number of subcomponents within a block; the timing characteristics of a block; or even the physical characteristics of a design such as temperature, capacitance, or location. ---+++ 6.5.7 Association lists ---++++ 034.19: Third paragraph counting BNF as one paragraph in 6.5.7.1 page 81 Each association element in an association list associates one actual designator with the corresponding interface element in the interface list<font color="red">.<strike> of a subprogram declaration, component declaration, entity declaration, block statement, or package.</strike></font> The corresponding interface element is determined either by position or by name. ---+++ 6.5.7.2 Generic map aspects ---++++ 034.20: 1st paragraph in 6.5.7.2 on page 84 A generic map aspect, other than one appearing in an interface package generic map aspect (see 6.5.5), associates values, subtypes, subprograms, or instantiated packages with the formal generics of a block, a package, <font color="red"><strike>or</strike></font> a subprogram<font color="red">, or a protected type</font>. The following applies to external blocks defined by design entities, to internal blocks defined by block statements, and to packages<font color="red"><strike> and</strike></font>, subprograms<font color="red">, and a protected types</font>. ---++++ 034.21: 5th paragraph in 6.5.7.2 on page 84 <font color="green">[Add new list item as the last item in the list for the list that starts with]</font> The purpose of a generic map aspect is as follows:%BR% <font color="green">[5 other list items unmodified]</font> <font color="green">[Edit as follows if LCS_2016_14a is rejected]</font> <font color="red">- A generic map aspect appearing immediately within a protected type header associates actuals with the formals defined by the same protected type header. This applies to a generic map aspect appearing in a protected type header of an explicitly declared generic-mapped protected type, a generic-mapped protected type that is equivalent to a protected type instantiation declaration, or a generic-mapped protected type that is implicitly declared when the subtype indication of a variable declaration is an uninstantiated protected type and it has a generic map aspect.</font> <font color="green">[Edit as follows if LCS_2016_14a is accepted]</font> <font color="red">- A generic map aspect appearing immediately within a protected type header associates actuals with the formals defined by the same protected type header. This applies to a generic map aspect appearing in a protected type header of an explicitly declared generic-mapped protected type, a generic-mapped protected type that is equivalent to a protected type instantiation declaration, or a generic-mapped protected type that is implicitly declared when the subtype indication of a variable declaration, access type definition, or an allocator is an uninstantiated protected type and it has a generic map aspect.</font> ---++++ 034.22: Note 2 at the end of in 6.5.7.2 on page 85 NOTE 2-A local generic (from a component declaration) or formal generic (from a package, a subprogram, <font color="red"> a protected type,</font> a block statement<font color="red">,</font> or from the entity declaration of the enclosing design entity) may appear as an actual in a generic map aspect. ---+++ 12.2 Scope of declarations ---++++ 034.23: List item f f) A formal generic declaration in an entity declaration, an uninstantiated package declaration, <font color="red"><strike>or</strike></font> an uninstantiated subprogram declaration<font color="red">, or an uninstantiated protected type declaration</font> ---+++ 12.3 Visibility ---++++ 034.24: List item s on page 188 see also LCS2016_033 s) For a subprogram declared immediately within a given protected type declaration<font color="red">, other than in a protected type declaration that defines an uninstantiated protected type</font> : at the place of the suffix in a selected name whose prefix denotes an object of the protected type. ---++++ 034.25: New list item following list item t on page 188 continuing the count from LCS2016_028 <font color="red">x) For a formal generic declaration of a given protected type declaration: at the place of the formal part (before the compound delimiter =>) of a named association element of a corresponding generic map aspect.</font> ---++++ 034.26: paragraph 5 on Page 189 Two declarations that occur immediately within the same declarative region, other than the declarative region of a block implied by a component instantiation or the declarative region of a generic-mapped package or subprogram equivalent to a package instance or a subprogram instance, <font color="red">or a protected type instance,</font> shall not be homographs, unless exactly one of them is the implicit declaration of a predefined operation or is an implicit alias of such an implicit declaration. In such cases, a predefined operation or alias thereof is always hidden by the other homograph. Where hidden in this manner, an implicit declaration is hidden within the entire scope of the other declaration (regardless of which declaration occurs first); the implicit declaration is visible neither by selection nor directly. For a declarative region of a block implied by a component instantiation or the declarative region of a generic-mapped package or subprogram equivalent to a package instance or a subprogram instance, the rules of this paragraph are applied to the corresponding entity declaration, component declaration, uninstantiated package declaration, <font color="red"><strike>or</strike></font> uninstantiated subprogram declaration, <font color="red">or uninstantiated protected type,</font> as appropriate. ---+++ 14.3. Elaboration of a block, package, or subprogram header <font color="green">[034.27: Edit section title to add protected type]</font> 14.3. Elaboration of a block, package, <font color="red"><strike>or</strike></font> subprogram<font color="red">, or protected type</font> header ---++++ 14.3.1 General ---+++++ 034.28: first paragraph of 14.3.1 on pages 202 and 203 Elaboration of a block header consists of the elaboration of the generic clause, the generic map aspect, the port clause, and the port map aspect. Similarly, elaboration of a package header consists of the elaboration of the generic clause and the generic map aspect; <font color="red">elaboration of a protected type header consists of the elaboration of the generic clause and the generic map aspect;</font> and elaboration of a subprogram header consists of the elaboration of the generic clause equivalent to the generic list of the subprogram header and the generic map aspect. ---++++ 034.29: 14.4.2.3 Type declarations %red% and instantiations %ENDCOLOR% ---+++++ 034.30: 2nd from last paragraph on page 207 Elaboration of a protected type <font color="red"><strike>definition</strike> declaration, other than a uninstantiated protected type declaration,</font> consists of the elaboration, in the order given, of each of the declarations occurring immediately within the protected type definition. <font color="red">Elaboration of an uninstantiated protected type declaration simply establishes that the name by which the protected type may be referenced subsequently in protected type instantiation declarations.</font> Elaboration of a protected type body has no effect other than to establish that the body, from then on, can be used during the elaboration of objects of the given protected type. <font color="red"> Elaboration of a protected type instantiation declaration consists of elaboration of the equivalent generic-mapped protected type declaration, followed by elaboration of the corresponding equivalent generic-mapped protected type body (see 5.6.3). If the protected type instantiation declaration occurs immediately within an enclosing package declaration, elaboration of the equivalent generic-mapped protected type body occurs as part of elaboration of the body, whether explicit or implicit, of the enclosing package. Similarly, if the protected type instantiation declaration occurs immediately within an enclosing protected type declaration, elaboration of the equivalent generic-mapped protected type body occurs as part of elaboration of the protected type body. </font> ---++++ 14.4.2.5 Object declarations ---+++++ 034.31: 1st paragraph of 14.4.2.5 on page 208 The rules of this subclause apply only to explicitly declared objects (see 6.4.2.1) <font color="red">and an uninstantiated protected type with a corresponding generic map aspect</font>. Generic declarations, port declarations, and other interface declarations are elaborated as described in 14.3.2 through 14.3.5 and 14.6. ---+++++ 034.32: last paragraph of 14.4.2.5 before the notes on page 208 The elaboration of an object of a protected type <font color="red">other than an uninstantiated protected type</font> consists of the elaboration of the subtype indication, followed by creation of the object. <font color="red">The elaboration of an object of an uninstantiated protected type and its corresponding generic map aspect consists of the elaboration of the equivalent implicitly defined protected type instance, followed by elaboration of the variable whose type is the implicitly defined protected type instance.</font> Creation of the object consists of elaborating, in the order given, each of the declarative items in the protected type body. ---+++ Annex C Syntax Summary ---++++ 034.33: Updates to protected type declaration from section 5.6.2 <pre> protected_type_declaration ::= protected %RED%protected_type_header%ENDCOLOR% protected_type_declarative_part end protected [ protected_type_simple_name ] %RED%protected_type_header ::= [ generic_clause [ generic_map_aspect ; ] ]%ENDCOLOR%</pre> ---++++ 034.34: New syntax for protected type instantiation definition from section 5.6.4 <pre>%RED%protected_type_instantiation_definition ::= new uninstantiated_protected_type_name [ generic_map_aspect ] ;%ENDCOLOR%</pre> ---+++ 034.35: Updates to type definition from section 6.2 <pre> type_definition ::= scalar_type_definition | composite_type_definition | access_type_definition | file_type_definition | protected_type_definition %RED% | protected_type_instance_definition%ENDCOLOR%</pre> ---+++ 034.36: Updates to Variable declarations from section 6.4.2.4 <pre>variable_declaration ::= [ shared ] variable identifier_list : subtype_indication %RED%[ generic_map_aspect ]%ENDCOLOR% [ := expression ] ;</pre> ---+++ Annex I, Glossary ---++++ 034.37: Definition of Generic on page 567 generic: An interface declaration in the block header of a block statement, a component declaration, or an entity declaration, in the package header of a package declaration, <font color="red"><strike>or</strike></font> in the subprogram header of a subprogram specification<font color="red">, or in the protected type header of a protected type declaration</font>. Generics provide a channel for static information to be communicated to a block, a package, <font color="red"><strike>or</strike></font> a subprogram<font color="red">, or a protected type from its environment.</font> Unlike explicit declarations, however, the value or subtype denoted by a generic can be supplied externally, either in a component instantiation statement, in a configuration specification, <font color="red">in a variable declaration,</font> or in a package<font color="red">, <strike>or</strike></font> subprogram </strike></font>or a protected type instantiation declaration. (6.5.6.2) ---++++ 034.38: Add Glossary entries <font color="red"> B.--- generic-mapped protected type: A protected type declared by a protected type declaration containing a generic list and a generic map aspect. A generic-mapped protected type may be declared explicitly, or may be equivalent to a protected type instantiation. (ยง5.6.2) B.--- simple protected type: A protected type declared by a protected type declaration containing no generic list and no generic map aspect. (ยง5.6.2) B.--- uninstantiated protected type: A protected type declared by a protected type declaration containing a generic list and no generic map aspect. An uninstantiated protected type may be instantiated with a protected type instantiation declaration or in a variable declaration. (ยง5.6.2) </font> ---+++ Afterword Notes <font color="green">Author Comments: The current proposal only adds generics to protected types. This allows a simplified approach to dealing the generic map aspect by adding it to variable declaration. If generics are to be added to other types, such as records, this becomes a more complex problem. It would not be so bad if the already defined term subtype indication could be modified to accomodate a generic map aspect, however, a generic map aspect creates a new type, so this would not be appropriate. Hence, a new term, such as type indication would need to be introduced such as below:</font> <pre>%GREEN%type_indication ::= subtype_indication[ generic_map_aspect ]%ENDCOLOR%</pre> A generic type cannot currently be a simple protected type, however, a generic type could be an uninstantiated protected type. <br><br> </noautolink></sticky> </noautolink>
E
dit
|
A
ttach
|
P
rint version
|
H
istory
: r34
<
r33
<
r32
<
r31
<
r30
|
B
acklinks
|
V
iew topic
|
Ra
w
edit
|
M
ore topic actions
Topic revision: r34 - 2017-07-16 - 08:50:22 -
JimLewis
P1076
Log In
or
Register
P1076 Web
Create New Topic
Index
Search
Changes
Notifications
RSS Feed
Statistics
Preferences
Webs
Main
P1076
Ballots
LCS2016_080
P10761
P1647
P16661
P1685
P1734
P1735
P1778
P1800
P1801
Sandbox
TWiki
VIP
VerilogAMS
Copyright © 2008-2025 by the contributing authors. All material on this collaboration platform is the property of the contributing authors.
Ideas, requests, problems regarding TWiki?
Send feedback