Back

Half adders

Introduction
Computers need to be able to do maths on numbers. We are going to look at the logic in a circuit diagram that can add up bits. Before we look at the circuit, however, we need to understand how bits are added together and the role of the carry bit.

We are going to add two binary numbers. We start at the least significant end of the number, the right hand side. 
sum1

 

 

 

 

 


The sum of 0 + 1 is clearly 1 but what is the carry? In this case, you might think there isn't one but when we are designing hardware, if we decide there has to be a carry, then we always need to have one, even if it is 0, as in this case. We shall therefore carry 0 and show this in a bracket in the next column at the top, like this:

sum2

 

 

 

 

 

 

Now we can add the next column. 0 + 1 + 1 is 10 in binary. The sum part of the addition is a 0 this time, but we had to move a 1 into the next column. This is the carry. If you are confused about this, think about when you add two denary numbers together. If you add 6 and 8, for example, the answer is 4 carry 1 or 14. We can show the answer to our binary addition like this:

sum3

 

 

 

 

 

 

1 + 1 + 0 is 10 in binary. The sum part of the addition is a 0 again, and the carry is a 1 again. We can show that like this:

sum4

 

 

 

 

 

 

Now we have 1 + 1 + 1 which is 11 in binary. The sum part of the addition is a 1, and the carry is a 1. We can show that like this:

sum5

 

 

 

 

 

 

This time, as we have come to the end of the number, we will put the carry in a bracket just to the left of the answer. If you convert the original two numbers into denary, you can see that the sum was 14 plus 11, and the answer was 25, which is the same as the answer in binary if you include the carry bit as well. Generally speaking, if we have two binary numbers, each of which is X bits long, then the answer is either X bits long without a carry bit, or X+1 bits long if you include the carry bit.

halfaddertruthtableThe half adder
The first thing to notice is that we are adding up bits in columns. We started by adding just 2 bits, but then we had to add 3 bits together. Suppose we had to add 35 bits together or 400 bits - we would quickly have a very complicated logic diagram. It makes sense to design a circuit that adds just 2 bits together, and then just have lots of them if we need to add more than two bits.

Our circuit will therefore have just two inputs, one for each bit we are going to add. We'll call these A and B. It will also have two outputs, one for the sum (S) and one for the carry (C). This circuit is known as the half adder.

 

 

The truth table for the half adder is shown in the table. If you look at it carefully, you might notice a couple of very interesting things!

1) The first thing is that the carry has an identical truth table to an AND gate. Both inputs must be a 1 for the output to be a 1, otherwise the output is a 0.
2) The second interesting thing is that the truth table for the sum is the same as the truth table for XOR. Both inputs must be different for the output to be a 1, otherwise the output is a 0. 

Armed with these two observations, we can now design a logic diagram for a half adder!

halfadder

We will need two logic gates, an XOR and an AND gate. We need to connect them up as shown in the diagram. We then have 2 bits as inputs, called A and B. Both of these signals are fed into the two gates that make up the half adder circuit at the same time. The XOR gate will tell you what the sum of the two bits is whilst the AND gate will tell you what the carry is. 

It is possible to construct a half adder using other combinations of gates. For example, you could make one out of just NAND gates or just NOR gates. If you are confident you understand the logic behind a half adder as explained here, you could use Google to find some of the alternative designs!  

 

Back