Presentation is loading. Please wait.

Presentation is loading. Please wait.

Half Adder & Full Adder Patrick Marshall. Intro Adding binary digits Half adder Full adder Parallel adder (ripple carry) Arithmetic overflow.

Similar presentations


Presentation on theme: "Half Adder & Full Adder Patrick Marshall. Intro Adding binary digits Half adder Full adder Parallel adder (ripple carry) Arithmetic overflow."— Presentation transcript:

1 Half Adder & Full Adder Patrick Marshall

2 Intro Adding binary digits Half adder Full adder Parallel adder (ripple carry) Arithmetic overflow

3 Adding Binary Numbers 10110 - 22 00110 - 6 11100 - 28 0 + 0 = 0 0 + 1 = 1 1 + 0 = 1 1 + 1 = 10 A key requirement of digital computers is the ability to use logical functions to perform arithmetic operations. How do we add two binary numbers? Let's start by adding two binary bits. Since each bit has only two possible values, 0 or 1, there are only four possible combinations of inputs. These four possibilities, and the resulting sums, are:

4 Truth table for 2 bit binary addition InputsOutputs ABCarrySum 00110011 01010101 00010001 01100110 Carry = A.BSum = A.B + A.B

5 One possible implementation Note: The Half adder is sometimes drawn using a XOR gate to derive the sum. This is a common alternative to the circuit above which performs the same logic

6 Half adder HA A B Cout S It would be tedious to draw the full implementation of the half adder each time it appeared in a more complex circuit, so we commonly draw it as a box, showing the inputs and the outputs.

7 Adding groups of digits In digital circuits we usually have to add groups of bits together, rather than simply one bit to one bit as shown in the half adder. If multiple bit number representations, like 100110 are to be added to 00110 for each digit additions we must take into account carry bits from previous steps of the process. In other words we need a circuit which will do the full job of multiple bit binary addition. The half adder is so called because it performs ‘half’ the job of binary addition. 10110 = 22 decimal 00110 = 6 decimal 11100 = 28 decimal 0 + 0 + 0 = 0 1 + 0 + 0 = 1 1 + 1 + 0 = 10 1 + 1 + 1 = 11

8 Full adder using half Adders Cin HA A B HA S2S2 C out We can implement a full adder circuit using two half adders. Inputs A and B are added together using the first HA, with the resultant Sum bit been added with the Carry in (from previous bit additions) using the second HA. The sum bit of this second adder is the true sum with the true carry been generated if either of the half adder stages generated a carry C 1 S 1 C2C2

9 Implementing the Full adder circuit A B C in SumC out 00000 00110 01010 01101 10010 10101 11001 11111 This adder can be considered a three input adder. Two inputs, A&B, from the bits of the numbers we are adding and one bit, Cin, is from additions of previous bits Sum = ABC + ABC + ABC + ABC Cout = ABC + ABC + ABC +ABC

10 Full adder Cout = ABC + ABC + ABC +ABC Cout = AB + AC + BC AB C 00011110 01 1111

11 Full adder circuits

12 Full adder shorthand FA A B Cin Cout S There are many other ways to implement a Full adder circuit, using Nor gates only, using Nand gates only, using Xor gates. In many cases the implementation details are unimportant, so we can use the shorthand representation shown to the left. The important thing to note is that the full adder has three inputs (A B and Carry in) and two outputs (Carry out and Sum)

13 Adding mulitple bits We have seen how to add two binary digits using the half adder, we have seen how to add add two binary digits and a carry digit from a previous stage using the full adder. These operations are not terribly useful as generally we need to add large numbers together which are represented by multiple binary digits. We will now look at a way to achieve this using a parallel full adder.

14 Parallel Full Adder A parrallel adder adds all the bits the binary numbers in a single operation. One such adder is known as the ripple carry adder

15 Ripple Carry adder The first stage can calculate it’s Sum and Carry as soon as the input A0 and B0 are valid. The second stage must wait for the first stage to complete it’s job before it’s output is valid.Likewise the third stage must wait for the outputs of both the first and second stage to be valid. The carry bit ripples through all the stages. This is why this circuit is known as the ripple carry adder.The length of time taken to add the two numbers is proportional to the number of bits in the number.

16 Notes on Ripple Carry adder Setting the “Carry in to 1 st Stage” to a ‘1’ to generate A+B+1. If input B were zero the circuit would function as an incrementor. This also is handy when applying complimentary arithmetic. The Carry out bit can be used to determine if arithmetic overflow has occurred. Overflow occurs when the resulting value of an operation performed on valid representations of numbers is out of the range of valid values. That is, the resulting value is greater than max or less than min. It is possible to reduce partially the effect of the ripple-through carry by creating what are called “carry look ahead circuits”. That is the carry out to stage 5 can be calculated by inspecting the inputs to 4, 3, 2 and 1. This high speed circuit avoids the delays experience if a ripple through carry circuit.

17 Arithmetic overflow Consider 4 bit two’s complement additions, so the valid decimal range is from –8 to +7 0100 = 4 +0010 = 2 0110 = 6 1100 = -4 +1110 = -2 11110 = -2 0111 = 7 +0011 = 3 1010 = -6 1000 = -8 +1100 = -4 10100 = +4 The first two sum are fine, but there’s something funny with 7 + 3 = -6 and –8 – 4 = +4

18 Arithmetic Overflow Overflow occurs if the result of adding two positive numbers yields a negative result or if the adding of two negative numbers result in a positive result. If the sign bits of the two numbers are the same but the sign bit of the result is different then arithmetic overflow has occurred. Overflow (V) = A sign.B sign.Sum sign or A sign.B sign.Sum sign

19 Summary Adding binary digits Half adder Full adder Parallel adder (ripple carry) Arithmetic overflow


Download ppt "Half Adder & Full Adder Patrick Marshall. Intro Adding binary digits Half adder Full adder Parallel adder (ripple carry) Arithmetic overflow."

Similar presentations


Ads by Google