Template: 1-Bit Half Adder
Template: Template: 1-Bit Half Adder - Fundamental 1-bit addition using XOR and AND gates with digit display. Learn basic binary arithmetic and carry generation.
Lo que aprenderás
- Compute the sum and carry of two single bits with XOR and AND.
- Read the half-adder truth table — 4 rows, just XOR and AND patterns.
- Identify why bit 0 of a ripple adder uses a half-adder, not a full-adder.
- Understand the difference between half-adder and full-adder (no carry-in).
- Recognize that sum + carry encode 0–2 in 2-bit binary.
Cómo funciona
A half adder adds two single bits. It takes two inputs (A, B) and produces two outputs: - Sum = A ⊕ B (XOR — high when exactly one input is high) - Carry = A · B (AND — high only when both inputs are high)
This directly implements the four cases of single-bit binary addition: - 0 + 0 = 00 (sum 0, carry 0) - 0 + 1 = 01 (sum 1, carry 0) - 1 + 0 = 01 (sum 1, carry 0) - 1 + 1 = 10 (sum 0, carry 1) — the carry signals overflow into the next column
Why is it called "half"? Because it can't accept a carry-in from a previous bit position. To chain half-adders for multi-bit addition, you'd lose the carry-in capability — that's why higher bits use full adders (XOR/AND with three-input handling). The half-adder is only sufficient for the lowest bit position where there's nothing to carry from below.
The two outputs (sum, carry) together encode the integer 0, 1, or 2 in 2-bit binary — exactly the range needed for adding two single-bit operands.
Tabla de verdad
Half adder: add two bits, produce 2-bit result (sum, carry).
| Entradas | Salida | |||
|---|---|---|---|---|
| A | B | Sum | Carry | |
| 0 | 0 | 0 | 0 | 0 + 0 = 0 |
| 0 | 1 | 1 | 0 | 0 + 1 = 1 |
| 1 | 0 | 1 | 0 | 1 + 0 = 1 |
| 1 | 1 | 0 | 1 | 1 + 1 = 10 (binary 2 — carry out) |
Expresión booleana
Sum bit — XOR of inputs.
Carry bit — AND of inputs. Only fires when both bits are 1.
Pruébalo paso a paso
Configura las entradas en la simulación de arriba, lee qué debería suceder y verifícalo.
- 1A = 0 B = 0Esperado:
Sum=0, Carry=0Lo que verás: 0 + 0 = 0. Default state. - 2A = 1 B = 0Esperado:
Sum=1, Carry=0Lo que verás: 1 + 0 = 1. Just the sum bit; no overflow. - 3A = 0 B = 1Esperado:
Sum=1, Carry=0Lo que verás: Symmetric — XOR is commutative. - 4A = 1 B = 1Esperado:
Sum=0, Carry=1Lo que verás: 1 + 1 = 2 (binary 10). Sum bit drops back to 0 because there's no place to put the 2's-bit; the carry signals overflow.
Componentes utilizados
Aplicaciones en el mundo real
Bit 0 of any ripple-carry adder. Since there's no carry-in for the lowest bit, a half-adder suffices and saves transistors compared to a full-adder.
Counter increment logic. Incrementing a counter by 1 is equivalent to adding 1 to bit 0 — the half-adder pattern (XOR with the increment input, AND for carry-out) implements this in synchronous counter cells.
Hash/checksum primitive. Some lightweight hash functions XOR adjacent bytes and AND for carry as part of a mixing step.
Educational stepping stone. Half-adders are the bridge between learning logic gates and learning multi-bit arithmetic — every textbook covers them in this order.
Carry-save adder cells. In multiplier circuits, half-adders combine partial-product columns where carry-in isn't needed (the right edge of the array).