0% found this document useful (0 votes)
43 views55 pages

Capter 6

Uploaded by

eyoyo
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
43 views55 pages

Capter 6

Uploaded by

eyoyo
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 55

1

CHAPTER 6 :
FUNCTIONS OF
COMBINATIONAL LOGIC
Chapter 6 :
2
FUNCTIONS OF COMBINATIONAL LOGIC

 6.1 Basic Adders


 6.2 Parallel Binary Adder
 6.4 Comparators
 6.5 Decoders
 6.6 Encoders
 6.8 Multiplexers (Data Selector)
 6.9 Demultiplexers
 6.7 Code Conventer
 6.10 Parity Generators / Checkers
2.4 Binary Arithmetic
1) Binary Addition (+)
3

 2) Binary Subtraction (-)


 3) Binary Multiplication (x)
 4) Binary Division (/)
1) Binary Addition (+)
4
 The four basic rules for adding binary digits (bits)
are as follows :
0+0= 0
0+1= 1
1+0= 1
1 + 1 = 10 (with a carry of 1)

 Example :
1 111 1 1
01 (1) 1001 (9) 11001
(25)
+ 11 (3) + 1111 (15) +
11001 (25)
100 (4) 11000 (24)
110010 (50)
2) Binary Subtraction (-)
5  The four basic rules for subtracting binary digits
(bits) are as follows :
0-0=0
1-1=0
1-0=1
10 - 1 = 1 -> 0-1 with a borrow of 1
 Example :

111 (7) 10100 (20)


11110 (30)
- 101 (5) - 10000 (16) - 01111
(15)
010 (2) 00100 ( 4)
01111 (15)
2) Binary Multiplication (x)
6  The four basic rules for multiplying binary digits
(bits) are as follows :
0x0=0
0x1=0
1x0=0
1x1=1
 Example :
111 (7)
11 (3) X 101 (5)
x 11 (3) 111
11 000
+ 11 + 111
1001 (9) 100011 (35)
2) Binary Division (/)
7  Division in binary = Division in decimal

 Example :

a) 110 / 11 b) 110 / 10

10 2 11 3
11 110 3 6 10 110 2 6
11 6 10 6
000 0 10 0
00
2.6 Signed Number
8

 Signed binary number consist of sign and


magnitude information.
 Sign Bit = left most bit in signed binary number.
= indicate number is positive (0) or
negative (1). Magnitude bit
Sign bit
 a) Sign-Magnitude form
 For example :

 +25 (8-bit signed number) = 00011001


 -25 (8-bit signed number) = 10011001
In the sign-magnitude form, negative number has the same
magnitude bits as the corresponding positive number but
the sign bit is a 1 rather than a zero
2.5 1’s and 2’s Complements
of
9 Binary Number
 Finding the 1’s Complement of a Binary Number
 Changing all 1 to 0 and all 0 to 1.

 Ex : 1011 0010 (binary number)

 0100 1101 (1’s Complement form)


 Finding the 2’s Complement of a Binary Number
 2’s Complement = (1’s Complement) + 1

 Ex : Find the 2’s Complement of 1011 0010

1011 0010 (Binary Number)


0100 1101 (1’s Complement)
+ 1
0100 1110 (2’s Complement)
2.6 Signed Number+0 Zero is represent as
0000 0000
-0 1111 1111
10
in 1’s Complement
 b) 1’s Complement form
 Positive number in 1’s Complement = positive
sign-magnitude numbers.
 Example :
 +25 = 00011001  positive sign magnitude
 +25 = 00011001  positive in 1’s Complement

 But negative number = 1’s complement of the


corresponding positive number
 Example :
 -25 is expressed as the 1’s complement of
 +25 (00011001)

 = 11100110
2.6 Signed Number
11
 c) 2’s Complement form
 Positive number in 2’s Complement = positive
sign-magnitude numbers.
 Example :
 +25 = 00011001  positive sign magnitude
 +25 = 00011001  positive in 2’s Complement
 But negative number = 2’s complement of the
corresponding positive number
 Example :
 -25 is expressed as the 2’s complement of
 +25 (00011001)
 = 1’s Complement + 1 = 11100110 + 1
 = 11100111
2.7 Arithmetic Operation with
Signed Numbers
12

 a) Addition

 Both number positive


0000 0111 7
+ 0000 0100 + 4
0000 1011 11

 Positive number with larger than negative number


0000 1111 15
+ 1111 1010 + -6
1 0000 1001 9

Discard carry
2.7Arithmetic Operation
13 with
 Signed
