## Topics of Discussion

1. Definitions and Overview of adder

## Definitions and Overview

An adder is a device which add up two numbers and produce the result. A binary adder is something which deals with addition of binary numbers.

A binary adder is a digital device and needed for digital computations. The operation performed in a binary adder, obeys the rules of binary addition. Here two bits corresponding to 2n are added and the resultant is then added to the carry from the 2n-1 digit.

The binary addition rules are stated as follow. Here 0 is logic low and 1 is logic high. A and B are two inputs.

1. 11111 + 1011 + 101 + 10 + 1

11111

+ 1011

= 101010

101010

+    101

= 101111

110001

+       1

= 110010

This addition operation is implemented by various digital circuitries. They are –

A binary adder not only performs addition operations but also used in other digital applications. Decoding of address, calculation of index are few of its applications.

A half adder is a type of binary adder which add one bit of data and produces the result. It has two input side through which we supply the digital logic values and it has two outputs through which we receive the result of the operation. The result can be shown in a single digit. The output shows the digit in the sum that has the same significance as the individual digits added. The other output shows the carry bit.

The operation of the half adder is shown in the following truth table.

Now from the truth table, we can observe that the first three rows can represent the sum using a single digit. At the last row, the sum is represented using two digits as it has 1 as carry. Here the sum is zero and carry 1 must be taken to the position of next higher significance.

Sum = A′ B + A B′

Carry = AB

So,

Sum = A XOR B

Carry = A AND B

To implement the logic, we need one XOR gate and one AND gate. XOR gate and AND gate can also be made using universal gates like NAND and NOR. So, a half adder can be designed using only universal gates.

The following image shows A and B as the input and S as the sum and C as the carry.

Another type of binary adder is full adder. It also adds binary data and produces the output. Now, when two binary numbers are added, except the least significant digit there is a carry-in as Ci-1 and carry-out as Ci. The full adder is designed to handle a carry-in for each stage. That is how a full order overcomes the shortcoming of half adder of handling carry-in.

Si = Ai Bi Ci-1 + Ai Bi Ci-1 + Ai Bi Ci-1 + Ai Bi Ci-1 + (Ai Bi + Ai Bi) Ci-1   + (Ai Bi + Ai Bi) Ci-1

And the carry comes as:

Ci = Ai Bi Ci-1 + Ai Bi Ci-1 + Ai Bi Ci-1 + Ai Bi Ci-1

Or, Ci = (Ai Bi + Ai Bi) Ci-1   + (Ai Bi + Ai Bi) Ci-1

Or, Ci = Ai Bi + (Ai Bi + Ai Bi) Ci-1

Now, consider a half adder has inputs A and B. The output sum is S and carry is C. Now the expression of Si and Ci can be obtained from the expressions of Sum and carry of half adder circuit.

Si = S Ci-1 + S Ci-1

Ci = C + S Ci-1

Now, to implement a full adder using half adders we need two half adders and one OR gate. Full adder implementations using half adders is represented in the below figure.

As we can see in the figure that the first half adder (marked as-) has the input Ai and Bi. The second half adder (marked as-) has inputs of C i-1 and output of the first half adder that is S. The output of the second half adder are Si and S Ci-1.

Now, S Ci-1 represents the carry out. The carry of the first half adder that is C and the carry of the second half adder that is S Ci-1 are fed as input of a OR gate. The output of the OR gate is the final carry out of the full adder circuit.

Let us add 101 and 111 as an example of parallel binary adder. The figure shown below represents the addition.

The first half adder (marked as-1) adds the extreme right-hand bits 1 and 1 to produce the binary sum 0 and the carry 1 according to the rules of binary addition. The output of the half adder is fed into the input of the first full adder (marked as- 2). The other two inputs of first full adder are the two next bits that is 0 and 1. The outputs of the first full adder are 0 as sum and 1 as carry. They are further fed into input of second full adder. The other two inputs are 1 and 1. The outputs of the second full adder is 1 as sum and 1 as carry. So, the result of the summation is 1100.

