Differences
This shows you the differences between two versions of the page.
Both sides previous revision Previous revision Next revision | Previous revision | ||
language:expressions [2023/09/07 10:03] rajit [Expressions] |
language:expressions [2024/03/20 07:19] (current) rajit [External circuit functions] |
||
---|---|---|---|
Line 19: | Line 19: | ||
* '' | * '' | ||
+ | Syntactic replication is also supported for the operators ''&'', | ||
+ | <code act> | ||
+ | (+ i : 3 : p[i] + 2*i) | ||
+ | </ | ||
+ | and is equivalent to | ||
+ | <code act> | ||
+ | p[0] + 2*0 + p[1] + 2*1 + p[2] + 2*2 | ||
+ | </ | ||
===== Parameters and constant expressions ===== | ===== Parameters and constant expressions ===== | ||
Line 65: | Line 73: | ||
* left shift ''<<'' | * left shift ''<<'' | ||
* For concatenation, | * For concatenation, | ||
+ | |||
+ | While these bit-width rules are nice because you never lose bits, they can have some unexpected consequences. One of the not-so-nice effects of these rules is that, technically, | ||
+ | |||
+ | <code act> | ||
+ | int< | ||
+ | int< | ||
+ | int< | ||
+ | ... | ||
+ | chp { | ||
+ | ... | ||
+ | x := (a + b) + c; | ||
+ | y := a + (b + c); | ||
+ | ... | ||
+ | } | ||
+ | </ | ||
+ | |||
+ | Applying the bit-width rules, the expression '' | ||
+ | |||
+ | Another strange example is: | ||
+ | |||
+ | <code act> | ||
+ | ... | ||
+ | chp { | ||
+ | ... | ||
+ | x := x - 1; | ||
+ | y := y + (-1); | ||
+ | ... | ||
+ | } | ||
+ | </ | ||
+ | |||
+ | Now the right hand side of the first assignment takes '' | ||
+ | |||
===== Functions ===== | ===== Functions ===== | ||
Line 208: | Line 248: | ||
An example of file I/O implemented with external functions can be found in the '' | An example of file I/O implemented with external functions can be found in the '' | ||
+ | |||
+ | ===== Operator Precedence ===== | ||
+ | |||
+ | The operators have the following precedence, from the highest to lowest: | ||
+ | - '' | ||
+ | - '' | ||
+ | - '' | ||
+ | - ''<<'', | ||
+ | - ''&'' | ||
+ | - '' | ||
+ | - '' | ||
+ | - ''?'' | ||