Adders
In questa pagina 5
In questa pagina 4
The adder is the fundamental circuit of an arithmetic-logic unit (Arithmetic Logic UnitRole of the ALU, its inputs and the N Z C V flags, the 1-bit ALU built from AND, OR, a full adder and a multiplexer, the N-bit ALU with subtraction, NOR, set-less-than, zero and overflow detection, comparators, bus sharing with tri-state outputs, and the other computation units.Arithmetic Logic Unit →): subtraction, comparison and address computation all reuse it (Binary ArithmeticBinary addition and two's complement subtraction, overflow for unsigned (carry) and signed (sign change) numbers, the N Z C V flags, multiplication by shifts and additions, Booth's algorithm with a worked example, division, and logical, arithmetic and rotate shifts.Binary Arithmetic →).
Half adder and full adder
The sum of two bits gives a sum bit and a carry : , , . A half adder has , . To add multi-bit numbers each position must also add the carry from the previous one: three bits , , give and .
| 0 | 0 | 0 | 0 | 0 |
| 0 | 0 | 1 | 1 | 0 |
| 0 | 1 | 0 | 1 | 0 |
| 0 | 1 | 1 | 0 | 1 |
| 1 | 0 | 0 | 1 | 0 |
| 1 | 0 | 1 | 0 | 1 |
| 1 | 1 | 0 | 0 | 1 |
| 1 | 1 | 1 | 1 | 1 |
Formula (full adder).
The carry is the majority function: it is when at least two inputs are . Example: gives , .
Definition (generate, propagate, delete).
- generate : the stage produces a carry of regardless of ;
- propagate (or for the carry): the stage passes on;
- delete : the stage kills the carry (output whatever ).
Then
and depend only on , (set-up phase); only and depend on (carry/sum phase).
Ripple-carry adder
Formula (ripple-carry delay, worst case). full adders in cascade, . With the carry delay () and the sum delay () of one full adder, and : in the worst case (all , the carry crosses all stages) the last bit waits carry delays: and if set-up is counted.
Numerical example. ps, ps: : ps; : ps; : ps. Doubling roughly doubles the delay. It is the simplest and most compact adder, but slow.
Data-dependent delay. The carry out of stage is available after if the stage is generate or delete, and after plus the previous stage's time if it is propagate. A generate or delete breaks the chain; the total delay is plus times the longest chain (a generate or delete followed by consecutive propagates).
Example. Stages with : P, P, G, D. Stage resets the chain, so . If everywhere, every stage is G or D and .
Adding two -bit numbers needs bits (the final carry). In two's complement overflow is (carry into and out of the last stage).
Adder-subtractor
Property (adder-subtractor). One adder also subtracts in two's complement: each bit of goes through an XOR with a signal , which is also the initial carry .
- : , , result .
- : , , result .
Example (4 bits, ): .
Fast adders
Fast structures keep the same full adder but shorten the critical carry path with extra logic. Notation: , (per stage), , .
Carry-lookahead
Definition (carry lookahead). With and the carries are computed directly from the inputs:
More gates, but delay growing roughly as (prefix adders such as Kogge-Stone combine G and P of bit groups in ). In FPGAs a dedicated carry chain does the same job with a fast physical path.
Carry-bypass (carry-skip)
The bits are divided into blocks of . In each block compute . If all propagates are , the block's carry out equals its carry in: a multiplexer driven by makes the carry skip the block.
Formula (carry-bypass delay and optimal block size). Worst case: the carry is generated at the first stage of the first block and crosses it (), skips the following blocks through multiplexers, then crosses stages of the last block:
Example. , all delays : and . The delay is dominated by the carry time (), since set-up and sum appear once.
Carry-select
In each block (except the first) sums and carries are computed twice, assuming carry in and . When the true carry from the previous block arrives, a multiplexer selects the right result. Both computations run in parallel with the previous block's carry.
Formula (linear carry-select). Blocks of bits, blocks:
Example. , , all delays : . Cost: about twice the full adders, plus multiplexers.
Square-root carry-select
In the linear version, block waits for the carry of block , which arrives one multiplexer later: meanwhile it has already finished its two alternatives. So each block can have one more bit than the previous one. Blocks of bits:
Formula (square-root carry-select).
Example. , : blocks ( bits), , . Delay grows as . If the blocks grow by bits at a time.
Comparison
With :
| ripple | carry-bypass | linear select | square-root select | |
|---|---|---|---|---|
| 16 | ||||
| 32 | ||||
| 64 |
The advantage of variable-block structures grows with ; the price is area (select structures duplicate full adders) and routing complexity.
Common mistakes
- Using or instead of : the sum is computed once, at the end.
- Treating the worst-case delay as valid for every pair of operands.
- Forgetting that a generate or delete stage interrupts the carry chain; confusing propagate () with generate ().
- Counting multiplexers wrongly: for bypass, for select.
- Using the bypass (with the factor ) for carry-select, or equal blocks in the square-root select.
- Forgetting in subtraction ( alone is wrong).
Versione ripasso
Full adder
, (majority). Half adder: , . With generate , propagate , delete : , . , do not depend on (set-up).
Ripple-carry
full adders in cascade. Worst case (all ): , linear in . Example , ps: gives ps. A G or D stage cuts the chain; delay (longest G/D-then-P chain). Equal operands: . Result needs bits; overflow .
Adder-subtractor
XOR on each driven by SUB, SUB also : . Example: .
Fast adders
- Lookahead: , ; delay about .
- Carry-bypass: blocks of , skips the block through a mux. , . : .
- Linear carry-select: two results per block (carry in 0 and 1), mux selects. , . , : .
- Square-root select: blocks ; , . , : .
| ripple | bypass | select | sqrt | |
|---|---|---|---|---|
| 16 | ||||
| 32 | ||||
| 64 |
Common mistakes: instead of ; worst case taken as typical; forgetting that G/D break the chain; without ; bypass used for select.