How to build an 8-bit adder, with carry and overflow flags
An 8-bit adder chains eight full adders, each passing its carry to the next, so it adds two bytes plus a carry-in and outputs an 8-bit sum and a carry-out. This live one also has the signed overflow flag V = c7 XOR c8, which is 1 when two's complement numbers add to a result outside -128 to 127.
Each full adder adds one bit position: A_i, B_i and the carry from the bit below. The same circuit adds unsigned numbers (0 to 255) and signed two's complement numbers (-128 to 127); only the reading of the result changes, and so does the flag that says it went wrong. For unsigned numbers that flag is the carry-out: 200 + 100 = 300 does not fit, Cout = 1 and S = 44. For signed numbers it is overflow, which happens when the carry into the sign bit differs from the carry out of it, so one XOR gate computes it: 100 + 50 = 150 fits as unsigned but is out of range as signed, so V = 1 and S reads as -106. A CPU's status register keeps both flags because the hardware cannot know which reading the program means; see carry vs overflow. Each full adder here is a saved part built from the full adder circuit; for the 4-bit version gate by gate, see the ripple-carry adder. Eight edge cases and 300 seeded random sums are checked, every sum bit, Cout and V, before the page is built.
Open this circuit in the lab →
What you need
- 8× full adder: one per bit, carry rippling from Cin through bit 7 to Cout
- 1× XOR: overflow V = c7 XOR c8 (carry into and out of the sign bit)
Step by step
- Place inputs
A7toA0,B7toB0andCin, and probesS7toS0,CoutandV. - Place eight full adders in a row; wire
A_iandB_iinto adder i and its sum toS_i. - Chain the carries: Cin into adder 0, each Cout into the next adder's Cin, and the last Cout to the
Coutprobe. - Overflow: XOR the carry into adder 7 with the carry out of it and send it to
V. - Try 0111 1111 + 0000 0001 (127 + 1): S = 1000 0000, Cout = 0 and V = 1, because the signed answer 128 does not fit and reads as -128.
Carry and overflow examples
| A | B | S | Unsigned | Signed | Cout | V |
|---|---|---|---|---|---|---|
| 0110 0100 | 0011 0010 | 1001 0110 | 100 + 50 = 150 | 100 + 50 = -106 (overflow) | 0 | 1 |
| 1100 1000 | 0110 0100 | 0010 1100 | 200 + 100 = 44 (wrapped) | -56 + 100 = 44 | 1 | 0 |
| 0111 1111 | 0000 0001 | 1000 0000 | 127 + 1 = 128 | 127 + 1 = -128 (overflow) | 0 | 1 |
| 1111 1111 | 0000 0001 | 0000 0000 | 255 + 1 = 0 (wrapped) | -1 + 1 = 0 | 1 | 0 |
| 1000 0000 | 1000 0000 | 0000 0000 | 128 + 128 = 0 (wrapped) | -128 + -128 = 0 (overflow) | 1 | 1 |
| 0100 0000 | 0010 0000 | 0110 0000 | 64 + 32 = 96 | 64 + 32 = 96 | 0 | 0 |
Carry and overflow are independent: 255 + 1 sets the carry but not overflow (-1 + 1 = 0 is fine as signed), 127 + 1 sets overflow but not the carry, and 128 + 128 sets both.
You can also read the full theory in the lesson on the 8-bit adder. Prefer to build it yourself from scratch? Open the digiwleea lab and place the gates on the canvas, or start from the logic gate simulator.
Build more parts from gates
Each of these is one step from a transistor to a working CPU. Build every gate from CMOS transistors and work all the way up in the free digiwleea lab, with the free theory reference alongside.
Open the 8-bit adder in the lab →Frequently asked
How do you make an 8-bit adder?
Chain eight full adders: each adds A_i, B_i and the carry from the bit below, outputs the sum bit S_i, and passes its carry-out to the next adder. The first carry-in is Cin (0 for plain addition) and the last carry-out is Cout.
How many full adders are in an 8-bit adder?
Eight, one per bit. If the lowest bit never needs a carry-in, it can be a half adder, but keeping a full adder there lets Cin chain adders together or turn the adder into a subtractor.
What is the overflow flag in an 8-bit adder?
V = 1 when adding two's complement numbers gives a result outside -128 to 127. It equals the carry into bit 7 XOR the carry out of bit 7; equivalently, it is 1 when both inputs have the same sign and the sum has the other sign.
What is the difference between carry and overflow?
Carry-out reports that an unsigned result did not fit in 8 bits; overflow reports that a signed result did not fit. 255 + 1 carries without overflow, 127 + 1 overflows without a carry.
How do you make an 8-bit adder from two 4-bit adders?
Connect the carry-out of the low 4-bit adder (bits 0 to 3) to the carry-in of the high one (bits 4 to 7). That is exactly the same ripple chain as eight full adders in a row.