Professional Documents
Culture Documents
Overflow Detector For Ripple Carry Adder
Overflow Detector For Ripple Carry Adder
Abstract
The following is our take on the assignment problems from Chapter 6, Questions 10 from Heuring.
Question 10
The objective of the question is to design an overow detector for the Ripple Carry Adder/Subtractor Cicuit as given
1.1 Assumptions
The underlying assumption made in this solution is that the 2 numbers X and Y are n-bit Signed integers.That is, the MSB in each number is used to indicate the sign of the number. An MSB of 1 indicates the number is negative. It is evident that the overow condition is dierent for addition and subtraction, given that the numbers are signed. For example adding 2 positive integers to give a negative one is overow. Subtraction a negative from a positive should yield a positive number, and when it gives a negative, it's overow. We need to decompose into Various cases and solve. There are 2 solution methods possible, both of which have been outlined here.
2
2.1
Method I
We need to look at possible cases for overow. This is done by considering the various possibilities of overow given the sign bits of the 2 input numbers.
If Xn1 = 0 and Yn1 = 0, it indicates we are trying to add 2 positive numbers, Overow can occur here if the result exceed integer range and goes negative, i.e if Sn1 = 1 If Xn1 = 0 and Yn1 = 1, or, Xn1 = 0 and Yn1 = 1 it indicates we are trying to add a positive number and a negative one. Overow can never occur here. If Xn1 = 1 and Yn1 = 1, it indicates we are trying to add 2 negative numbers, Overow can occur here if the result exceed integer range and goes positive, i.e if Sn1 = 0
OVr0 =0 = X n1 Y n1 Sn1 + Xn1 Yn1 S n1
2.2
Subtraction (r=1)
Again, we need to look at possible cases for overow. This is done by considering the various possibilities of overow given the sign bits of the 2 input numbers. These are as
If Xn1 = 0 and Yn1 = 0, it indicates we are trying to subtract a positive number number from a positive number. Overow can never occur here. Similarly, for Xn1 = 1 and Yn1 = 1, Overow never occurs. If Xn1 = 0 and Yn1 = 1, we are trying to subtract a negative number from a positive one. Naturally, we expect a positive result. But when the result exceeds the range, and goes negative, i.e Sn1 = 1, it indicates overow If Xn1 = 1 and Yn1 = 0, we are trying to subtract a positive number from a number one. Naturally, we expect a negative result. But when the result exceeds the range, and goes positive, i.e Sn1 = 0, it indicates overow
OVr0 =1 = X n1 Yn1 Sn1 + Xn1 Y n1 S n1
2.3
Combined Expression
Method II (Better)
In this method, we try to cleverly take the same overow conditions as given above, and try to reect those changes in the Carry Variables. Naturally, every full adder has a truth table dictated by input
2
variables and carry. Hence for a given input number and output sum, we can analyse what values of carry could have given rise to that combination. As above, we try to decompose into various cases. Here, we take yn1 = r Yn1 as the input to the Full adder.
3.1 Addition (r=0)
Now from our previous method, we already know which cases give rise to overow. Let us look at them again, but from a carry perspective. Here, yn1 = Yn1
When Xn1 = 0 and yn1 = Yn1 = 0, we know Sn1 = 1is the overow condition. The only way this can be achieved is if the Carry-in is 1, i.e Cn1 = 1. Looking at the Truth table of the Full-Adder, we see that Cn = 0 in this case. No other combination of inputs and outputs other than this one, gives Cn1 = 1 & Cn = 0. Hence this is an overow condition. When Xn1 = 1 and yn1 = Yn1 = 1, we know Sn1 = 0is the overow condition. The only way this can be achieved is if the Carry-in is 1, i.e Cn1 = 0. Reviewing the Truth Table, this amounts to Cn = 1. Again, this is unique. So this is an overow condition
OVr1 =0 = C n1 Cn + Cn1 C n = Cn1 Cn
3.2
Subtraction (r=1)
Again, let us consider the previous overow conditions. Here, yn1 = Y n1 . Note here that y is the input to the full adder at any instant of time, so that is the value that will have to be checked against the Truth Table
When Xn1 = 0 and Yn1 = 1, we know the Sn1 = 1is the overow condition. This again amounts to yn1 = 0. We see that the condition here is identical to the previous case, where Cn1 = 1 and Cn = 0 is the Overow condition. When Xn1 = 1 and Yn1 = 0, we know the Sn1 = 0is the overow condition. This again amounts to yn1 = 1. We see that the condition here is identical to the previous case, where Cn1 = 0 and Cn = 1 is the Overow condition.
We can easily see that the expression is identical in every aspect to the previous case. We can summarize the overow condition at r=1 as
OVr1 =1 = C n1 Cn + Cn1 C n = Cn1 Cn
3.3 Combined expression
We notice that the expression in both cases are the same, hence on nal value is independant of r. This makes sense, as for subtraction, the main purpose of r is to invert Y and make Cin = 1. This Cin = 1 ripples through, and takes care of the carry conditions, making the Overow condition identical to that of addition. Hence, the nal expression is
OV 1 = Cn1 Cn