Addition (cont..)Numbers

 Negative number with magnitude larger than


positive number
0001 0000 16
+ 1110 1000 + -24
1111 1000 - 8

 Both numbers negative


1111 1011 -5
+ 1111 0111 + -9
1 1111 0010 -14

Discard carry
2.7 Arithmetic Operation with
Signed Numbers
14

 Subtraction

 The sign of a positive or negative binary number is changed by


taking its 2’s complement.
Example :
8-3 = 8+(-3) = 5
0000 1000 (+8)
+ 1111 1101 (2’s complement of -3)
1 0000 0101 (Difference (+5)

Discard carry
2.7 Arithmetic Operation with
Signed Numbers
15

 Multiplication
 The numbers in multiplication are the multiplicand and multiplier
 Example : 8 (Multiplicand)
X 3 (Multiplier)
24 (Product)

 Two basic methods for multiplication


 A) Direct Addition.
 Add the multiplicand a number of times equal to the multiplier
 B) Partial Product (If multiplier is a large number)
 The multiplicand is multiplied by each multiplier digit beginning
with the least significant digit.
 If the signs are the same, the product is positive
 If the signs are different, the product is negative
2.7 Arithmetic Operation with
Signed Numbers
16

 Multiplication
A) Direct Addition
 Example : 0100 1101 (multiplicand) and 0000 0100 (multiplier)
 Since both numbers are positive, the product will be positive.

0100 1101 1st time


+ 0100 1101 2nd time
1001 1010 Partial sum
+ 0100 1101 3rd time
1110 0111 Partial sum
+ 0100 1101 4th time
1 0011 0100 PRODUCT
2.7 Arithmetic Operation with
Signed Numbers
17

 Multiplication
B) Partial Product
 Example :
0101 0011 (multiplicand, 83) and 1100 0101 (multiplier, 59)

 Step 1 : The sign bit of multiplicand is 0 and multiplier is 1. Sign bit


product will be 1 (negative)

 Step 2 : The 2’s complement of the multiplier to put it in true form.


1100 0101  0011 1011
 Step 3 and 4 : only magnitude bits are used

1010011 (multiplicand)
18
X 0111011 (multiplier)
1010011 1st partial product
+ 1010011 2nd partial product
11111001 Sum 1st and 2nd
+ 0000000 3rd partial product
011111001 Sum
+ 1010011 4th partial product
1110010001 Sum
+ 1010011 5th partial product
10001100001 Sum
+ 1010011 6th partial product
100110010001 Sum
+ 0000000 7th partial product
1001100100001 Final product
 Partial Product
 Step 5 : Since the sign of product is 1 as determined in step 1,
take the 2’s complement of the product.
19

1 0011 0010 0001 0 1100 1101 1111

1 0 1100 1101 1111

Attach the sign bit


2.7 Arithmetic Operation with
Signed Numbers
20

 b) Division

dividend = quotient
divisor

 If the sign are the same, the quotient is positive


 If the sign are different, the quotient is negative
b) Division (cont..)
21
Divide 01100100 (+100) by 00011001
(+25)

01100100 -> dividend


------------- = 0000 0100
00011001 -> divisor (4 ->
quotient)
6.1 Basic Adder
22  Basic adder operation is fundamental to
the study of digital system.
 Types of basic adder :
 a) Half Adder
 b) Full Adder
 Basic rules for binary addition
0+0= 0
0+1= 1
1+0= 1
1+1=10
a) Half Adder
 Accepts two binary digits on its inputs and produces two
binary digits on its outputs,
a sum bit and a carry bit
Σ Half adder
A Σ Sum Logic
Input bits Output bits Symbol
Β Cout
Carry

 Cout = AB
 Output carry is 1 only when A and B are 1s.

 S=A+B
 Sum output is a 1, if A and B are not equal.

23
a) Half Adder
 Half adder Truth Table

A B Cout Σ
0 0 0 0
0 1 0 1
1 0 0 1
1 1 1 0

 Half adder Logic Diagram

= A + B = AB + AB

A
B . . Cout = AB

24
b) Full Adder
 Accepts two input bits and an input carry and generates
a sum output and an output carry.
Σ
A Σ Sum
Full adder
Β Logic
Cout Output Carry
Input Carry Cin
Symbol

A B Cin Cout
 .
0 0 0 0 0
0 0 1 0 1
Full adder
0 1 0 0 1
Truth Table
0 1 1 1 0
1 0 0 0 1
1 0 1 1 0
1 1 0 1 0
1 1 1 1 1
25
b) Full Adder : Example
26  Full adder Logic Diagram

