BACK

8.0 Operator

 

Operators perform an operation on one or two operands:

  • Unary expressions
    operator operand
  • Binary expressions
    operand operator operand
  • The operands may be either net or register data types.
  • Operands may be scalar, vector, or bit selects of a vector.
  • Operators which return a true/false result will return a 1-bit value where 1 is true, 0 is false, and X is indeterminate.

 

 

Usage

Description

Arithmetic Operators

+

m + n

Add n to m

-

m - n

Subtract n from m

-

-m

Negate m (2's complement)

*

m * n

Multiply m by n

/

m / n

Divide m by n

%

m % n

Modulus of m / n

Bitwise Operators

~

~m

Invert each bit of m

&

m & n

AND each bit of m with each bit of n

|

m | n

OR each bit of m with each bit of n

^

m ^ n

Exclusive OR each bit of m with n

~^
^~

m ~^ n
m ^~ n

Exclusive NOR each bit of m with n

Unary Reduction Operators

&

&m

AND all bits in m together (1-bit result)

~&

~&m

NAND all bits in m together (1-bit result)

|

|m

OR all bits in m together (1-bit result)

~|

~|m

NOR all bits in m together (1-bit result)

^

^m

Exclusive OR all bits in m (1-bit result)

~^
^~

~^m
^~m

Exclusive NOR all bits in m (1-bit result)

Logical Operators

!

!m

Is m not true? (1-bit True/False result)

&&

m && n

Are both m and n true? (1-bit True/False result)

||

m || n

Are either m or n true? (1-bit True/False result)

Equality Operators (compares logic values of 0 and 1

==

m == n

Is m equal to n? (1-bit True/False result)

!=

m != n

Is m not equal to n? (1-bit True/False result)

Identity Operators (compares logic values of 0, 1, X and Z

===

m === n

Is m identical to n? (1-bit True/False results)

!==

m !== n

Is m not identical to n? (1-bit True/False result)

Relational Operators

<

m < n

Is m less than n? (1-bit True/False result)

>

m > n

Is m greater than n? (1-bit True/False result)

<=

m <= n

Is m less than or equal to n? (True/False result)

>=

m >= n

Is m greater than or equal to n? (True/False result)

Logical Shift Operators

<<

m << n

Shift m left n-times

>>

m >> n

Shift m right n-times

Miscellaneous Operators

? :

sel?m:n

If sel is true, select m: else select n

{}

{m,n}

Concatenate m to n, creating larger vector

{{}}

{n{m}}

Replicate m n-times

->

-> m

Trigger an event on an event data type

 

Operator Precedence

  !     ~     +     - (unary)

  *     /     %

  +     - (binary)

  <<    >>

  <     <=    >    >=

  ==    !=   ===   !==

  &     ~&

  ^     ~^

  |     ~|

  &&

  ||

  ?:
 highest precedence






















 lowest precedence

 

 

TOP

 BACK