1

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
M.H. Tajaddini
  • 776
  • 4
  • 20

1 Answers1

2

Section 11.3.2 Operator precedence of the IEEE 1800-2017 SystemVerilog LRM defines this in detail.

dave_59
  • 39,096
  • 3
  • 24
  • 63