VHDL Issue Number 0103 Classification: Language Definition Problem Language Version: VHDL-87 Summary: The LENGTH attribute is ill-defined. Related Issues: 0102 Relevant LRM Sections: 14.1 Key Words and Phrases: LENGTH attribute, Pre-defined attributes. Current Status: ISAC-Approved 1076-1993 Disposition: Closed (All Issues Completely Addressed) Disposition Rationale: LRM is clear now. Superseded By: N/A ----------------------- Date Submitted: 1988/05/25 Author of Submission: Paul Menchini Author's Affiliation: CAD Language Systems, Inc. Author's Post Address: P.O. Box 13036 Research Triangle Park, NC 27709-3036 Author's Phone Number: (919) 361-1913 Author's Fax Number: Author's Net Address: mench@clsi.com ----------------------- Date Analyzed: 1990/10/02 Author of Analysis: Clive R. Charlwood Revision Number: $Revision: 1.9 $ Date Last Revised: $Date: 1995/05/13 19:34:42 $ Description of Problem ---------------------- The specification of the result of the evaluation of LENGTH attribute (LRM page 14-5) is incorrect. The result is specified as "A'HIGH(N) - A'LOW(N) + 1", which is evaluable only if the Nth index subtype of A is an integer type or subtype. Note that the type of the result expression must then be converted to universal integer. Conversely, if the Nth index subtype is an enumerated type, this computation fails. Note further that this computation fails if the Nth index subtype denotes a null range. Proposed Resolution ------------------- These problems can all be solved by stating the result as "(T'POS(A'HIGH(N)) - T'POS(A'LOW(N)) + 1) max 0", where T is the type or subtype of the Nth index of A. VASG-ISAC Analysis & Rationale ------------------------------ This is a valid problem. The proposed solution seems reasonable. However, the term "max 0" is not well defined. Therefore the equation should be written in two parts. The first covering the case where the Nth index subtype denotes a null range. The second covering the case where the Nth index subtype denotes a non-null range. VASG-ISAC Recommendation for IEEE Std 1076-1987 ----------------------------------------------- Read the paragraph on page 14-5 of the LRM as: Result: The number of values in the Nth index range, i.e., If the Nth index subtype denotes a null range then the value is 0. Otherwise, the value is given by the equation "T'POS(A'HIGH(N)) - T'POS(A'LOW(N)) + 1", where T is the type or subtype of the Nth index of A. VASG-ISAC Recommendation for Future Revisions --------------------------------------------- Re-write the paragraph on page 14-5 of the LRM as: Result: The number of values in the Nth index range, i.e., If the Nth index subtype denotes a null range then the value is 0. Otherwise, the value is given by the equation "T'POS(A'HIGH(N)) - T'POS(A'LOW(N)) + 1", where T is the type or subtype of the Nth index of A.