Design and Implementation of A Unified BCD/Binary Adder/Subtractor
Design and Implementation of A Unified BCD/Binary Adder/Subtractor
Design and Implementation of a Unified
BCD/Binary Adder/Subtractor
Contents
Chapter 5 ............................................................................................................................... 74
5.1 Introduction ............................................................................................................... 74
5.2 Review of Existing Techniques for BCD Addition/Subtraction ............................... 76
5.2.1 One-Digit BCD Full Adder ..............................................................................76
5.2.2 Higher Bit BCD/Binary Adders/Subtractors ....................................................77
5.3 A Unified BCD/Binary Adder/Subtractor Architecture ............................................ 79
5.3.1 Conventional Binary Adder /Subtractor ...........................................................80
5.3.2 A Modified Binary Adder/Subtractor ...............................................................82
5.3.3 Modified BCD Adder/Subtractor .....................................................................84
5.3.4 A Modified Unified BCD/Binary Adder/Subtractor Architecture ...................88
5.4 Simulations and Results ............................................................................................ 89
5.5 Conclusions ............................................................................................................... 92
5.1 Introduction
There is a growing importance of decimal arithmetic in commercial, financial and internet-
based applications. These applications cannot tolerate errors that result from the conversion of
binary format to decimal format. Thus, hardware support for decimal arithmetic is receiving
considerable attention. Recently, specifications for decimal floating point arithmetic have been
added to the draft revision of IEEE-754 standard for floating point arithmetic [43]. Despite the
widespread use of binary arithmetic, decimal computation remains essential for many
applications. Not only is it required whenever numbers are presented for human inspection, but is
also often a necessity when fractions are involved. Decimal fractions are pervasive in human
endeavors, yet most cannot be represented by binary fractions. The value 0.1 for example,
5.1 Introduction
requires an infinitely recurring binary number. If a binary approximation is used instead of an
exact decimal fraction, results can be incorrect even if subsequent arithmetic is correct.
As the IEEE standard for decimal floating point is approved, hardware support for decimal
floating point arithmetic will be incorporated in processors for various applications. Still, a major
consideration while implementing Binary Coded Decimal (BCD) arithmetic is to enhance its
speed as much as possible.
BCD is a decimal representation of a number directly coded in binary, digit by digit. For
example, the number (9527)10 is represented as (1001 0101 0010 0111)BCD . It can be seen that
each digit of the decimal number is coded in binary and then concatenated to form BCD
representation of the decimal number.
To use this representation all the arithmetic and logical operations need to be defined. As
the decimal number system contains 10 digits, at least 4 bits are needed to represent a BCD digit.
The BCD representation of digit A is A4A3A2A1 where all Ak ∈ (0,1) . The only point to note is
that the maximum value that can be represented by a BCD digit is ‘9’. The representation of
(10)10 in BCD is (0001 0000).
Addition in BCD can be explained by considering two decimal digits A and B with BCD
representations as A4A3A2A1 and B4B3B2B1 respectively. In the conventional approach , these
two numbers are added using a 4-bit binary adder during which it is possible that the resultant
Sum can exceed 9 resulting in an overflow. If the Sum is greater than 9, the binary equivalent of
6 is added to the resultant Sum to obtain the exact BCD representation. This can be illustrated
with the following example
A 0110 (6)
B 0101 (5)
Sum 1011 (11)
Add 0110 ( 6)
BCD 1 0001 (11 in BCD )
Answer = (0001 0001)
75
5.2 Review of Existing Techniques for BCD Addition/Subtraction
A BCD 1-digit adder is a circuit that adds two BCD digits in parallel and also produces the
Sum digit in BCD along with the necessary correction logic. The conventional implementation of
addition as mentioned above is shown in Fig 5.1[44]. It can be seen that a 4-bit binary adder is
used initially to add two BCD digits (each digit expressed using 4 bits) with a carry-input. An
overflow detection circuit is used (to check if the ‘Sum’ of the BCD digit has exceeded 9) which
is designed using two 2-input AND gates and a 3-input OR gate. Finally, another 4-bit binary
adder is used as a correction stage, which comes in the path of final Sum computation. Thus, the
critical path in this circuit consists of a 4-bit binary adder, overflow logic and one more 4-bit
binary adder. Assuming, in the best case, that the 4-bit binary adder is a carry look-ahead adder,
a gate level analysis would indicate that it consists of 4-gates in the critical path. It can be
observed from Fig 5.1 that the overflow detection circuit comes into picture only after the top-
most 4-bit binary adder performs its operation and it consists of 2 gates in the critical path. Thus,
a minimum of a 10-gate delay can be expected in conventional implementation [44]. The above
design can however be optimized by removing those gates that are completely redundant in their
operation. Such a modification is shown in Fig 5.2 which results in a smaller critical path. A
faster carry prediction for this implementation is proposed in [45], which uses carry look-ahead
logic to predict the carry in advance. These 1-digit full adders can be cascaded to realize higher
digit BCD adders.
76
5.2 Review of Existing Techniques for BCD Addition/Subtraction
A3 B3 A2 B2 A1 B1 A0 B0
CO FA CI CO FA CI CO FA CI CO FA CI Cin
S S S S
A1 1 1XX
A2 1X1X
CO FA CI CO FA CI 0
S S
Cout S3 S2 S1 S0
77
5.2 Review of Existing Techniques for BCD Addition/Subtraction
78
5.3 A Unified BCD/Binary Adder/Subtractor Architecture
79
5.3 A Unified BCD/Binary Adder/Subtractor Architecture
a detailed implementation of the proposed unified binary and BCD adder/subtractor is discussed.
Initially, the conventional binary adder/subtractor is discussed followed by a modified binary
adder/subtractor. This is followed by the existing design of BCD adder/subtractor leading to an
improved version of the same. Finally, the binary and BCD adder/subtractor has been combined
to realize a unified binary/BCD adder /subtractor that performs better than the exiting one.
80
5.3 A Unified BCD/Binary Adder/Subtractor Architecture
In floating-point operations, where the operands are in signed magnitude form, there is an
extra bit that indicates the sign of the operand. Addition/subtraction operation on this signed
magnitude form not only depends on type of operation but also on the sign bit. For example,
assume X and Y are two (n+1)-bit signed magnitude numbers such that X = [XnXn-1Xn-2…X0] and
Y = [YnYn-1 Yn-2……Y0], where Xn and Yn are sign bits. The type of operation i.e., addition or
subtraction is represented with ‘Op’. (Where ‘Op’ is logic ‘1’ the operation is subtraction and
vice versa). The effective operation that depends on the type of operation as well as sign bits is
given in Table 5.1.
From this Table, the ‘Effective Operation’ (EOp) is given by equation (5.1). When the
‘EOp’ is logic ‘1’, the operation that needs to be performed is addition and when ‘EOp’ is logic
‘0’ the operation is subtraction.
EOp = (Xn Yn ) Op (5.1)
After the effective operation EOp is determined using equation 5.1, sign of the result is
computed using the sign of the first operand X i.e. Xn and the Carry-out from the adder circuit. If
the final effective operation is addition then the sign of the final result is equal to the sign of the
first operand i.e. X. However, if the effective operation is subtraction the final sign depends on
the sign of X and also the carry-out signal (indicates if X >Y or X≤ Y) of the adder circuit. The
sign of the final result ‘Sn’ is given by
When the effective operation is addition i.e., EOp = 1, both the operands X and Y are given
directly to the prefix adder and the final result is X+Y. When the effective operation is
subtraction i.e. EOp = 0, operand Y is inverted at the input side. The normal addition operation is
carried out to result in X + (Y)’. The resulting ‘Carry-out’ of this addition indicates whether X >
Y or X ≤ Y. Based on this and from the above equations, addition of ‘1’ or inverting operation is
decided to compute the final result. The optimized late carry-in adder proposed in section 2.3 is
used in this design. This late carry-in is used for the addition of ‘1’ when X>Y. When X ≤ Y, a
group of XOR gates carries out the inverting operation after the sum is computed. The proposed
binary adder/subtractor design is shown in Fig 5.9.
83
5.3 A Unified BCD/Binary Adder/Subtractor Architecture
5.3.3 Modified BCD Adder/Subtractor
The existing BCD Adder/Subtractor architectures and the limitations of the same have
been explained in section 5.2. In this section, a modified BCD adder/subtractor architecture is
presented which overcomes these limitations. The proposed design is inspired from Fischer
approach but eliminates the usage of complementary stage as well as supports unsigned and
signed magnitude form.
In Fischer’s approach, the BCD addition operation is performed by pre-correction block
where digit-wise addition of ‘6’ is carried out for one of the operands. After pre-correction the
result is added to other operand by a binary adder. The post-correction block includes conditional
subtraction of ‘6’ depending up on the ‘Carry-out’ at each digit stage. This signal at each digit
stage indicates whether the digit is greater than ‘9’ or not. For example, if the ‘Carry-out’ is ‘1’
the digit is less than or equal to ‘9’ and hence no correction is required. If the ‘Carry-out’ is ‘0’
the digit is greater than ‘9’ and a correction by subtraction of ‘6’ is needed. Since 2’s
complement of ‘6’ is ‘10’, subtraction of ‘6’ i.e. (0110)2 is accomplished by addition of ‘10’ i.e.,
(1010)2. The following example 5.1 and Fig 5.10 illustrate the above decimal addition operation.
Example 5.1:
Let X=556
Y=239
In BCD format: X = 0101 0101 0110
Y = 0010 0011 1001
Addition of digit-wise 6 i.e. (0110)2 to X results in new X,
X = 0101 0101 0110
+6 0110 0110 0110
Hence, new X = 1011 1011 1100
Now the ‘new X’ is added to Y and correction is applied.
84
5.3 A Unified BCD/Binary Adder/Subtractor Architecture
The BCD subtraction is similar to binary subtraction with an extra post-correction stage
like in BCD addition. In Fischer’s approach, the BCD subtractor gives unsigned result when
X>Y where X and Y are minuend and subtrahend respectively. However, this approach requires a
10’s complement, like 2’s complement for binary, if X ≤ Y. The design proposed in this work is
aimed to eliminate the overhead related to this extra complementary stage. However, the post-
correction stage needs to be modified to handle both conditions X>Y and X ≤ Y. The following
examples 5.2 and 5.3, Fig 5.11 and Fig 5.12 illustrate the decimal subtraction operation for cases
X>Y and X ≤ Y respectively.
Example 5.2: Subtraction operation and X>Y
Let X=556
Y=239
In BCD format: X = 0101 0101 0110
Y = 0010 0011 1001
As explained in binary adder/subtractor, if X > Y, the result = X+Y’+1. Thus, taking 1’s
complement of Y (as in normal binary subtraction) results in ‘New Y’. This ‘New Y’ is added to
X. If the ‘carry-out’ signal is ‘1’ that indicates X>Y, addition of ‘1’ is carried out. Then post-
correction is applied on this result to compute final BCD difference. The digit wise carry of ‘1’
85
5.3 A Unified BCD/Binary Adder/Subtractor Architecture
indicates that the digit is less than or equal to ‘9’ and hence no correction is required while the
digit wise carry of ‘0’ indicates the digit is greater than ‘9’ and a correction by subtraction of ‘6’
or addition of ‘10’ is needed [57].
86
5.3 A Unified BCD/Binary Adder/Subtractor Architecture
carry of ‘1’ indicates the digit is greater than ‘9’ and a correction by subtraction of ‘6’ or addition
of ‘10’ is needed [57].
No carry out, No
correction needed
From the examples 5.2 and 5.3, the post-correction is needed only when X >Y, and digit
wise carry-out is ‘0’ or when X ≤ Y and digit wise carry-out is ‘1’. In the proposed design, these
conditions are incorporated in the post-correction stage [57].
As seen in the examples 5.1, 5.2 and 5.3, the correction is carried out by adding (1010)2.
The optimized implementation of the pre-correction block (which implements the +6 circuit) and
the post correction block (which implements addition of (1010)2) is shown in Fig 5.13 (a) and (b)
respectively.
87
5.3 A Unified BCD/Binary Adder/Subtractor Architecture
(a) (b)
Figure 5.13 (a) Pre-correction block (b) Post Correction block for BCD
The control signal for the pre-correction circuit is given as
88
5.4 Simulations and Results
89
5.4 Simulations and Results
The proposed approach can also be extended to higher operand lengths leading to efficient
designs of unified BCD/Binary adder / subtractor architectures.
Table 5.2: Results for a 32-bit Unified BCD/Binary Adder/Subtractor
Humberto [53] Proposed
Delay (nS) 4.004 3.460
(100%) (86.4%)
Power (mW) 14.5 13.37
(100%) (92.2%)
Power-Delay (pJ) 58.06 46.26
(100%) (79.7%)
2
Area (um ) 12068 10498
(100%) (87%)
Area (um2)
12500
12000
11500
11000
Area (um2)
10500
10000
9500
Humberto [35] Proposed
90
5.4 Simulations and Results
Power (mW)
16
14
12
10
8
Power (mW)
6
4
2
0
Humberto [35] Proposed
Delay (nS)
4.1
4
3.9
3.8
3.7
3.6
Delay (nS)
3.5
3.4
3.3
3.2
3.1
Humberto [35] Proposed
91
5.5 Conclusions
Power‐Delay (pJ)
70
60
50
40
30 Power‐Delay (pJ)
20
10
0
Humberto [35] Proposed
5.5 Conclusions
In this chapter, efficient blocks for Binary and BCD arithmetic operations have been
proposed. Also a unified BCD/Binary adder /subtractor which can handle both signed as well as
unsigned numbers has been proposed and analyzed in detail. The results indicate that the
proposed designs are efficient in terms of area, power and power- delay product when compared
with those reported in literature.
92