Sub topic 6
Half Adders, Full Adders and Subtractors
Prerequisites and the basic idea
Assume you know binary addition, Boolean algebra, and the AND, OR, and XOR gates. A combinational circuit produces outputs from the current inputs only. Adders and subtractors are combinational circuits used inside arithmetic logic units and processors.
A half adder adds two one-bit inputs, \(A\) and \(B\). It produces:
- Sum: \(S = A \oplus B\)
- Carry: \(C = A \cdot B\)
The carry is 1 only when both input bits are 1.
| A | B | S | C |
|---|---|---|---|
| 0 | 0 | 0 | 0 |
| 0 | 1 | 1 | 0 |
| 1 | 0 | 1 | 0 |
| 1 | 1 | 0 | 1 |
A half adder cannot accept a carry from a previous bit position. This limitation matters when adding multi-bit numbers.
Full adders
A full adder adds three one-bit values: \(A\), \(B\), and the carry-in \(C{in}\). It produces a sum \(S\) and carry-out \(C{out}\).
The equations are:
\[ S = A \oplus B \oplus C_{in} \]
\[ C{out} = AB + C{in}(A \oplus B) \]
The carry equation has two cases. The first term generates a carry when both \(A\) and \(B\) are 1. The second term propagates an incoming carry when exactly one of \(A\) and \(B\) is 1.
| A | B | Cin | S | Cout |
|---|---|---|---|---|
| 0 | 0 | 0 | 0 | 0 |
| 0 | 1 | 0 | 1 | 0 |
| 1 | 1 | 0 | 0 | 1 |
| 1 | 1 | 1 | 1 | 1 |
A full adder can be built from two half adders and one OR gate:
Connecting full adders in series creates a ripple-carry adder. Each stage waits for the previous carry, so the delay grows with the number of bits.
Subtractors
A half subtractor subtracts \(B\) from \(A\). It produces a difference \(D\) and a borrow \(B_{out}\):
\[ D = A \oplus B \]
\[ B_{out} = \overline{A}B \]
A full subtractor also accepts a borrow-in \(B_{in}\):
\[ D = A \oplus B \oplus B_{in} \]
\[ B{out} = \overline{A}B + \overline{A}B{in} + BB_{in} \]
The borrow-out equation describes every case in which the amount being subtracted is greater than the available value in the current bit position. Multi-bit subtraction can be built by connecting full subtractors, although practical processors often subtract by adding the two's complement.
module full_adder(
input a,
input b,
input cin,
output sum,
output cout
);
assign sum = a ^ b ^ cin;
assign cout = (a & b) | (cin & (a ^ b));
endmoduleExercise
For A = 1, B = 0, and Cin = 1, what are the full-adder outputs?
Show answer
Sum = 0 and Cout = 1, because 1 + 0 + 1 = 2, which is binary 10.