0% found this document useful (0 votes)
17 views30 pages

246094lecture 12 - Decimal Arithmetic Operations and BCD-1693891828368

Uploaded by

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

246094lecture 12 - Decimal Arithmetic Operations and BCD-1693891828368

Uploaded by

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

Computer

Organization &
Architecture
Lecture 12
Decimal Arithmetic
Operations and BCD
Session Objectives
By the end of the session, we will be
able to:

▪ Discuss arithmetic operations and decimal


arithmetic unit with an example
▪ Explain the difference between binary addition
and BCD Addition
▪ Describe BCD Adder in detail
Floating-point arithmetic operations

Floating-point normalization and


Floating-point operations

Floating-point hardware
Decimal Arithmetic Unit

BCD Addition

BCD Adder
Arithmetic Operations

▪ The four basic arithmetic operations are


addition, subtraction, multiplication, and
division.
▪ We can use these four operations to derive
other operations also.
▪ The need for these arithmetic operations is to
manipulate the data. Data is manipulated to
produce the results required to solve
computation problems.
▪ Computers, calculators, or other specialized
digital systems that perform arithmetic
operations directly in the decimal number
system represent decimal numbers in the
binary-coded form.
▪ There are basically two cases in computer
systems: When the I/O is small and the
arithmetic calculations are relatively larger
and vice versa.
Arithmetic Operations

▪ It is necessary to convert input decimal


numbers to binary, perform all calculations
with binary numbers, and convert results back
to decimal to perform arithmetic operations on
decimal data.
▪ This can be a good method for applications
that require a lot of calculations but only a
small amount of input and output data.
▪ When an application requires a large amount
of input-output and a small number of
arithmetic calculations, doing internal
arithmetic directly with decimal numbers
becomes appropriate.
▪ Decimal data must be stored in binary-coded
form (BCD) on computers that can do decimal
arithmetic. The decimal numbers are then fed
into a decimal arithmetic unit, which can
perform micro-operations in decimal numbers.
Decimal Arithmetic Unit

▪ A decimal arithmetic unit is a digital function


that performs decimal microoperations.
▪ It mainly performs two operations
○ Addition
○ Subtraction
▪ The addition operation is performed with BCD
Adder whereas subtraction is performed with
BCD Subtractor.
Here, BCD stands for binary-coded decimal.
Decimal Arithmetic Unit

▪ Example

Decimal 8 4 2 1 Explanation
Digits
0 0 0 0 0 All 0’s
1 0 0 0 1 LSB is 1
2 0 0 1 0 Self-explanatory

3 0 0 1 1 2+1 = 3
4 0 1 0 0 Self-explanatory

5 0 1 0 1 4+1 = 5
6 0 1 1 0 4+2 = 6
7 0 1 1 1 4+2+1 = 7
8 1 0 0 0 Self-explanatory
9 1 0 0 1 8+1 = 9
Decimal Arithmetic Unit

BCD Addition

BCD Adder
BCD Code

▪ Example Analysis
▪ The mentioned codes are valid BCD codes.
▪ Now, we’ll look at the invalid BCD codes:
▪ Since we are using 4-bits to represent the
decimal digits, the total possibilities will be
24 = 16 and we are only representing (0-9),
i.e. 10 out of 16 possibilities. So, what about
the other ones?
▪ 10 - 15 are considered invalid since they are
not decimal digits rather decimal numbers.
Terms(X) are used to represent invalid cases.
BCD Code

▪ For example, to represent 10 in BCD, the BCD


code for 1 and 0 will be concatenated.
Thus, (10)10 = 00010000
▪ Now, you must be wondering, are the BCD
and binary the same? The answer is NO.
▪ Example
▪ Let’s understand with an example:
▪ Let’s convert a decimal number 15 in binary
as well as in BCD.
(15)10 = (1111)2 in binary
(15)10 = (00010101) in BCD
BCD Addition
▪ BCD addition is a replica of the binary
addition. In BCD addition, we’ve to deal with
three cases which are:
▪ Sum <= 9, final carry = 0, the obtained result
is correct.
▪ Sum <= 9, final carry = 1, the obtained result
is incorrect. To correct the answer, we just
need to add 6 (or 0110) to the obtained
result.
▪ Sum >9, final carry = 0, again the result
obtained is incorrect. To correct the answer
the same will be followed, i.e., the addition of
6 (or 0110) to the result.
BCD Addition

▪ Examples
▪ (2)2 + (6)2

▪ (3)10 + (7)10
BCD Addition
▪ As discussed above by adding 6 we can
obtain the correct result. Now the question
may arise why 6 only?
▪ We know that we use the 4-bit binary number
to represent the decimal digits which are from
(0-9).
▪ Also, we know that with 4-bit there can be 16
(0-15) possibilities.
▪ But the valid cases are only from (0-9), by
this, we can calculate the invalid cases, i.e, 15
- 9 = 6.
BCD Addition

