IEEE 200X Fast Track Change Proposal ID: FT-03 Enhancement Summary: Support logic operators: Array with Bit returning Array Related issues: Similar to 1164 efforts Relevant LRM section: 7.2.1, 14.2 Summary: Define binary logical operators, AND, OR, NOR, NAND, XOR, and XNOR, in the case where one operand is BIT/BOOLEAN and the other operand is an array of BIT/BOOLEAN. The result should be an array where each element of the array operand has had the logical operated applied to and the scalar operand. This proposal is derived from proposal CP-003 from the P1164 working group. As a result, the following code would be legal: signal ASel, BSel : bit ; signal Y, A, B : bit_vector(7 downto 0) ; Y <= (A and ASel) or (B and BSel) ; The above code would imply the same as the following more verbose code: GenLoop : for i in A'range generate begin Y(i) <= (A(i) and ASel) or (B(i) and BSel) ; end generate ; Analysis: The important issue is what the index range of the result. There are three choices. 1. Same as the array operand. I believe this is the most straight forward solution. The resulting index is known to be valid and doesn't depend on operand ordering. It is consistent with the current vector logical operator result. They take the index constraint from the operands. 2. Same as the left operand range. This is the rule used for vector logical operators but if the left operand is a scalar, what is its index range? This would require definition of an index range on a scalar or defining these operators in terms of the vector logical operators. The scalar operand could be converted to an array in one of two ways A. Take the range for the other operand. B. Take the range from the length of the other operand and the direction and 'left from the other operand's array base type. If we choose A, then the result's index range is the same as choice 1. If we choose B, then the result's index matches choice 1 if the array operand is first, otherwise it match choice 3. 3. Use the index constrain on the array operand base type. This is the rule used for concatenation. This appears to be overkill. It is used for concatenation only because we need to insure the generation of a valid index range. But by definition, the array operand must have a valid index range, so why go through the trouble of generating a whole new range. Choice 1 is the best option. It is consistent with the current LRM and provides the intuitive result. Change to 1076-2002 Section 7.2.1 needs to have the first paragraph modified as follows The logical operators AND, OR, NAND, NOR, XOR, XNOR, and NOT are defined for predefined types BIT and BOOLEAN. They are also defined for any one-dimensional array type whose element type is BIT or BOOLEAN. In addition the binary logical operators AND, OR, NOR, XOR, and XNOR are defined for the case where one operand is of type BIT or BOOLEAN and the other operand is a one-dimensional array whose element type is the same as the other operand. For the operators AND, OR, NAND, NOR, XOR, and XNOR, the operands must either be the same base type or one operand must be a scalar subtype and the other operand a one-dimensional array whose element type is the same subtype. For the binary logical operators, if the both operands are one-dimensional array types, the operand must be arrays of the same length, the operation is performed on matching elements of the array, and the result is an array with the same index range as the left operand. If one operand to a binary logical operator is a scalar and the other operand is a one-dimensional array, the specified logical operation is performed on the scalar operand with each element of the array operand. The result is an array of the same base type and index constrain as the array 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. In section 14.2 add the following fucntion declarations to the section for type BIT_VECTOR function "and"( anonymous: BIT_VECTOR; anonymous : BIT ) return BIT_VECTOR; function "and"( anonymous: BIT; anonymous : BIT_VECTOR ) return BIT_VECTOR; function "or"( anonymous: BIT_VECTOR; anonymous : BIT ) return BIT_VECTOR; function "or"( anonymous: BIT; anonymous : BIT_VECTOR ) return BIT_VECTOR; function "nand"( anonymous: BIT_VECTOR; anonymous : BIT ) return BIT_VECTOR; function "nand"( anonymous: BIT; anonymous : BIT_VECTOR ) return BIT_VECTOR; function "nor"( anonymous: BIT_VECTOR; anonymous : BIT ) return BIT_VECTOR; function "nor"( anonymous: BIT; anonymous : BIT_VECTOR ) return BIT_VECTOR; function "xor"( anonymous: BIT_VECTOR; anonymous : BIT ) return BIT_VECTOR; function "xor"( anonymous: BIT; anonymous : BIT_VECTOR ) return BIT_VECTOR; function "xnor"( anonymous: BIT_VECTOR; anonymous : BIT ) return BIT_VECTOR; function "xnor"( anonymous: BIT; anonymous : BIT_VECTOR ) return BIT_VECTOR; Resolution: [To be determined by the P1164 Working Group]