A A+B
B

Cin = (A + B) + Cout

 Cout = AB + (A + B) Cin
b) Full Adder : Exercise
 For each of the three full adders, determine
the outputs for the inputs shown :

Σ
1 A Σ Sum

0 Β
Cout Output Carry Σ
0 Cin 1 A Σ Sum

0 Β
Cout Output Carry
Cin
1

Σ
1 A Σ Sum

1 Β
Cout Output Carry
Cin
0

27
6.2Parallel Binary Adder
Two or more full adders are connected to
28

form a parallel adders.


Carry bit from
1 right column

11
+ 01
100
In this case, the
carry bit from 2nd
column becomes a
sum bit
Parallel Adder : Example

29
Parallel Adder : Exercise
30  Determine the sum generated by the 3-bit
parallel adder below and show the
intermediate carries when the binary numbers
101 and 011 are being added.
Figure 6.9 A 4-bit parallel adder

31
6.4Comparators
 Compares two n-bit binary values to determine
which one is larger.
 Inputs : 2 single-bit inputs (X and Y).
 Outputs : 3 lines: X>Y, X=Y, X<Y.

32
Figure 6.19 Basic comparator operation. Equality

33
Figure 6.20 Logic diagram for equality comparison of two 2-bit
numbers.

34
Example
35
Figure 6.23 Logic symbol for a 4-bit comparator with inequality
indication.

36 Compare B3 and A3 first,


if TRUE then immediately set,
If NOT check B2 and A2 ….
Example
37
6.5Decoders
38
 Function – detect the presence of a specified
combination of bits (code) on its inputs and to indicate
the presence of that code by a specified output level.
 Decoder has n input lines to handle n bits and from one
to 2n output lines to indicate the presence of one or more
n-bit combinations.
 Output is 1 if its label matches input
A0 Y0
A1 Y
n A2 DEC
Penyahkod Y
1
2 M
Kemasukan Keluaran
n inputs m outputs
A n
2 -1 Y
M -1

nke2n( 1dari 2n)

Perduaan BCD
A Y0
B Penyahkod Y1
C Y2
D Y3

PerduaankeBCD
Types of Decoder
39

1) Binary decoder
2) 3-Bits decoder (1 from 8) = 3-line to 8-line
3) 4-Bit decoder (1 from 16) = 4-line to 16-line
4) Binary to BCD decoder
5) BCD to Decimal decoder
6) BCD to 7-segments
1) Binary decoder
40
1 A0 (LSB)

1 A1
0 A1
1 X=A3A2A1A0

0
1 A2
1 A2
A3 (LSB)

 Decoding logic for the binary code 1001 with an active-HIGH output
 The output is 1 if only when A0=1, A1=0, A2=0, A3=1 are applied to the
inputs.
2) 3-Bits decoder A B C

41
Q0
A B C Q0 Q1 Q2 Q3 Q4 Q5 Q6 Q7
0 0 0 1 0 0 0 0 0 0 0
0 0 1 0 1 0 0 0 0 0 0 Q1
0 1 0 0 0 1 0 0 0 0 0
0 1 1 0 0 0 1 0 0 0 0 Q2
1 0 0 0 0 0 0 1 0 0 0
1 0 1 0 0 0 0 0 1 0 0 Q3
1 1 0 0 0 0 0 0 0 1 0
1 1 1 0 0 0 0 0 0 0 1
Q4
Truth Table for 3 bits decoder
Q5
with active-HIGH

Q6

Q7
3) 4-Bits decoder
42

CLASS …
Please construct a truth table for
this type of decoder

SHOW ME !!!
Figure 6-31 A simplified computer I/O port system with a port address
decoder with
only four address lines shown.

43
4) Binary to BCD decoder
A B C D Y4 Y3 Y2 Y1 Y0 Penyahkod jenis ini mengambil nilai-
44 nilai atau nombor-nombor perduaan
0 0 0 0 0 0 0 0 0
dan menukarnya kepada kod-kod BCD
0 0 0 1 0 0 0 0 1
A B C D
0 0 1 0 0 0 0 1 0
0 0 1 1 0 0 0 1 1
0 1 0 0 0 0 1 0 0
0 1 0 1 0 0 1 0 1 Y4

0 1 1 0 0 0 1 1 0
0 1 1 1 0 0 1 1 1 Y3

