(Fwd) BTF - BE64 - Realtional ops

From: Thomas Fitzpatrick (tfitz@cadence.com)
Date: Tue Apr 21 1998 - 13:06:04 PDT


Here's the other one:
X-Lines: 277
Content-Type: text/plain; charset="us-ascii"
Content-Length: 9024
X-Status: $$$$
X-UID: 0000000396
Status: RO

The proposal as indicated in Anders' html file from April 6 should be accepted
as is:

Proposal

Change the second table entry in Table 4-21 on page 22 to:

+-------------------------------+-------+------------------------------+
| i op j where op is | | operands are sized to |
| === !== == != && || > >= < <= | 1 bit | max(L(i),L(j)) |
+-------------------------------+-------+------------------------------+

Add the following paragraphs at the end of section 4.1.7 on page 33:

When both operands of a relational expression are signed intergral operands (an
integer, or a unsized, unbased integer) then the expression shall interpreted
as a comparison between signed values. When either operand of a relational
expression is a real operand then the other operand shall be converted to an
equivalent real value, and the expression shall interpreted as a comparison
between two real values. Otherwise the expression shall interpreted as a
comparison between unsigned values.

<p>Change the first sentence in paragraph 8 on page 7 to:
A plus or minus operator preceding the size constant is a unary plus or minus
operator.

--- Forwarded mail from "Anders Nordstrom" <andersn@nortel.ca>

Date: Sat, 11 Oct 97 18:46:08 EDT
From: "Anders Nordstrom" <andersn@nortel.ca>
To: 1364core@galaxy.nsc.com
Subject: BTF - BE64 - Realtional ops

Subject: BTF - BE64 - Realtional ops

Behavioral Task Force - Errata Submission

Assigned Errata Number: BE64
Errata Name (Description): Realtional ops
Section: 4.1.7 page 33
Date Submitted: 970814
Requestor: J. Bhasker

Status: Submitted (priority not yet assigned)

Errors found in the Verilog LRM (IEEE 1364-1995).

Details:

The Verilog LRM does not explain how relational ops are to be handled:
are they numeric comparisons or bit-by-bit comparisons?

Here is an example:

What is : -1 < -3'd2

LHS is -1 which is 32 bits ("11111...11")
RHS is "110"

RHS is then zero-filled to 32 bits (P1364, pg33, 2nd line from top).

Now if I do a numeric comparison, the answer is 1 (true; -1 is less
than 6)

If I do a bit-by-bit comparison (treat as unsigned values, left to
right), the answer is 0 (false: 2**32-1 is greater than 6).

My interpretation of P1364 was that for relational operators, we have to
do numeric comparison. (But apparently a major simulation vendor does
not agree).

Could anyone please comment on which one is correct?

Thanks,

<p>- J. Bhasker, Lucent Technologies, jbhasker@lucent.com

<p>jbhasker@bell-labs.com writes:
> Hi,
>
> The Verilog LRM does not explain how relational ops are to be handled:
> are they numeric comparisons or bit-by-bit comparisons?
>
> Here is an example:
>
> What is : -1 < -3'd2
>
> LHS is -1 which is 32 bits ("11111...11")
> RHS is "110"
        not correct.
>
> RHS is then zero-filled to 32 bits (P1364, pg33, 2nd line from top).

<p> -1 < -3'd2 is treated as:

        (LT (UMINUS (1)) (UMINUS (EXP32 2)))

where EXP32 expands it's argument to 32 bits, zero filling.

The key bit here is that the second UMINUS is an operator, not part of
a token, and that the sizing is done before any operators are
applied. (ref 4.1.3 and 4.4.1) [I now note that the second table entry
on page 44 is wrong, and directly contradicts the correct rule you
cite from 4.1.7, and another correct rule in 4.1.8 *sigh*]

Hence the final comparison is done between the bit patterns,

        0xffffffff and 0xfffffffe

        Now here is a bit that isn't called out very clearly in the
specification. 4.1.6 almost lays it out, but is missing a final
clarification. Since there is no rhs destination for the calculation
of (-1 < -3'd2), we can't use the rules in 4.1.6. However, it is the
case that given any signed operand (which -1 is) the relational
operators treat all their arguments as signed.

These patterns are therefor interpreted as signed numbers, and hence
since -1 is not less than -2, the answer is false.

> Now if I do a numeric comparison, the answer is 1 (true; -1 is less
> than 6)
>
> If I do a bit-by-bit comparison (treat as unsigned values, left to
> right), the answer is 0 (false: 2**32-1 is greater than 6).
>
> My interpretation of P1364 was that for relational operators, we have to
> do numeric comparison. (But apparently a major simulation vendor does
> not agree).
>
> Could anyone please comment on which one is correct?
>
> Thanks,
>
>
> - J. Bhasker, Lucent Technologies, jbhasker@lucent.com

        So, two problems:

        1) the second table entry on page 44 should read:
