Logic gates & Boolean algebra
Simple truth tables become selectors, adders, and control circuits.
A computer can make every logical decision from one kind of gate.
Universal logic building block.
Build a decision
| A | B | XOR |
|---|---|---|
| 0 | 0 | 0 |
| 0 | 1 | 1 |
| 1 | 0 | 1 |
| 1 | 1 | 0 |
NAND can build any Boolean function. Combining small gates creates selectors, adders, and control.
What this model includes
Ideal Boolean logic. Electrical timing and noise are omitted.
What happens inside
Turn inputs into an output
AND is 1 only when both inputs are 1. OR needs at least one 1. XOR detects different inputs. NOT inverts one bit. NAND inverts AND and is functionally complete: networks of NAND gates can express any Boolean function.
Select and combine
A multiplexer chooses an input using select bits. A decoder activates a line for an input code. A full adder combines two bits and a carry; chaining carry signals forms a wider adder. Long carry paths can be shortened by more elaborate circuits at an area and power cost.
sum = A XOR B XOR carry_inWhat this means for your code
Low-level engineer
Truth tables describe stable behavior. Propagation delay and glitches still matter. Synthesizers minimize logic under timing, area, and power constraints.
Software developer
Bit masks, flags, and branchless selection follow these same rules. Branchless code is useful when measured, not automatically faster.
Read the actual specifications
These references supply the underlying contracts and implementation details. The diagrams here are simplified teaching models.