Microsoft Word - Digital Logic Design v_4_6a

(lily) #1

7.6. Operators


This section provides an overview of logical, relational, arithmetic and other operators. Note that this a
sampling of operation available and the reader is encouraged to explore Verilog reference manual online.


 Logical operators
The logical operators and, or and not as list here. They operate on two variables regardless if the
variables are one bit, scalar or array of bits.


Symbol Operation
! Negation
&& And
|| Or

The following function are bitwise operators and the operands must be one bit or array of bits.

Symbol Operation
& And
~ Negation
~& Nand
| Or
~| Nor
^ Xor
~^ Xnor
>> Right shift
<< Left shift

 Example – Bitwise Operator

(~4'b0001))  1110 // Bitwise Negation
(4'b0001 | 4'b1001))  1001 // Bitwise OR
(4'b0001 & 4'b1001))  0001 // Bitwise AND

 Relational operators
Relational operators are used to test the relative values of two scalar types. The result of a relational
operation is always a Boolean true (1) or false (0) value.


Symbol Operation
== Equality
!= Inequality
> Greater than
< Less than
>= Greater than or equal
<= Less than or equal

 Example – Relational Operators
3'b101 == 3'b110  0 // equal (==) operator
3'b101 != 3'b110  1 // not equal (!=) operator
4’b1001 < 4’b1010  1 // Less than (<) operator

 Arithmetic Operations
The Arithmetic operators are listed in this section

Free download pdf