Special purpose adders |
Special purpose adders |
Some arithmetic algorithms can be realized with only one modified adder. For example :
The cost and the delay are similar to a fast adder's ones. |
The special purpose adders of this page are built around the Sklansky's adder, which is recalled here for convenience of comparison. |
The "BK" cells outputs are either 'P', 'G' or 'K', nevertheless a carry ci is never 'P' because in this applet the "HA" cell at the right is modified in order to exclude 'P'. |
Adders spontaneously calculate the addition modulo 2n. To get the opposite -B of a number B, all the
bits are logically complemented and a 1 is added. The addition of B with -B obtained in this way gives 2n
that is 0. The input carry c0 of an adder is used to add the bit a/s and disjunction gate to complement B. This "operations box" executes addition if a/s = '0' and subtraction if a/s = '1'. |
Just like the adder, the adder/subtractor may overflow, but it may as well underflow. If the last carry cn and of the carry cn-1 differ, then the output S is incorrect :
|
Comparison of signed integers |
After a subtraction S = A – B, the sign of S indicates A ³ B or otherwise A < B. A slight modification of the adder/subtractor wiring allows the output carry cn to indicate A < B, A = B or A > B; necessary for comparisons. This indication is only valid with subtraction. |
In order to compare A and B, it not necessary to compute the difference A – B. Only the sign of A – B is needed, that is the carry out. This comparator is simpler (less "BK") therefore faster (less fan-out) than a complete subtractor. A multiplexors row selects the max. |
If the carry in c0 of an adder S = A + B + c0 is ready later than the inputs A and B, a carry-late adder is appropriate. The delay between input c0 and outputs S is small and independent of the number of bits. |
On the contrary, if the carry in c0 is ready as soon as the inputs A and B, then the approach used in the above described adder/subtractor would be more efficient because requesting less "BK" cells. |
To design this adder S = A + B + c0 first the output are duplicated. Then for the output S the value 0 is substituted to c0 and the value 1 is substituted to c0 for the output S'. The obtained adder calculates simultaneously S = A + B and S' = A + B + 1 . |
The output of the "BK" is either 'P', 'G' or 'K', and the carry ci must be '0' or '1'.
|
We want to calculate S = A + B, S' = A + B + 1 and S" = A + B + 2. To get S and S" we calculate beforehand without carry propagation two numbers X and Y such that X + Y = A + B. In that way we get the least significant bits s0 and s"0. Then the n-1 most significant bits of X and Y are added with the preceding two-output adder . |
Where is the third output S' = A + B + 1 ? The calculation of S' from S and S", either S' = S + 1 or S' = S" – 1, only claims one inverter and some 2-input multiplexers.
|
In much the same way as above, a two-output adder can calculate S = A + B – 1, S' = A + B and S" = A + B + 1 by calculating two numbers X and Y such that X + Y = A + B + 2n – 1 with a row of HA' cells, dual of the HA cell. An extra inverter deals with the 2n . |
With four slight modifications, Sklansky's adder with a late carry-in returns S = ½ A – B ½.
|
An adder delivers spontaneously a modulo 2n sum. With a slight modification, the Sklansky's adder with a late carry-in delivers a modulo 2n – 1 sum S.
In both cases we get S = ½ A + B ½ modulo
(2n– 1). |
The previous adder is used with two inputs X and Y such that X + Y = A + B + 2n – 1. A row of HA' cells carries on this addition propagation-free.
The horizontal "feed-back" signal that controls the "+1" is the "nand" of xn and (cn = 'G' ). The result bit sn is the "and" of xn and (cn = 'P'). |
The inserstion of multiplexors within the adder deals with some specific cases overlooked in the adder above. if A = 2n et B = 2n then A + B modulo 2n – 1 = 1. if A = 2n et B < 2n then A + B modulo 2n – 1 = B complemented + 2. if A < 2n et B = 2n then A + B modulo 2n – 1 = A complemented + 2. |