Verilog Quickstart: A Practical Guide to Simulation and Synthesis in Verilog, 3rd Edition

Operators in Verilog can be divided into several categories. One way to categorize the operators is by the number of operands they take. For example, the + symbol takes two operands, as in a + b. When an operator takes two operands, it is called a binary operator. Verilog, like most programming languages, has many binary operators. Verilog also includes unary operators (which take only one operand), and a ternary operator (which takes three operands).
Another way to group the operators is by the size of what they return. Some operators, when operating on vectors, return a vector. But two types of operators return a single-bit value even if they are passed vectors. The operators that return only a single bit are either reduction or logical operators.
Most of the operators in Verilog take two operands, and fall into the category ot binary operators. This includes a set of arithmetic, bit-wise, and logical operators.
| Symbol | Description |
|---|---|
| + | Addition |
| ? | Subtraction |
| * | Multiplication |
| / | Division |
| % | Modulus (remainder) |
| ** | Power (exponent) New in IEEE1364-2001 |
The definitions of the arithmetic operators are similar to other programming languages. IEEE 1364-2001 adds the power operator that was previously not part of Verilog.
| Symbol | Description |
|---|---|
|
| OR |
| & | AND |
| ? | Exclusive OR |
| << | Shift left |
| <<< | Signed shift left New in IEEE1364-2001 |
| >> | Shift right |
| >>> | Signed shift right New in IEEE1364-2001 |
The bit-wise I, &, and ? operators...