+-------------------------------+-------+------------------------------+
| i op j where op is | | operands are sized to |
| === !== == != && || > >= < <= | 1 bit | max(L(i),L(j)) |
+-------------------------------+-------+------------------------------+

        2) section 4.1.7 needs the following sentences added:

When either operand of a relational expression is a signed intergral
operand (an integer, or a unsized, unbased integer) then the
expression shall interpreted as a comparison between signed values.

When either operand of a relational expression is a real operand then
the other operand shall be converted to an equivalent real value, and
the expression shall interpreted as a comparison between two real
values.

- mac

<p><p>> 2) section 4.1.7 needs the following sentences added:
>
>When either operand of a relational expression is a signed intergral
>operand (an integer, or a unsized, unbased integer) then the
>expression shall interpreted as a comparison between signed values.
>
This hypothesis does not seem to support the following result from
vcs:

(-1 < 1) returns 1
(-1 < 1'b1) returns 0

In fact, it seems a signed comparison is performed iff BOTH operands
are signed integral objects.

Regards,
-Ambar

--
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Ambar Sarkar                          Email: ambar@viewlogic.com
Viewlogic Systems Inc., Marlboro      Phone: (508)879-2150      (H)
293, Boston Post Rd West, MA 01752           (800)456-VIEWx5493 (W)

<p><p>Ambar Sarkar writes: > > 2) section 4.1.7 needs the following sentences added: > > > >When either operand of a relational expression is a signed intergral > >operand (an integer, or a unsized, unbased integer) then the > >expression shall interpreted as a comparison between signed values. > > > This hypothesis does not seem to support the following result from > vcs: > > (-1 < 1) returns 1 > (-1 < 1'b1) returns 0 > > In fact, it seems a signed comparison is performed iff BOTH operands > are signed integral objects. > > Regards, > -Ambar > -- > ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ > Ambar Sarkar Email: ambar@viewlogic.com > Viewlogic Systems Inc., Marlboro Phone: (508)879-2150 (H) > 293, Boston Post Rd West, MA 01752 (800)456-VIEWx5493 (W)

I agree, and accept your admendment to my proposal.

Please have the proposal read:

2) section 4.1.7 needs the following sentences added:

When both operands of a relational expression are signed intergral operands (an integer, or a unsized, unbased integer) then the expression shall interpreted as a comparison between signed values.

When either operand of a relational expression is a real operand then the other operand shall be converted to an equivalent real value, and the expression shall interpreted as a comparison between two real values.

Otherwise the expression shall interpreted as a comparison between unsigned values.

-mac

<p>Mac wrote: > > The key bit here is that the second UMINUS is an operator, not part of > a token, and that the sizing is done before any operators are > applied.

Mac,

Thanks very much for your clarification with further clarification by Ambar (thanks to Amabar too).

The confusion was caused by the - (minus) sign in front of a sized number. The syntax on pgs 602-603 clearly says that the - in front of a sized number is a unary minus operator, but the 8th para on page 7 of LRM says that the - is a sign for the constant number, WHICH IS INCORRECT. ("A plus or a minus operator preceding the size constant is a sign for the constant number").

The LRM should be corrected.

- J. Bhasker, jbhasker@lucent.com

<p>+-----------------------------------------------------------------------+ | Anders Nordstrom | | Senior ASIC Designer | | | | Northern Telecom Ltd. Email: andersn@nortel.ca | | P.O. Box 3511 Station C Phone: 613-763-9186 | | Ottawa, Ontario K1Y 4H7 Fax: 613-763-2626 | +-----------------------------------------------------------------------+

<p><p>---End of forwarded mail from "Anders Nordstrom" <andersn@nortel.ca>

-- --------------- Tom Fitzpatrick

Senior Technical Marketing Manager Cadence Design Systems, Inc. Cycle Simulation Products 270 Billerica Rd. Logic Design and Verification Business Unit Chelmsford, MA 01824 x6438 (978)446-6438



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