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

Chapter 8: Operators

OVERVIEW

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.

BINARY 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.

Table 8-1: Arithmetic 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.

Table 8-2: Bit-wise Operators

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...

UNLIMITED FREE
ACCESS
TO THE WORLD'S BEST IDEAS

SUBMIT
Already a GlobalSpec user? Log in.

This is embarrasing...

An error occurred while processing the form. Please try again in a few minutes.

Customize Your GlobalSpec Experience

Category: Arithmetic Logic Units (ALU)
Finish!
Privacy Policy

This is embarrasing...

An error occurred while processing the form. Please try again in a few minutes.