1 0 0 0 0 1 0 0 0
Y2
1 0 0 1 0 1 0 0 1
Y1
1 0 1 0 1 0 0 0 0
1 0 1 1 1 0 0 0 0
Y0
1 1 0 0 1 0 0 0 0
1 1 0 1 1 0 0 0 0
1 1 1 0 1 0 0 0 0
1 1 1 1 1 0 0 0 0
Review ..Binary Coded
Decimal (BCD)
 BCD is a way to express each of the

decimal digits with a binary code.


 There are only 10 code groups in the BCD
system
0 1 2 3 4 5 6 7 8 9

0000 0001 0010 0011 0100 0101 0110 0111 1000 1001

 Ex : 3510 = 0011 0101

45
5) BCD to Decimal decoder
Decima A3 A2 A1 A0 Decoding
46l digit Function

0 0 0 0 0 A3 A2 A1 A0

1 0 0 0 1 A3 A2 A1 A0

2 0 0 1 0 A3 A2 A1 A0

3 0 0 1 1 A3 A2 A1 A0

4 0 1 0 0 A3 A2 A1 A0

5 0 1 0 1 A3 A2 A1 A0

6 0 1 1 0 A3 A2 A1 A0

7 0 1 1 1 A3 A2 A1 A0

8 1 0 0 0 A3 A2 A1 A0

9 1 0 0 1 A3 A2 A1 A0
Figure 6.33 : BCD to Decimal decoder example

47
6) Binary to 7-segments
decoder
48
 The function of a BCD to 7-segment decoder is to
convert the logic states at the outputs of a BCD counter
which will drive a 7-segment display.
 The display shows the decimal numbers 0-9 and is
easily understood.
 The individual segments making up a 7-segment display
are identified by letters as follows:
6) Binary to 7-segments
decoder
49
BCD inputs segment outputs
display
D C B A a b c d e f g
0 0 0 0 1 1 1 1 1 1 0

0 0 0 1 0 1 1 0 0 0 0
0 0 1 0 1 1 0 1 1 0 1
0 0 1 1 1 1 1 1 0 0 1

0 1 0 0 0 1 1 0 0 1 1
0 1 0 1 1 0 1 1 0 1 1
0 1 1 0 1 0 1 1 1 1 1

0 1 1 1 1 1 1 0 0 0 0
1 0 0 0 1 1 1 1 1 1 1
1 0 0 1 1 1 1 1 0 1 1
6.6Encoders
 Encoder does the opposite from decoder

 Encoder accepts an active level on one of its inputs


representing a digit, such as a decimal or octal
digit and converts it to a coded output, such as
BCD or binary.

 Encoder can also be devised to encode various


symbols and alphabetic characters.

50
Decimal-to-BCD encoder

51

Thomas L. Floyd Copyright ©2003 by Pearson Education,


Digital Fundamentals, 8e Inc.
Upper Saddle River, New Jersey 07458
S0 S1 S2 S3 S4 S5 S6 S7 S8 S9 A3 A2 A1 A0
1 0 0 0 0 0 0 0 0 0 0 0 0 0
0 1 0 0 0 0 0 0 0 0 0 0 0 1
0 0 1 0 0 0 0 0 0 0 0 0 1 0
0 0 0 1 0 0 0 0 0 0 0 0 1 1
0 0 0 0 1 0 0 0 0 0 0 1 0 0
0 0 0 0 0 1 0 0 0 0 0 1 0 1
0 0 0 0 0 0 1 0 0 0 0 1 1 0
Vcc 0 0 0 0 0 0 0 1 0 0 0 1 1 1
0 0 0 0 0 0 0 0 1 0 1 0 0 0
0 0 0 0 0 0 0 0 0 1 1 0 0 1

Please Identify :
S0 A0 = ?,
S1
A1 = ?,
AA0
S2
S3
Pengekod BA1 A2 = ?,
S4 CA2
S5 (Encoder)
DA A3 = ?
3
S6 (Kod BCD)
S7
S8 Logic symbols for a
S9
decimal to BCD encoder.

52
Figure 6.38 Basic logic diagram of a decimal-to-BCD encoder. A 0-digit input is not
needed because the BCD outputs are all LOW when there are no HIGH inputs.

53

Thomas L. Floyd Copyright ©2003 by Pearson Education,


Digital Fundamentals, 8e Inc.
Upper Saddle River, New Jersey 07458
Link
54

www.allaboutcircuits.com/vol_4/chpt_9/index.html
www.opamp-electronics.com/tutorials/digital_theory_ch_009.htm
55

END OF CHAPTER 6

You might also like