0% found this document useful (0 votes)
12 views

Lectures

Uploaded by

hshdue29
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
12 views

Lectures

Uploaded by

hshdue29
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 11

University of Anbar Subject / Digital TechniquesI

College of Engineering Second Stage / 1st Semester


Dept. of Electrical Engineering (2021 – 2022);lecture 3
‫ـــــــــــــــــــــــــــــــــــــــــــــــــــــــــــــــــــــــــــــــــــــــــــــــــــــــــــــــــــــــــــــــــــــــــــــــــــــــــــــــــــــــــــــــــــــــــــــــــــــــــــــ‬
Addition of Hexadecimal Numbers:
Hex numbers are used extensively in machine-language computer
programming and in conjunction with computer memories. When working in these
areas, there will be situations where hex numbers have to be added or subtracted.
The addition can be done in the same manner as decimal addition. Let’s add the
hex numbers 58 and 24, 58 and 4B.

58 3AF 58
+ 24 + 23C + 4B
7C 5EB 93

Examples: add the following hexadecimal numbers.


(a) 23(16)+16(16) (b) 58(16)+22(16) (c) DF(16)+AC(16)

23 right column: 3(16)+6(16) = 3(10)+6(10) = 9(10) = 9(16)


+ 16 left column: 2(16)+1(16) = 2(10)+1(10) = 3(10) = 3(16)
39

58 right column: 8(16)+2(16) = 8(10)+2(10) = 10(10) = A(16)


+ 22 left column: 5(16)+2(16) = 5(10)+2(10) = 7(10) = 7(16)
7A

DF right column: F(16)+C(16) = 15(10)+12(10) = 27(10)


= 27(10)-16(10) = 11(10) = B(16) with a carry of 1
+ AC left column: D(16)+A(16)+1(16)= 13(10)+10(10) +1(10)= 24(10)
18B = 24(10)-16(10) = 8(10) = 8(16) with a carry of 1

Subtraction of Hexadecimal Numbers (Using Direct Method):


Reverse operation of addition may be used as a direct way to subtract
hexadecimal numbers as shown in the following examples:
D3A right column: A(16 )- 4(16) = 10(10) - 4(10) = 6(10) = 6(16)
- F4 middle column: 3(16) - F(16)= 3(10) - 15(10) (need borrow)
C46 = 19(10) - 15(10)= 4(10) =4(16)
left column: D(16) - 1(16) = C(16)

84 right column : 4(16 )- A(16) = 4(10) - 10(10) (need borrow)


- 2A = 20(10) - 10(10)= 10(10) =A(16)
5A left column : 8(16) - 2(16) - 1(16)= 5(16) 1
University of Anbar Subject / Digital TechniquesI
College of Engineering Second Stage / 1st Semester
Dept. of Electrical Engineering (2021 – 2022);lecture 3
‫ـــــــــــــــــــــــــــــــــــــــــــــــــــــــــــــــــــــــــــــــــــــــــــــــــــــــــــــــــــــــــــــــــــــــــــــــــــــــــــــــــــــــــــــــــــــــــــــــــــــــــــــ‬
Subtraction of Hexadecimal Numbers (Using Complement Method):

Remember that hex numbers are just an efficient way to represent binary
numbers. Thus we can subtract hex numbers using the same method we used for
binary numbers. In order to find the complement of hex numbers, two ways are
found
 first way: 7 3 A hex number
0111 0011 1010 convert to binary
1000 1100 0101 1’s complement representation
1000 1100 0110 2’s complement representation
8 C 6 conversion back to hex

 Second way: this procedure is quicker, subtract each hex digit from F, and
then add 1. let’s try this for the same hex number from the example above:

F F F
-7 -3 -A Subtract each digit from F
8 C 5
+1 adding 1
8 C 6 hex. Equivalent of 2’s comp.

Example: subtract 3A5(16) from 592(16).


First, covert 3A5 to its 2’s complement form by using either method presented
above. The result is C5B. Then add this to 592.

592
Discarded + C5B
carry 1 1ED

2
University of Anbar Subject / Digital TechniquesI
College of Engineering Second Stage / 1st Semester
Dept. of Electrical Engineering (2021 – 2022);lecture 3
‫ـــــــــــــــــــــــــــــــــــــــــــــــــــــــــــــــــــــــــــــــــــــــــــــــــــــــــــــــــــــــــــــــــــــــــــــــــــــــــــــــــــــــــــــــــــــــــــــــــــــــــــــ‬
Example: subtract the following hexadecimal numbers:
(a) 84 – 2A (b) C3 – 0B

