IEEE 200X Fast Track Change Proposal ID: FT-02 Enhancement Summary: Unary reduction operators Related issues: Similar to 1164 and 1076.3 efforts Relevant LRM section: 7.1, 7.2, 7.2.2 Enhancement Detail: Same as for 1164, except using standard operators (and, or, xor, xnor, nand, nor) rather than a form that requires "_reduce". The 1164 proposal follows ---------------------------- IEEE P1164 Working Group - Change Proposal ID: CP-006 Proposer: Jim Lewis Status: Proposed (1-Jun-2001) Analyzed (17-Nov-2002) To be resolved Summary: Add logical reduction operations/operators Detail: I would like to see reduction operators added to the package. If 200X is seriously going to add this to the language, I guess it may be worth waiting. However, as one who likes code clarity, I do not see the advantage of the language adding an operator. Consider if you use a reduction operator in an expression: Is this more readable (not built in) Parity <= xorr (Data) and ParityEnable ; or this (built in) Parity <= (xorr Data) and ParityEnable ; ---------------------------- Analysis: John Ries ---------------------------- Summary: Add the following unary reduction operators: AND, OR, NOR, NAND, XOR, and XNOR. Give these operators the same precedence as the miscellaneous_operators **, ABS, and NOT. Define these operators for all types that are one-dimensional arrays types whose elements have the binary operators AND, OR, and XOR, along with the unary operator NOT. Detail: To section 7.1 for the production of factor, change to factor ::= primary [ ** primary ] | ABS primary | AND primary | NAND primary | NOR primary | NOT primary | OR primary | XNOR primary | XOR primary In section 7.2 add to the definition of miscellaneous_operator miscellaneous_operator ::= ** | ABS | AND | NAND | NOR | NOT | OR | XNOR | XOR Change the first paragraph of section 7.2.1 to: The binary logical operators AND, OR, NAND, NOR, XOR, and XNOR, along with the unary NOT are defined for the predefined types BIT and BOOLEAN. They are also defined for any one-dimensional array type whose element is BIT or BOOLEAN. For the binary operators AND, OR, NAND, NOR, XOR, and XNOR, the operands must be of the same base type. Moreover, for the binary operators AND, OR, NAND, NOR, XOR, and XNOR defined on one-dimensional array types, the operands must be arrays of the same length, the operation is performed on matching elements of the arrays, and the result is an array with the same index range as the left operand. For the unary operator NOT defined on one-dimensional array types, the operation is performed on each element of the operand, and the result is an array with the same index range as the operand. The result type for the binary logical operators and NOT are the same as the base type of the operands. Add to the end of section 7.2.1: The unary forms of AND, NAND, NOR, OR, XOR, and XNOR are referred to as logical reduction operators. The logical reduction operators are predefined for any one-dimensional array type whose element type is BIT or BOOLEAN. The logical recduction operands have only one operand and their result type is the same as the element type of the operand. The individual logical reduction operators are defined as follows: - AND If the operand is a null array the return value is TRUE if the result is BOOLEAN, '1' if it is BIT. If the array contains one element only, return that element's value. For arrays of two or more elements, apply the binary logical AND operator to the two left most elements. Take that result and apply the binary AND to it and the next left-most element. Repeat until the right-most element is processes. Return the final result value. - OR If the operand is a null array the return value is FALSE if the result is BOOLEAN, '0' if it is BIT. If the array contains one element only, return that element's value. For arrays of two or more elements, apply the binary logical OR operator to the two left most elements. Take that result and apply the binary OR to it and the next left-most element. Repeat until the right-most element is processes. Return the final result value. - XOR If the operand is a null array the return value is FALSE if the result is BOOLEAN, '0' if it is BIT. If the array contains one element only, return that element's value. For arrays of two or more elements, apply the binary logical XOR operator to the two left most elements. Take that result and apply the binary XOR to it and the next left-most element. Repeat until the right-most element is processes. Return the final result value. - NAND Compute the unary AND of the operand and apply the array element type's NOT operator to compute the resulting value. - NOR Compute the unary OR of the operand and apply the array element type's NOT operator to compute the resulting value. - XNOR Compute the unary XOR of the operand and apply the array element type's NOT operator to compute the resulting value. Add the following note to the end of section 7.2.1 Note: Logical reduction operators use the array element type's logical operator AND, OR, XOR, and NOT. These operators maybe implicit or explicit, but must be declared and visible before the array type is declared. In section 14.2 add the following function declarations to the section for type BIT_VECTOR. function "and" ( anonymous: BIT_VECTOR) return BIT; function "or" ( anonymous: BIT_VECTOR) return BIT; function "nand" ( anonymous: BIT_VECTOR) return BIT; function "nor" ( anonymous: BIT_VECTOR) return BIT; function "xor" ( anonymous: BIT_VECTOR) return BIT; function "xnor" ( anonymous: BIT_VECTOR) return BIT; Resolution: ---------------------------- [To be performed by the 200X Fast Track Working Group]