Re: && and || operand sizing

From: Steven Sharp (sharp@cadence.com)
Date: Fri Jun 28 2002 - 10:51:32 PDT


Precedence: bulk

I got this same question from MTI a couple weeks ago (not via BTF).

>Table 29 on page 60 in section 4.4 on Expression bit lengths
>lists the logical operators (&& and ||) in the 5th row along
>with the comparison operators.
>
>The "Comments" column for this row states that the operands
>of these operators are resized to max(L(i), L(j)).
>
>Resizing the operands makes sense to me for the comparison
>operators. But, should the logical operators really be
>treated the same way, or should their operands actually be
>self-determined?

They should be self-determined. Compares need their operands
resized to the same width before being compared. The operands
of the logical operators are both reduced to 1 bit before
being combined, so there is no reason they need to be the same
size.

The 1995 standard failed to specify that the operands of a compare
needed to be resized. When that was fixed for 2001, the logical
operators got included by mistake because they were on the same
line in the table. The change was not an attempt to change the
behavior, but to correct the standard to match the existing
behavior.

The existing behavior has the operands of && and || completely
self-determined, as you found by experiment.

>For example:
>
>+-----------------------------+------------+--------------------------+
>| Expression | Bit Length | Comments |
>+-----------------------------+------------+--------------------------+
>| i op j, where op is | 1 | operands are sized to |
>| == != === !== < <= > >= | | max(L(i), L(j) |
>+-----------------------------+------------+--------------------------+
>| i op j, where op is | 1 | i, j are self-determined |
>| && || | | |
>+-----------------------------+------------+--------------------------+

Yes, that would be correct. Or move it down into the row with the reduction
operators, since they say that "All operands are self-determined", which
covers binary operators as well as the unary ones.

Somebody add this to the errata list for the ETF.

Steven Sharp
sharp@cadence.com



This archive was generated by hypermail 2.1.4 : Mon Jul 08 2002 - 12:55:39 PDT and
sponsored by Boyd Technology, Inc.