Usually, assign
statements are simple and straightforward. But suppose there is a complex one that has parenthesis and concatenation and a bunch of different operators; What is the exact order of evaluation priorities of the operators that come on the right side of an assign
statement?
There are a bunch of different operator types:
arithmetic
logical
relational
equality
bitwise
reduction
shift
concatenation
replication
conditional
In other words, if you were to convert an assign
statement into an always
block, what is the exact order of organizing the operations?
Answer
Thanks to @dave_59, based on IEEE's documentation, the priorities in descending order are:
Operator | Associativity |
---|---|
() , [] , :: , . |
Left |
+ , - , ! , ~ , & , ~& , | , ~| , ^ , ~^ , ^~ , ++ , -- (unary) |
|
** |
Left |
* , / , % |
Left |
+ , - (binary) |
Left |
<< , >> , <<< , >>> |
Left |
< , <= , > , >= , inside , dist |
Left |
== , != , === , !== , ==? , !=? |
Left |
& (binary) |
Left |
^ , ~^ , ^~ (binary) |
Left |
| (binary) |
Left |
&& |
Left |
|| |
Left |
?: (conditional operator) |
Right |
–> , <–> |
Right |
= , += , -= , *= , /= , %= , &= , ^= , \|= , <<= , >>= , <<<= , >>>= , := , :/ , <= |
None |
{} , {{}} |
Concatenation |