For branch (a): the 2’s complement of 2A = D6


84
+ D6
Drop carry 1 5A the difference is 5A(16)

For branch (b): the 2’s complement of 0B = F5

C3
+ F5
Drop carry 1 B8 the difference is B8(16)

Multiplication of Hexadecimal Numbers:

The multiplication of hex numbers is well illustrated in the following example:

3A right column : A(16 ) × F(16) = 10(10) × 15(10) =150(10) = 96(16)


× F = 6 with carry 9
366 left column : 3(16) × F(16) + 9(16)= 3(10) × 15(10) + 9(10) = 45(10) + 9(10) = 54(10)
=36(16)
1- Inverter (NOT Gate):
The inverter performs the operation called inversion or complementation.
The purpose of the inverter is to change the one logic level to the opposite level. In
terms of bits, it changes a 1 to 0 and a 0 to a 1.

Inverter Truth Table

Input ( A ) Logic Symbol


Output ( A )
0 1
A A
1 0

3
University of Anbar Subject / Digital TechniquesI
College of Engineering Second Stage / 1st Semester
Dept. of Electrical Engineering (2021 – 2022);lecture 3
‫ـــــــــــــــــــــــــــــــــــــــــــــــــــــــــــــــــــــــــــــــــــــــــــــــــــــــــــــــــــــــــــــــــــــــــــــــــــــــــــــــــــــــــــــــــــــــــــــــــــــــــــــ‬
2- AND Gate:
The AND Gate is one of the basic gates from which all logic functions are
constructed. An AND gate can have two or more inputs and performs what is
known as logical multiplication. Figure below, all possible logic levels for a 2-
input AND gate.

AND Gate Truth Table

Inputs Output
Logic Symbol
A B X
0 0 0 A
X
0 1 0 B
1 0 0
1 1 1

The total number of possible combinations of binary inputs to a gate is


determined by the following formula:
N = 2n
Where N is the total possible combinations and n is the number of input variables.
To illustrate,
For two input variables: N=22 =4
For three input variables: N=23 =8
For four input variables: N=24 =16

4
University of Anbar Subject / Digital TechniquesI
College of Engineering Second Stage / 1st Semester
Dept. of Electrical Engineering (2021 – 2022);lecture 3
‫ـــــــــــــــــــــــــــــــــــــــــــــــــــــــــــــــــــــــــــــــــــــــــــــــــــــــــــــــــــــــــــــــــــــــــــــــــــــــــــــــــــــــــــــــــــــــــــــــــــــــــــــ‬
3- OR Gate:
The OR gate is one of the basic gates from which all logic functions are
constructed. An OR gate can have two or more inputs and performs what is know
as logical addition. Figure below, all possible logic levels for a 2-input OR gate.
OR Gate Truth Table

Inputs Output
Logic Symbol
A B X
0 0 0 A
X
0 1 1 B
1 0 1
1 1 1

4- NAND Gate:
The NAND gate is a popular logic element because it can be used as a
universal gate; that is; NAND gate can be used to perform the AND, OR, and
Inverter operations, or any combination of these operations. The term NAND is a
contraction of NOT-AND and implies an AND function with a complemented
(Inverted) output. Figure below Operation of a 2-input NAND gate.

A A
X X
B B
NAND Gate Truth Table

5
University of Anbar Subject / Digital TechniquesI
College of Engineering Second Stage / 1st Semester
Dept. of Electrical Engineering (2021 – 2022);lecture 3
‫ـــــــــــــــــــــــــــــــــــــــــــــــــــــــــــــــــــــــــــــــــــــــــــــــــــــــــــــــــــــــــــــــــــــــــــــــــــــــــــــــــــــــــــــــــــــــــــــــــــــــــــــ‬
Inputs Output
Logic Symbol
A B X
0 0 1 A
X
0 1 1 B
1 0 1
1 1 0

5- NOR Gate:
The NOR gate, like the NAND gate, is a very useful logic element because it
can also be used as a universal gate; that is; NOR gate can be used to perform the
AND, OR, and Inverter operations, or any combination of these operations.

NOR Gate Truth Table

Inputs Output
Logic Symbol
A B X
0 0 1 A
X
0 1 0 B
1 0 0
1 1 0

The term NOR is contraction of NOT-OR and implies an OR function with an


inverted output. Figure below Operation of a 2-input NOR gate.

