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

Lecture 19

notes

Uploaded by

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

Lecture 19

notes

Uploaded by

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

4.

5 DECIMAL
ADDER
80

DECIMAL ADDER
• BCD Adder

• Consider the arithmetic addition of two decimal digits in BCD


and an input carry.

• In BCD each input digit does not exceed 9

• Output sum cannot be greater than 9 + 9 + 1 = 19.


– 1 is an input carry.

12 December, 2016 INTRODUCTION TO LOGIC DESIGN


81

DECIMAL ADDER
• Suppose:
– Two BCD digits applied to a 4-bit binary adder.
c3 c2 c1 .
+ x3 x 2 x 1 x 0
+ y3 y2 y1 y0
────────
Cy S3 S2 S1 S0

– The output produces a result that ranges from 0 through 19.

12 December, 2016 INTRODUCTION TO LOGIC DESIGN


82

DECIMAL ADDER
X +Y x3 x2 x1 x0 y3 y2 y1 y0 Sum Cy S S S S
3 2 1 0
0+0 0 0 0 0 0 0 0 0 =0 0 0 0 0 0
0+1 0 0 0 0 0 0 0 1 =1 0 0 0 0 1
0+2 0 0 0 0 0 0 1 0 =2 0 0 0 1 0

0+9 0 0 0 0 1 0 0 1 =9 0 1 0 0 1
1+0 0 0 0 1 0 0 0 0 =1 0 0 0 0 1
1+1 0 0 0 1 0 0 0 1 =2 0 0 0 1 0

1+8 0 0 0 1 1 0 0 0 =9 0 1 0 0 1
1+9 0 0 0 1 1 0 0 1 =A 0 1 0 1 0 Invalid Code
2+0 0 0 1 0 0 0 0 0 =2 0 0 0 1 0

9+9 1 0 0 1 1 0 0 1 = 12 1 0 0 1 0 Wrong BCD Value

12 December, 2016 0001 1000 INTRODUCTION TO LOGIC DESIGN


83

DECIMAL ADDER
X +Y x3 x2 x1 x0 y3 y2 y1 y0 Sum Cy S3 S2 S1 S0 Required BCD Output Value

9+0 1 0 0 1 0 0 0 0 =9 0 1 0 0 1 0 0 0 0 1 0 0 1 =9
9+1 1 0 0 1 0 0 0 1 = 10 0 1 0 1 0 0 0 0 1 0 0 0 0 = 16 
9+2 1 0 0 1 0 0 1 0 = 11 0 1 0 1 1 0 0 0 1 0 0 0 1 = 17 
9+3 1 0 0 1 0 0 1 1 = 12 0 1 1 0 0 0 0 0 1 0 0 1 0 = 18 
9+4 1 0 0 1 0 1 0 0 = 13 0 1 1 0 1 0 0 0 1 0 0 1 1 = 19 
9+5 1 0 0 1 0 1 0 1 = 14 0 1 1 1 0 0 0 0 1 0 1 0 0 = 20 
9+6 1 0 0 1 0 1 1 0 = 15 0 1 1 1 1 0 0 0 1 0 1 0 1 = 21 
9+7 1 0 0 1 0 1 1 1 = 16 1 0 0 0 0 0 0 0 1 0 1 1 0 = 22 
9+8 1 0 0 1 1 0 0 0 = 17 1 0 0 0 1 0 0 0 1 0 1 1 1 = 23 
9+9 1 0 0 1 1 0 0 1 = 18 1 0 0 1 0 0 0 0 1 1 0 0 0 = 24 
+6
12 December, 2016 INTRODUCTION TO LOGIC DESIGN
84

DECIMAL ADDER
• The problem is to find a rule by which the binary sum is to be
converted to the correct BCD digit representation of the number
in the BCD sum.

12 December, 2016 INTRODUCTION TO LOGIC DESIGN


85

DECIMAL ADDER
Binary Sum BCD Sum Decimal
K Z3 Z2 Z1 Z0 C S3 S2 S1 S0
0 0 0 0 0 0 0 0 0 0 0
0 0 0 0 1 0 0 0 0 1 1
0 0 0 1 0 0 0 0 1 0 2
0 0 0 1 1 0 0 0 1 1 3
0 0 1 0 0 0 0 1 0 0 4
0 0 1 0 1 0 0 1 0 1 5
0 0 1 1 0 0 0 1 1 0 6
0 0 1 1 1 0 0 1 1 1 7
0 1 0 0 0 0 1 0 0 0 8
0 1 0 0 1 0 1 0 0 1 9

12 December, 2016 INTRODUCTION TO LOGIC DESIGN


86

DECIMAL ADDER
Binary Sum BCD Sum Decimal
K Z3 Z2 Z1 Z0 C S3 S2 S1 S0
0 1 0 1 0 1 0 0 0 0 10
0 1 0 1 1 1 0 0 0 1 11
0 1 1 0 0 1 0 0 1 0 12
0 1 1 0 1 1 0 0 1 1 13
0 1 1 1 0 1 0 1 0 0 14
0 1 1 1 1 1 0 1 0 1 15
1 0 0 0 0 1 0 1 1 0 16
1 0 0 0 1 1 0 1 1 1 17
1 0 0 1 0 1 1 0 0 0 18
1 0 0 1 1 1 1 0 0 1 19