Now, a point to be noted that in place of a half adder at the least significant digit position, a full adder can be used with its carry input made 0.

The term BCD in BCD adder stand for Binary Coded Decimal. BCD is a special type of binary encoding where each digit has certain number of bits for representation. The BCD of first 10 decimal value is shown in the table.

BCD adder has two inputs which varies from 0 to 9. The output varies from 0 to 18 and if the previous carry is considered then the range will be up to 19.

### The table for BCD adder is given below.

From the above table, we can observe that from 1 to 9 the binary and the BCD is same. From 10 to 19 decimal numbers, both the binary and codes are different.

### The circuit diagram of a BCD adder is shown below.

• In the above diagram there is a four-bit binary adder which has input as addended and augend. It has also input of carry.
• The binary adder gives output of the addition and an carry output.
• Now, using the output and the carry the circuit is further designed to find out the final carry.
• The output is further fed into a 4-bit adder.
• Now, the circuit is designed to make the 1st and 4th bit of the addended number as 0 and also the 2nd and 3rd bit to make as same as Carry. When the carry is 1, the circuit is designed in such a way that the addended will be 0110. 6 is added with augend to get the BCD.

### Example of BCD

0110 + 0101

0110

+ 0101

= 1011

Now this is invalid as BCD. The number is greater than 9. So, we have to add 6 to the result.

The final result will be = 1011 + 0110 =

1011

+ 0110

= 10001

So the final answer will be 10001

library IEEE ;

use IEEE.std_logic_1164.all ;

Port ( a : in  STD_LOGIC;

b : in  STD_LOGIC;

s : out  STD_LOGIC;

c : out  STD_LOGIC);

begin

s <= a XOR b;

c <= a AND b;

end Behavioral;

Port ( A : in  STD_LOGIC;

B : in  STD_LOGIC;

C : out  STD_LOGIC;

S : out  STD_LOGIC;

Z : out  STD_LOGIC);

begin

process(A, B)

begin

if(A=’0′ and B=’0′) then

S <=’0′;

C <=’0′;

elsif(A=’0′ and B=’1′) then

S <=’1′;

C<=’0′;

elsif(A=’1′ and B=’0′) then

S <=’0′;

C<=’1′;

else

S <=’1′;

C<=’1′;

end if;

end process;

end Behavioral;

library IEEE;

use IEEE.STD_LOGIC_1164.ALL;

Port ( A : in  STD_LOGIC;

B : in  STD_LOGIC;

Cin : in  STD_LOGIC;

S : out  STD_LOGIC;

Car : out  STD_LOGIC);

begin

S<=(A xor B) xor Cin;

Car<=( A and B) or (B and Cin) or (Cin and A);

end Dataflow;

Port ( A : in  STD_LOGIC;

B : in  STD_LOGIC;

Cin : in  STD_LOGIC;

S : out  STD_LOGIC;

Car : out  STD_LOGIC);

begin

process(A,B,Cin)

begin

if(A=’0′ and B=’0′ and Cin=’0′) then

S<=’0′;

Car<=’0′;

elsif(A=’0′ and B=’0′ and Cin=’1′) then

S<=’1′;

Car<=’0′;

elsif(A=’0′ and B=’1′ and Cin=’0′) then

S<=’1′;

Car<=’0′;

elsif(A=’0′ and B=’1′ and Cin=’1′) then

S<=’0′;

Car<=’1′;

elsif(A=’1′ and B=’0′ and Cin=’0′) then

S<=’1′;

Car<=’0′;

elsif(A=’1′ and B=’0′ and Cin=’1′) then

S<=’0′;

Car<=’1′;

elsif(A=’1′ and B=’1′ and Cin=’0′) then

S<=’0′;

Car<=’1′;

else

S<=’1′;

Car<=’1′;

end if;

end process;

end Behavioral;