RE: Assignment statement versus assignment operator


Subject: RE: Assignment statement versus assignment operator
From: David Smith (david_smith@avanticorp.com)
Date: Wed Aug 01 2001 - 13:17:19 PDT


Hi Peter,
Do you agree that according to the associativity rules this is not required? As far as I can see, with the definition of the assignment operator always required to be in parentheses when the result is used then the associativity is not required to be right associative (in other words the associativity is not used).

Not trying to belabor this issue. It is not clear what you intend. The comment that is made on page 21 needs to be expanded to make it obvious (as we discussed in the last meeting).

Thanks
David

-----Original Message-----
From: Peter Flake [mailto:flake@co-design.com]
Sent: Wednesday, August 01, 2001 1:02 PM
To: David Smith
Cc: vlog-pp@eda.org
Subject: Re: Assignment statement versus assignment operator

By 'such an assignment' I meant 'any assignment that is an expression'

Consequently in
a = (b = c = a+=1)
as there are 3 assignments that are expressions, this would have to be written
a = (b = (c = (a+=1)))

The data type and size of such an expression corresponds to the LHS, so
a+=1 has the data type and size of a.

Peter.

At 08:57 AM 8/1/01 -0700, David Smith wrote:
>I would like to follow up on a discussion we had at the last meeting. The
>question was raised about the behavior of the assignment group of
>operators, how they were used, and the meaning of being right or left
>associative.
>
>The example on page 21 of SUPERLOG_ESS_3.doc is:
>
> if ((a-b)) b = (a+=1)
>
>The previous statement is:
>
>"Note that such an assignment must be enclosed in parenthesis to avoid
>common mistakes such as a=b for a==b or a|=b for a!=b."
>
> From this we concluded that:
>
> a = b = a+=1
>
>is not a legal Verilog. The analysis is based on the difference between
>the "assignment statement" (which is NOT an operator and therefore does
>not have associativity rules) and the "assignment operator" (which is
>right associative within the new specification).
>
>The need for the parenthesis, as stated above, is not based on the ability
>to parse the language but on the desire to disambiguate the assignment
>operator and the the logical comparison operators. This is clearly true
>for the use within the condition of an selection or iteration statement.
>It is less clear of the reason for the use of the parenthesis for the
>assignment statement. I believe we need to make a clearer statement for
>this case.
>
>The question of whether the following is legal was not discussed.
>
> a = (b = c = a+=1)
>
>Based on the description in the document, the specification that the
>assignment operator is right associative, and the discussion on page 21 I
>would conclude that it is. This is due to the ambiguity in the quote
>above. So, is this a legal use or is the quote above meant to indicate
>that whenever the result of an assignment operator is used it must be
>placed within parenthesis? If so, why?
>
>David
>
>David W. Smith
>Architect
>
> > Avant! Corporation
>9205 SW Gemini Drive
>Beaverton, OR 97008
>
>Voice: 503.520.2715
>FAX: 503.643.3361
>Email: david_smith@avanticorp.com
>http://www.avanticorp.com



This archive was generated by hypermail 2b28 : Wed Aug 01 2001 - 13:18:52 PDT