12 December, 2016 INTRODUCTION TO LOGIC DESIGN


87

DECIMAL ADDER
• In examining the contents of the table;
– When the binary SUM = 1001, the corresponding BCD number is
identical.
– When the binary SUM >1001, the BCD number is invalid.
– The addition of 6 (0110) is required.
– Correction is needed when K = 1.
– Correction is needed from 1010 – 1111.
• Z4 = 1,
• Z3 and Z2 must = 1 to distinguish from 1000 and 1001

12 December, 2016 INTRODUCTION TO LOGIC DESIGN


88

DECIMAL ADDER
Z3 Z2 Z1 Z0 Err Z1
Z 1Z 0
0 0 0 0 0 Z 3Z 2 00 01 11 10
. . 00
. .
. . 01
Z
1 0 0 0 0 2

1 0 0 1 0
11 1 1 1 1
Z
1 0 1 0 1 3
10 1 1
1 0 1 1 1
1 1 0 0 1
Z0
1 1 0 1 1
1 1 1 0 1 Err = Z3Z2 + Z3Z1
1 1 1 1 1
Output Carry = K + Z3Z2+ Z3Z1
12 December, 2016 INTRODUCTION TO LOGIC DESIGN
89

DECIMAL ADDER
Addend Augend

• When Output carry = 0,


– Nothing is added. Carry
out K 4-bit binary adder
Carry
in

• When Output carry = 1,


Output

– add 0110 to the binary sum.


Carry

– provide an output carry for


0

the next stage.


4-bit binary adder

S3 S2 S1 S0

12 December, 2016 INTRODUCTION TO LOGIC DESIGN


4.6 BINARY
MULTIPLIER
91

B I N A R Y M U LT I P L I E R
A0
• Consider; 2-bit number A1
B0
Multiplicand
bits B1
x Multiplier
bits
First partial product
(AND gate)
+ Second partial product
(AND gate)
Product

HA HA

C 3 C2 C1 C0
12 December, 2016 INTRODUCTION TO LOGIC DESIGN
92

B I N A R Y M U LT I P L I E R
• For more bits;
– A bit of multiplier is ANDed with each bit of multiplicand in as many
levels as there are bits.

– The binary output of AND gate in each level is added with the partial
product of previous level.

– For J multiplier bits and K multiplicand bits we need


• J x K AND gates.

12 December, 2016 INTRODUCTION TO LOGIC DESIGN


4.7 MAGNITUDE
COMPARATOR
94

M AG N I T U D E CO M PA R ATO R
• Compare two numbers (A and B)

• 3 outputs <, =, >


– A > B, A = B, A<B

• Consider compare 4-bit number to 4-bit number


A3A2A1A0 B3B2B1B0
– A = A3 A2 A1 A0

– B = B3 B2 B1 B0 Magnitude
Comparator

A>B A=B A<B


12 December, 2016 INTRODUCTION TO LOGIC DESIGN
95

M AG N I T U D E CO M PA R ATO R
• A = B if:
– A3 = B3 AND A2 = B2 AND A1 = B1 AND A0 = B0
Ai Bi xi (A = B) x3 = A3’ . B3’ + A3 . B3
0 0 1
x2 = A2’ . B2’ + A2 . B2
0 1 0
x1 = A1’ . B1’ + A1 . B1
1 0 0
1 1 1 x0 = A0’ . B0’ + A0 . B0

xi = Ai’ . Bi’ + Ai . Bi
x = x3 . x2 . x1 . x0 = (A = B)
12 December, 2016 INTRODUCTION TO LOGIC DESIGN
96

M AG N I T U D E CO M PA R ATO R
• A > B if
– Ai = 1 and Bi = 0
Ai Bi yi (A > B) y3 = A3 . B3’
0 0 0
y2 = y3 . A2 . B2’
0 1 0
y1 = y3 . y2 . A1 . B1’
1 0 1
1 1 0 y0 = y3 . y2 . y1 . A0 . B0’

yi = Ai . Bi’
y = y3 + y2 + y1 + x0 = (A > B)
12 December, 2016 INTRODUCTION TO LOGIC DESIGN
97

M AG N I T U D E CO M PA R ATO R
• A < B if
– Ai = 0 and Bi = 1
Ai Bi zi (A < B) z3 = A3’ . B3
0 0 0
z2 = y3 . A2’ . B2
0 1 1
z1 = y3 . y2 . A1’ . B1
1 0 0
1 1 0 z0 = y3 . y2 . y1 . A0’ . B0

zi = Ai’ . Bi
z = z3 + z2 + z1 + z0 = (A < B)
12 December, 2016 INTRODUCTION TO LOGIC DESIGN
98

M AG N I T U D E CO M PA R ATO R
A3
x3
B3

A2
x2
B2

A1 z = (A<B)
x1
B1

A0
x0 y = (A>B)

B0
x=(A=B)

12 December, 2016 INTRODUCTION TO LOGIC DESIGN

You might also like