▪ To correct the answer, let’s add 6 to the sum.

▪ (10)10 = 0001 0000


Decimal Arithmetic Unit

BCD Addition

BCD Adder
BCD Adder
▪ The digital system handles the decimal
number in the form of binary-coded decimal
numbers (BCD).
▪ A BCD Adder Circuit adds two BCD digits and
returns a BCD sum digit. BCD numbers use
digits, ranging from 0 to 9, which are
represented in binary as 0000 to 1001, i.e.
each BCD digit is a 4-bit binary number.
▪ The maximum value of output will be 19 (i.e.
9(1001)+9(1001)+1(carry =1) = 19).
▪ Here, we will only be obtaining the binary
Fig. BCD Adder
addition of the two numbers. To convert them
into the BCD form by using the BCD adder.
BCD Adder
▪ As a result, in order to build a BCD Adder
Circuit, we'll need:
○ 4-bit binary adder for initial addition
○ Logic circuit to detect sum greater than 9
○ One more 4-bit adder to add 0110(6) in the
sum if the sum is greater than 9 or carry is 1.

▪ The only correction is needed in the second


half of the table.
BCD Adder
▪ Reason
▪ The minimum sum we can obtain from the 4-
bit adder is zero (0000 with k(final carry) = 0)
and the maximum sum is 19 (0011 with k =
1).
▪ The table shows that when the 'Binary Sum'
has an output carry K=1, a correction is
required.
▪ First condition = K(output carry) = 1, which
covers the numbers from 16 to 19.
▪ The remaining six combinations numbered 10
to 15, require correction, with the bit on the Z8
position set to 1.
▪ If we closely look at table two unrequired
cases ( 8 and 9 ) will also be covered. To
overcome this, we can check for the other
bits. Herewith Z8, Z4 values are also 1’s.
BCD Adder
▪ Reason
▪ Second condition = Z8Z4 = 1, which covers
the numbers from 12 to 15.
▪ The leftover will be covered by considering
the Z8 and Z2 bits.
▪ Third condition = Z8Z2 = 1, which covers the
numbers 10 and 11
▪ To conclude: C=K+Z8.Z4+Z8.Z2 will be the
Boolean expression for the adder circuit.
Henceforth, we are adding “0110” (=6) only
to the second half of the table.
▪ We can also make use of the K-map to find the
Boolean expression.
BCD Adder

Fig. Block Diagram of BCD Adder


BCD Adder
▪ In the diagram, we'll use a 4-bit Binary-Adder
as an example, which accepts addend and
augend bits as input and has a 'Carry in' input
carry.
▪ The Binary-Adder generates five outputs: Z8,
Z4, Z2, Z1, and a carry K output.
▪ The logical circuit is designed to identify the
Cout using the output carry K and Z8, Z4, Z2,
and Z1 outputs.
▪ The binary adder's Z8, Z4, Z2, and Z1 outputs
are fed into the 2nd 4-bit binary adder as an
Augend.

Fig. Block Diagram of BCD Adder


BCD Adder
▪ The added bit of the 2nd 4-bit binary adder is
designed in such a way that the 1st and the
4th bit of the addend number are 0 and the
2nd and the 3rd bit are the same as Cout.
▪ When the value of cout is 0, the addend
number will be 0000, which generates the
same result as the 1st 4-bit binary number.
But when the value of the Cout is 1, the
addend bit will be 0110(6) which adds with
the augend to get the valid BCD number.
BCD Adder
▪ Example: 1001 + 1001
▪ Step 1: Add both the numbers using a 4-bit
binary adder and the input carry Cin = 0.

▪ Step 2: The binary adder produces the result


0010 and the output carry as 1(k=1).
BCD Adder
▪ Example: 1001 + 1001 (Ctd.)
▪ Step 3: Then, using the expression
Cout=K+Z8.Z4+Z8.Z2, find the Cout value to
determine whether the produced BCD is
invalid or valid.
K=1
Z8 = 0
Z4 = 0
Z2 = 1
Cout = 1+0*0+0*1
Cout = 1+0+0
Cout = 1
BCD Adder
▪ Step 4: The value of Cout is 1, which
expresses that the produced BCD code is
invalid. Then, add the output of the 1st 4-bit
binary adder with 0110(6).
= 0010+0110
= 1000
▪ The BCD is represented by the carry output
as:
BCD=Cout Z8 Z4 Z2 Z1=1 1 0 0 0 (19)
Decimal Arithmetic Unit

BCD Addition

BCD Adder
Lecture 12 Activity
1 activity.
Time for an
Lecture 12 Activity
2 activity.
Time for an

You might also like