Re: [sv-bc] RE: associativity of ** operator

From: Steven Sharp <sharp_at_.....>
Date: Mon Oct 26 2009 - 23:19:01 PDT
>From: "Bresticker, Shalom" <shalom.bresticker@intel.com>

>I also don't see why you think that with left-to-right associativity it becomes 
equivalent to * except for the left-most operator. If that were the case, then 
2**3**2 would give you (2**3)*2 = 16, not 64.

He means that (2**3)**2 is equivalent to 2**(3*2).  If you left-associate
your exponentiation, you get the same result as multiplying all of the
exponents and then exponentiating once.

I believe that other languages like FORTRAN right-associate exponentiation,
and that one reason is that if you meant to left-associate, you could have
just used multiplication.  That still takes one set of parentheses, but
forcing right-association with a left-associative convention takes a set
of parentheses for each exponent.  I might have brought this up back when
exponentiation was added to Verilog.



>In these programming languages, it is a matter of definition.
>
>In any case, changing the associativity now would cause a problem of backwards 
compatibility, which is the main reason it won't be changed in SystemVerilog 
(There won't be any more 1364 as it has been merged into SystemVerilog.).


Since Verilog-AMS probably took its conventions from SPICE, which probably
took them from FORTRAN, it probably right-associates.  So this would be
an incompatibility between the languages.


Steven Sharp
sharp@cadence.com


-- 
This message has been scanned for viruses and
dangerous content by MailScanner, and is
believed to be clean.
Received on Mon Oct 26 23:21:34 2009

This archive was generated by hypermail 2.1.8 : Mon Oct 26 2009 - 23:25:23 PDT