.. _core-operators: Operators ========= Verilisp includes a wide range of mathematical and logical operators. In general these are the same as those in Lisp, and behave identically. Lisp operators -------------- +---------------+------------------------------+--------------------+ | Operator | Example | Notes | +===============+==============================+====================+ | ``+`` + ``(+ 1 2 a)`` + | +---------------+------------------------------+--------------------+ | ``-`` + ``(- 1 2 a)`` or ``(- 3)`` + Unary or n-ary | +---------------+------------------------------+--------------------+ | ``*`` + ``(* 1 2 a)`` + | +---------------+------------------------------+--------------------+ | ``mod`` + ``(mod 15 4)`` + | +---------------+------------------------------+--------------------+ | ``rem`` + ``(rem 12 a)`` + | +---------------+------------------------------+--------------------+ | ``logand`` + ``(logand a #16rFF)`` + | +---------------+------------------------------+--------------------+ | ``logior`` + ``(logior a b c)`` + | +---------------+------------------------------+--------------------+ | ``logxor`` + ``(logxor a #16rFF)`` + | +---------------+------------------------------+--------------------+ Verilisp-specific operators ------------------------- Bitwise shifts in Lisp use the ``ash`` ("arithmetic shift") function which shifts left or right depending on the sign of its second argument. We replace this with two explicit operators, left and right shifts, that take exactly two arguments. +---------------+------------------------------+--------------------+ | Operator | Example | Lisp equivalent | +===============+==============================+====================+ | ``<<`` + ``(<< a 5)`` + ``(ash a 5)`` | +---------------+------------------------------+--------------------+ | ``>>`` + ``(>> b 5)`` + ``(ash b -5)`` | +---------------+------------------------------+--------------------+