-------------BEGINNING OF IR---------------- VHDL Issue Number: 2093 Language_Version VHDL-2002 Classification Language Definition Problem Summary Static type conversions and qualified expressions Relevant_LRM_Sections 7.4 Static expressions, 7.3.5 Type conversions, 7.3.4 Qualified expressions Related_Issues Key_Words_and_Phrases static expression, type conversion, qualified expression Authors_Name Peter Ashenden Authors_Phone_Number +61 414 709 106 Authors_Fax_Number Authors_Email_Address peter@ashenden.com.au Authors_Affiliation Ashenden Designs Authors_Address1 Authors_Address2 Authors_Address3 Current Status: VASG-Approved Superseded By: ------------------------ Date Submitted: 24 April 2006 Date Analyzed: 04 May 2006 Author of Analysis: Chuck Swart Revision Number: 4 Date Last Revised: 24 August 2006 Description of Problem ---------------------- The conditions for a type conversion to be locally static or globally static may not be sufficient. In 7.4.1, a type conversion is a locally static primary if its operand is a locally static expression. Similarly, in 7.4.2, a type conversion is a globally static primary if its operand is a globally static expression. The rules for type conversions in 7.3.5 state that if the type mark denotes a constrained array type, the bounds of the result are those of the type mark. The result of such a type conversion can only be locally static (respectively, globally static) if the subtype denoted by the type mark has locally static (respectively, globally static) index ranges. If, for example, the bounds are determined by generics, the subtype is only globally static, and the bounds of the result of the type conversion cannot be determined at analysis time, even if the expression in the type conversion is locally static. Similarly, if the bounds are determined by parameters, the subtype is not even globally static, and the bounds of the result of the type conversion cannot be determined at elaboration time, even if the expression in the type conversion is globally static. Also, if the type mark denotes an unconstrained array type, there is a check that the converted array bounds belong to the index subtype of the array type. To ensure that that subtype check succeeds for a locally static (respectively, globally static) expression, the index subtype must be locally static (respectively, globally static). Further, for both unconstrained and constrained types, there is a check that any constraint on the element subtype is the same for both the operand and the target type. Again, to ensure that that subtype check succeeds for a locally static (respectively, globally static) expression, the element subtype must be locally static (respectively, globally static). A similar problem will exist in VHDL-2006 for qualified expressions when we change them to do a subtype conversion rather than a subtype check. (See LCS-2006-114, FT-26.) Proposed Resolution ------------------- Change the rule for a type conversion being locally static to require that the type mark denote a locally static subtype. Change the rule for a type conversion being globally static to require that the type mark denote a globally static subtype. Suggest to the Accellera LRM-SC that similar changes be made to the rules for qualified expressions being locally and globally static. VASG-ISAC Analysis & Rationale ------------------------------ The VHDL 1987 LRM states that a globally static qualified expression is one "whose type mark denotes a globally static subtype and whose operand is a globally static expression." This was changed in VHDL 1993 for reasons which are not completely clear. The current opinion is that for an expression to be locally static, both its value and it subtype (if applicable) must be globally static. So the submitter is correct, and appropriate LRM changes should be made. There was some consideration about extending the definition of locally static array types to include unconstrained array types. It was determined that to do so would require significant changes to to the wording of case statements and perhaps to other areas, so this idea was rejected. However, the definition of locally static (and globally static) declared constants should be revised to accommodate, in effect, locally static unconstrained array subtypes. The proposed changes are developed either from VHDL 1987 or from Ada 95. Note: Issues of staticness and formal generic types have not been addressed. VASG-ISAC Recommendation for IEEE Std 1076-2002 ----------------------------------------------- No change. There may be some subtle but uncommon compatibility issues. VASG-ISAC Recommendation for Future Revisions --------------------------------------------- Make the following LRM changes: 7.4.1 Locally static primaries "An expression is said to be locally static if and only if... b) A constant (other than a deferred constant) explicitly declared by a constant declaration with a locally static subtype or with an unconstrained array subtype whose index subtypes and element subtype are locally static and initialized with a locally static expression; ... h) A qualified expression whose type mark denotes a locally static subtype and whose operand is a locally static expression; i) A type conversion whose type mark denotes a locally static subtype and whose expression is a locally static expression; ... 7.4.2 Globally static primaries "An expression is said to be globally static if and only if ... e) A constant (including a deferred constant) explicitly declared by a constant declaration with a globally static subtype or with an unconstrained array subtype whose index subtypes and element subtype are globally static; m) A qualified expression whose type mark denotes a globally static subtype and whose expression is a globally static expression; n) A type conversion whose type mark denotes a globally static subtype and whose expression is a globally static expression; ... -------------END OF IR----------------