Professional Documents
Culture Documents
Chapter 8
Verilog Operators
2
Arithmetic Operators (cont.)
3
Relational Operators
4
Relational Operators (cont.)
5
Equality Operators
• There are two types of Equality operators. Case Equality
and Logical Equality.
Operands are compared bit by bit, with zero filling if the two operands
do not have the same length.
Result is 0 (false) or 1 (true).
For the == and != operators, the result is x, if either operand contains
an x or a z
For the === and !== operators, bits with x and z are included in the
comparison and must match for the result to be true. The result of
these operators is always a known value, either 1 or 0.
6
Equality Operators (cont.)
7
Logical Operators
8
Logical Operators (cont.)
9
Bit-wise Operators
• Bitwise operators perform a bit wise operation on two
operands. They take each bit in one operand and perform
the operation with the corresponding bit in the other
operand. If one operand is shorter than the other, it will be
extended on the left side with zeroes to match the length
of the longer operand.
10
Bit-wise Operators (cont.)
• Computations include unknown bits, in the
following way:
~x = x
0&x = 0
1&x = x&x = x
1|x = 1
0|x = x|x = x
0^x = 1^x = x^x = x
0^~x = 1^~x = x^~x = x
• When operands are of unequal bit length, the
shorter operand is zero-filled in the most
significant bit positions.
11
Bit-wise Operators (cont.)
12
Reduction Operators
14
Shift Operators
15
Shift Operators (cont.)
16
Concatenation Operator
17
Concatenation Operator (cont.)
{4'b1001,4'b10x1} = 100110x1
18
Replication Operator
19
Replication Operator (cont.)
{4{4'b1001}} = 1001100110011001
{4{4'b1001,1'bz}} = 1001z1001z1001z1001z
20
Conditional Operators
21
Conditional Operators (cont.)
22
Operator Precedence
23
The End