6
University of Anbar Subject / Digital TechniquesI
College of Engineering Second Stage / 1st Semester
Dept. of Electrical Engineering (2021 – 2022);lecture 3
‫ـــــــــــــــــــــــــــــــــــــــــــــــــــــــــــــــــــــــــــــــــــــــــــــــــــــــــــــــــــــــــــــــــــــــــــــــــــــــــــــــــــــــــــــــــــــــــــــــــــــــــــــ‬

A A
X X
B B

6- Exclusive-OR Gate (XOR):


The Exclusive-OR is actually formed by a combination of other gates.
Figure below, all possible logic levels for an exclusive-OR gate.

XOR Gate Truth Table

Inputs Output
Logic Symbol
A B X
0 0 0 A
X
0 1 1 B
1 0 1
1 1 0

7
University of Anbar Subject / Digital TechniquesI
College of Engineering Second Stage / 1st Semester
Dept. of Electrical Engineering (2021 – 2022);lecture 3
‫ـــــــــــــــــــــــــــــــــــــــــــــــــــــــــــــــــــــــــــــــــــــــــــــــــــــــــــــــــــــــــــــــــــــــــــــــــــــــــــــــــــــــــــــــــــــــــــــــــــــــــــــ‬

7- Exclusive-NOR Gate (XNOR):


The Exclusive-NOR is actually formed by a combination of other gates.
Figure below, all possible logic levels for an exclusive-NOR gate.

XNOR Gate Truth Table

Inputs Output
Logic Symbol
A B X
0 0 1 A
X
0 1 0 B
1 0 0
1 1 1

8
University of Anbar Subject / Digital TechniquesI
College of Engineering Second Stage / 1st Semester
Dept. of Electrical Engineering (2021 – 2022);lecture 3
‫ـــــــــــــــــــــــــــــــــــــــــــــــــــــــــــــــــــــــــــــــــــــــــــــــــــــــــــــــــــــــــــــــــــــــــــــــــــــــــــــــــــــــــــــــــــــــــــــــــــــــــــــ‬
Example: (a) Develop the truth table for a 3-input AND gate.
(b) Determine the total number of possible input combinations for a
5-input AND gate.
For branch (a) there are eight possible input combinations for a 3-input AND gate.

Input Output
A B C X
0 0 0 0
0 0 1 0
0 1 0 0
0 1 1 0
1 0 0 0
1 0 1 0
1 1 0 0
1 1 1 1

For branch (b), N=25 =32. There are 32 possible combinations of input bits for a
5-input AND gate.

Example: for the two input waveforms, A and B, sketch the output waveform,
showing its proper relation to the inputs.

A A
B
B

X
X

When either or both inputs are HIGH, the output is HIGH as shown by the output
waveform X in the timing diagram.

9
University of Anbar Subject / Digital TechniquesI
College of Engineering Second Stage / 1st Semester
Dept. of Electrical Engineering (2021 – 2022);lecture 3
‫ـــــــــــــــــــــــــــــــــــــــــــــــــــــــــــــــــــــــــــــــــــــــــــــــــــــــــــــــــــــــــــــــــــــــــــــــــــــــــــــــــــــــــــــــــــــــــــــــــــــــــــــ‬
Example: Sketch the output waveform for the 3-input NOR gate, showing the
proper relation to the input.

A A
B
B C

X
X

The output X is LOW when any input is HIGH as shown by the output waveform
X in the timing diagram.

Example: For the 4-input NOR gate operating as a negative-AND. determine the
output relative to the inputs.

A A
B
C
B D

X X

10
University of Anbar Subject / Digital TechniquesI
College of Engineering Second Stage / 1st Semester
Dept. of Electrical Engineering (2021 – 2022);lecture 3
‫ـــــــــــــــــــــــــــــــــــــــــــــــــــــــــــــــــــــــــــــــــــــــــــــــــــــــــــــــــــــــــــــــــــــــــــــــــــــــــــــــــــــــــــــــــــــــــــــــــــــــــــــ‬
Summary of Logic Gates:

Table 1 : The Truth table of the gates

Inputs AND OR NAND NOR EX-OR EX-NOR


A.B A+B A. B A+B A B A B
A B X X X X X X
0 0 0 0 1 1 0 1
0 1 0 1 1 0 1 0
1 0 0 1 1 0 1 0
1 1 1 1 0 0 0 1

Table 2: The Symbols of the gates

Gate Symbol Gate Symbol


Type Type

NOT A A NOR
A A+B A
X
B

AND A.B EX-OR


A A B A
X X
B B

OR A+B A EX-NOR A
X A B X
B B

NAND
A.B A
X
B

11

You might also like