1. The Physical Layer: Voltage and Transistors
At the physical hardware level, a computer does not contain literal 0s and 1s. Instead, it operates on electrical voltages. Computers are built from MOSFET transistors that act as switches. In typical digital systems (such as TTL logic): - A low voltage (e.g. 0V to 0.8V) is mapped to binary 0. - A high voltage (e.g. 2.4V to 5.0V) is mapped to binary 1. These voltage thresholds prevent electrical interference or signal degradation from corrupting computational calculations.
2. Logic Gates: The Building Blocks of Computation
Transistors are combined to form logic gates, which process binary signals based on Boolean logic. The primary logic gates are: - NOT Gate: Inverts the input (0 becomes 1, 1 becomes 0). - AND Gate: Outputs 1 only if all inputs are 1. - OR Gate: Outputs 1 if at least one input is 1. - XOR (Exclusive OR) Gate: Outputs 1 if the inputs are different (e.g. one is 1 and the other is 0). XOR is fundamental for binary addition circuits.
3. Binary Arithmetic inside the ALU
The Arithmetic Logic Unit (ALU) is the CPU core component that performs mathematical calculations. The ALU uses logic gates to construct: - Half Adders: Adds two bits to produce a Sum and a Carry bit. - Full Adders: Adds three bits (including an incoming carry bit), allowing computers to add long multi-bit numbers by chaining adders together. - Subtractors: Performs subtraction by adding the two's complement of the subtrahend to the minuend.
4. Registers, RAM, and Cache Storage
To store binary values, computers use different storage technologies: - SRAM (Static RAM): Uses flip-flops (circuits made of 4-6 transistors) to store bits. SRAM is extremely fast and is used for CPU registers and cache. - DRAM (Dynamic RAM): Uses a single transistor and capacitor to store each bit. The capacitor holds charge (1) or no charge (0). DRAM is slower than SRAM because capacitors leak charge and must be refreshed thousands of times per second, but it is much cheaper and denser. - Flash Memory (SSD): Uses floating-gate transistors to trap electrons, preserving binary states even when the power is turned off.