Arithmetic Circuits
Adders and Arithmetic Circuits
Adders and arithmetic circuits perform arithmetic directly on binary words. You encounter them in processors, address generators, and digital measurement systems. Their basic building block handles one bit position; connecting several blocks lets you add or subtract whole words. To interpret the output correctly, keep the stored result separate from the carry, borrow, and signed-overflow information.
Adding one bit position
A half-adder adds two input bits, A and B. Its sum output is S=A⊕B, and its carry output is C=AB. Here, ⊕ means exclusive OR, multiplication means AND, and + in a Boolean expression means OR. A half-adder has no input for a carry from a lower bit position.
A full-adder adds three bits: two operand bits and an incoming carry. For bit position i, its outputs satisfy
The sum is 1 when an odd number of inputs are 1. The outgoing carry is 1 when at least two inputs are 1. As ordinary numerical values, these outputs obey Ai+Bi+Ci=Si+2Ci+1. The carry represents two units at the current bit position, or one unit at the next position.
Connecting a word-wide adder
An n-bit ripple-carry adder connects each full-adder's carry output to the next stage's carry input. Bit 0 is the least significant bit. Its carry travels toward bit n−1, the most significant bit.
For unsigned operands, the governing arithmetic identity is
Here, S is the unsigned value of the n stored sum bits. Ordinary addition uses C0=0. If the exact result exceeds 2n−1, the stored word wraps around modulo 2n, while Cn records the extra carry.
Carries take time to propagate. In a simplified delay model with carry delay tc per stage and sum delay ts from a stage input, the longest path to the highest sum bit is (n−1)tc+ts. The final carry path is ntc. These expressions assume all operand inputs and the initial carry are available together; additional input-conditioning delays require separate treatment.
Sharing hardware for subtraction
Two's-complement subtraction reuses addition:
The complement B reverses exactly the n bits of B. A mode bit M controls an XOR gate on every B input and also supplies the initial carry:
Mode M | Effective second operand | Initial carry | Operation |
|---|---|---|---|
0 | B | 0 | A+B |
1 | B | 1 | A−B |
For unsigned subtraction implemented this way, this lesson uses the carry means no borrow convention: Cn=1 means no borrow, and the borrow flag is 1−Cn. Some systems expose a borrow flag directly, so identify the convention before interpreting a status bit.
Interpreting signed results
An n-bit two's-complement word represents values from −2n−1 to 2n−1−1. Signed overflow occurs when the exact signed result lies outside that range. It is different from an unsigned carry.
For the adder, including subtraction through the complemented input, the overflow flag is
For addition, two operands with the same sign overflow if the stored result has the opposite sign. Operands with opposite signs do not overflow. The same output bits can therefore indicate unsigned carry without signed overflow, or signed overflow without unsigned carry.
What to remember
- A full-adder combines two operand bits and an incoming carry.
- Ripple-carry stages pass carries toward more significant bits.
- Subtraction requires both complementing B and setting C0=1.
- Unsigned carry, unsigned borrow, and signed overflow describe different conditions.
Example: A four-bit arithmetic unit
A small controller uses a four-bit ripple-carry arithmetic unit. Its operand words are A=01102 and B=00112. Mode M sets the effective second operand to Xi=Bi⊕M and the initial carry to C0=M. The unit stores four sum bits and reports final carry C4 and signed-overflow flag V=C3⊕C4.
a) For M=0, find the stored result, final carry, and signed-overflow flag. Interpret the result as both unsigned and two's complement.
Mode 0 passes B unchanged and sets C0=0. Work from the least significant bit upward. Each ordinary bit total Ai+Xi+Ci equals Si+2Ci+1.
- Bit 0: A0+X0+C0=0+1+0=1, so S0=1 and C1=0.
- Bit 1: A1+X1+C1=1+1+0=2, so S1=0 and C2=1.
- Bit 2: A2+X2+C2=1+0+1=2, so S2=0 and C3=1.
- Bit 3: A3+X3+C3=0+0+1=1, so S3=1 and C4=0.
Reading the sum from bit 3 down to bit 0 gives S=10012, with C4=0. The carry into the sign bit is C3=1, so
Unsigned interpretation gives 6+3=9, which fits the four-bit unsigned range. Two's-complement interpretation also starts with +6 and +3, but their exact sum +9 exceeds the signed maximum of +7. The stored word represents 9−16=−7, so it is not the correct signed sum. The outputs are S=10012, C4=0, and V=1.
b) For M=1, find the stored difference, final carry, unsigned borrow flag, and signed-overflow flag. Use borrow flag =1−C4.
Mode 1 complements every bit of B and supplies the initial carry:
Now trace the subtraction through the same full-adders.
- Bit 0: A0+X0+C0=0+0+1=1, so S0=1 and C1=0.
- Bit 1: A1+X1+C1=1+0+0=1, so S1=1 and C2=0.
- Bit 2: A2+X2+C2=1+1+0=2, so S2=0 and C3=1.
- Bit 3: A3+X3+C3=0+1+1=2, so S3=0 and C4=1.
Equivalently, the complete addition is
The stored low four bits are 00112=3, and the final carry is C4=1. Therefore,
The numerical check is 6−3=3. No unsigned borrow is needed, and the signed result fits the range −8 to 7. The outputs are S=00112, C4=1, borrow flag 0, and V=0.
c) Each full-adder has a worst-case carry-output delay of 1.5 ns and sum-output delay of 2.0 ns from any of its inputs. All effective operand inputs and C0 are stable at t=0. Using an additive worst-case delay model, find when all sum bits and the final carry are guaranteed stable for any input transition. Exclude XOR input-conditioning delays and assume the worst-case carry path can be sensitized.
The final carry passes through ________ carry-output delays:
The highest sum bit first waits for ________ carry stages, then takes the final stage's sum delay:
Lower sum bits have fewer preceding carry stages. Consequently, the guarantee for all requested outputs is the larger of these two delays:
The highest sum bit determines the 6.5 ns bound under the stated model. This is a worst-case guarantee over input transitions, rather than a claim that every operation takes exactly that long.
In an unsigned binary multiplier, a partial product is the row formed from one multiplier bit and all the multiplicand bits. Complete the two missing operations below.
Each bit in a row is produced by an gate receiving one multiplicand bit and the selected multiplier bit. The row associated with multiplier bit j is shifted by j positions before the rows are added. Here, bit index zero denotes the least significant bit, and enough output bits are retained to prevent truncation.
A four-bit arithmetic unit subtracts the unsigned word B=10012 from the unsigned word A=00112. It computes A+B+1, stores only the four low result bits, and defines its borrow flag as 1−C4, where C4 is the final carry. Which stored result and borrow flag are correct?