decimal adder - wordpress.com · • example: bcd adder • suppose we apply two bcd numbers to a...

15
Decimal adder When dealing with decimal numbers BCD code is used. A decimal adders requires at least 9 inputs and 5 outputs. BCD adder: each input does not exceed 9, the output can not exceed 19 How are decimal numbers presented in BCD? Decimal Binary BCD 9 1001 1001 19 10011 (0001)(1001) 1 9

Upload: others

Post on 30-May-2020

21 views

Category:

Documents


0 download

TRANSCRIPT

Page 1: Decimal adder - WordPress.com · • Example: BCD adder • Suppose we apply two BCD numbers to a binary adder then: • The result will be in binary and ranges from 0 through 19

Decimal adder

• When dealing with decimal numbers BCD code is used.

• A decimal adders requires at least 9 inputs and 5 outputs.

• BCD adder: each input does not exceed 9, the output can not exceed 19

• How are decimal numbers presented in BCD?

• Decimal Binary BCD • 9 1001 1001 • 19 10011 (0001)(1001) • 1 9

Page 2: Decimal adder - WordPress.com · • Example: BCD adder • Suppose we apply two BCD numbers to a binary adder then: • The result will be in binary and ranges from 0 through 19

Decimal Adder

• Decimal numbers should be represented in binary code number. • Example: BCD adder

• Suppose we apply two BCD numbers to a binary adder then:

• The result will be in binary and ranges from 0 through 19.

• Binary sum: K(carry) Z8 Z4 Z2 Z1 • BCD sum : C(carry) S8 S4 S2 S1

• For numbers equal or less than 1001 binary and BCD are identical. • For numbers more than 1001, we should add 6(0110) to binary to get BCD. • example: 10011(binary) = 11001(BCD) =19 • ADD 6 to correct.

Page 3: Decimal adder - WordPress.com · • Example: BCD adder • Suppose we apply two BCD numbers to a binary adder then: • The result will be in binary and ranges from 0 through 19

BCD adder

Decides to add 6?

Adds 6

Numbers that need correction (add 6) are: 01010 (10) 01011 (11) 01100 (12) 01101 (13) 01110 (14) 01111 (15) 10000 (16) 10001 (17) 10010 (18) 10011 (19)

Page 4: Decimal adder - WordPress.com · • Example: BCD adder • Suppose we apply two BCD numbers to a binary adder then: • The result will be in binary and ranges from 0 through 19

BCD adder

Numbers that need correction (add 6) are: K Z8 Z4 Z2 Z1 0 1 0 1 0 (10) 0 1 0 1 1 (11) 0 1 1 0 0 (12) 0 1 1 0 1 (13) 0 1 1 1 0 (14) 0 1 1 1 1 (15) 1 0 0 0 0 (16) 1 0 0 0 1 (17) 1 0 0 1 0 (18) 1 0 0 1 1 (19)

C = K + Z8Z4 +Z8Z2

Page 5: Decimal adder - WordPress.com · • Example: BCD adder • Suppose we apply two BCD numbers to a binary adder then: • The result will be in binary and ranges from 0 through 19

Magnitude Comparators

• Compares two numbers, determines their relative magnitude.

• We look at a 4-bit magnitude comparator;

• A=A3A2A1A0, B=B3B2B1B0

• Two numbers are equal if all bits are equal. • A=B if A3=B3 AND A2=B2 AND A1=B1 AND A0=B0

• Xi= AiBi + Ai’Bi’ ; Ai=Bi Xi=1 (remember exclusive

NOR?)

Page 6: Decimal adder - WordPress.com · • Example: BCD adder • Suppose we apply two BCD numbers to a binary adder then: • The result will be in binary and ranges from 0 through 19

COMPARATORS

• Comparator is a combinational logic circuit that compares the magnitudes of two binary quantities to determine which one has the greater magnitude.

• In other word, a comparator determines the

relationship of two binary quantities.

• A exclusiveOR gate can be used as a basic comparator.

Page 7: Decimal adder - WordPress.com · • Example: BCD adder • Suppose we apply two BCD numbers to a binary adder then: • The result will be in binary and ranges from 0 through 19

Magnitude Comparators

• How do we know if A>B?

• 1.Compare bits starting from the most significant pair of digits • 2.If the two are equal, compare the next lower significant bits • 3.Continue until a pair of unequal digits are reached • 4.Once the unequal digits are reached, A>B if Ai=1 and Bi=0, A<B if

Ai=0 and Bi = 1

• A>B = A3B3’+X3A2B2’+X3X2A1B1’+X3X2X1A0B0’ • A<B = A3’B3+X3A2’B2+X3X2A1’B1+X3X2X1A0’B0

• Xi=1 if Ai=Bi

Page 8: Decimal adder - WordPress.com · • Example: BCD adder • Suppose we apply two BCD numbers to a binary adder then: • The result will be in binary and ranges from 0 through 19
Page 9: Decimal adder - WordPress.com · • Example: BCD adder • Suppose we apply two BCD numbers to a binary adder then: • The result will be in binary and ranges from 0 through 19

2-bit comparator

Page 10: Decimal adder - WordPress.com · • Example: BCD adder • Suppose we apply two BCD numbers to a binary adder then: • The result will be in binary and ranges from 0 through 19

Circuit diaram for a two bit comparator

Page 11: Decimal adder - WordPress.com · • Example: BCD adder • Suppose we apply two BCD numbers to a binary adder then: • The result will be in binary and ranges from 0 through 19

Truth table for a two bit comparator

Page 12: Decimal adder - WordPress.com · • Example: BCD adder • Suppose we apply two BCD numbers to a binary adder then: • The result will be in binary and ranges from 0 through 19

4-bit magnitude comparators

A3=B3 ?

X3A2’B2

Page 13: Decimal adder - WordPress.com · • Example: BCD adder • Suppose we apply two BCD numbers to a binary adder then: • The result will be in binary and ranges from 0 through 19
Page 14: Decimal adder - WordPress.com · • Example: BCD adder • Suppose we apply two BCD numbers to a binary adder then: • The result will be in binary and ranges from 0 through 19

• There are two different types of output relationship between the two binary quantities;

• Equality output indicates that the two binary numbers being compared is equal (A = B) and

• Inequality output that indicates one of the two binary number being compared is the larger.

• That is, there is an output that indicates when A is greater than B (A > B) and an output that indicates when A is less than B (A < B).

Page 15: Decimal adder - WordPress.com · • Example: BCD adder • Suppose we apply two BCD numbers to a binary adder then: • The result will be in binary and ranges from 0 through 19

Example: Determine the A=B, A>B, and A<B outputs for the input numbers shown on the 4-bit comparator as given below.

Solution: The number on the A inputs is 0110 and the number on the B inputs is 1100. The A < B output is HIGH and the other outputs (A=B and A > B) are LOW