Logic gates and Boolean computation

At this layer, we stop looking at individual transistors and start looking at specific arrangements of them.

Logic gates

A logic gate is a physical device built from transistors that takes one or more electrical inputs and produces one electrical output according to a fixed physical rule. Inside the gate, transistors are connected in a specific arrangement. That arrangement determines how electrical current can flow.

For example, consider a gate with two input wires and one output wire, that has transistors arranged in such a way that:

  • If both input wires carry voltage, the transistors form a continuous conductive path, current flows, and the output wire gets voltage.
  • If either input wire lacks voltage, the conductive path is broken, no current flows, so the output wire receives no voltage.

The gate opens for some conditions and stays closed for others. The gate does not “choose”. This behavior is forced by the physical structure of its transistors and wiring. Given the same inputs, the gate will always produce the same output, because it cannot do otherwise. When a gate, like in the example described above, behaves such that current can reach the output only when all input wires carry voltage, we describe that behavior as AND. The gate is not “performing logic”, it is only obeying physics.

Logic is the description we give to that behavior.

By changing how transistors are connected in a logic gate, you change the physical conditions under which a conductive path exists:

  • In an AND gate, all input voltages are required for current to flow through the gate.
  • In an OR gate, any one input voltage is sufficient for current to flow through the gate.
  • In a NOT gate, the presence of any input voltage blocks the current.
  • More complex gates (NAND, NOR, XOR, XNOR) arise from slightly more intricate arrangements, but the principle is identical.

In conclusion:

  • Each input wire has two distinguishable states (voltage / no voltage).
  • Each output wire also has two states (voltage / no voltage).
  • The gate always produces the same output for the same inputs.

This is exactly the structure studied in Boolean logic: functions that take binary inputs (0 or 1) and produce a binary output.

Boolean logic and computational building blocks

Boolean logic (named after George Boole) is the mathematical description of systems that operate on two possible values. These values are usually written as 0 and 1, but they can just as well be called false/true, off/on, or no voltage/voltage. These two distinguishable states form the basis of digital systems. In digital systems (from digitus, finger in Latin) information is represented using discrete, distinguishable states.

An analogue system instead allows information to vary continuously across a range. A bit is the interpretation of this two-state physical signal, and it’s the smallest unit of information in a digital system.

Formally, Boolean logic studies Boolean functions. A Boolean function takes one or more binary inputs and produces a single binary output. For example:

  • AND is a function that outputs 1 only if all inputs are 1. Otherwise the output is 0.
  • OR is a function that outputs 1 if at least one input is 1.
  • NOT is a function that outputs 1 if the input is 0, and 0 if the input is 1.

Because these outputs are just another binary signal, they can be fed directly into other gates. By wiring gates together, we create larger Boolean functions made entirely of smaller ones, which can perform more complex operations. Specific arrangements can act as arithmetic units (adder, subtractor, multiplier, divider), comparing values (comparator), selecting between alternatives (multiplexor), or controlling which signals are allowed to flow.

Logic circuits only manipulate bits (0s and 1s). Numbers exist only because we interpret certain bit patterns as quantities, through the binary numeral system. For example, this four-bit pattern 0101 does not “mean five” to the circuit, it is simply a pattern of voltages. We choose to read it as the number 5. Arithmetic arises from this interpretation: the circuit transforms 0010 and 0011 into 0101; we call that “2 + 3 = 5”.

Under another convention, the same four bits could represent part of a colour, a machine instruction, four independent switches, or something else entirely.

The key insight is that complex behavior does not require complex components. It arises from the structured combination of extremely simple, deterministic elements. Logic gates do not “understand” numbers, choices, or rules. They merely allow or block electrical paths. Yet, when arranged in the right patterns, they implement arithmetic, control, and data flow.

Boolean logic provides the formal language to describe these compositions. Logic gates provide the physical mechanism to enforce them. Together, they show how “dumb” switches can be assembled into systems capable of solving complex problems.

Everything described so far responds only to present signals, and leaves no trace once those signals disappear. The next step is to allow the system to preserve information over time, so that past events can influence future behavior. This persistent information is called state, and the physical mechanisms that hold it are called memory.

State and memory

Logic alone is not enough

A network of logic gates behaves like a mathematical function. At any instant, its outputs are determined only by its current inputs. If the inputs change, the outputs change. If the inputs disappear, nothing remains. This means a pure logic circuit has no memory.

It cannot:

  • Keep track of how many times something has happened
  • Remember whether something was on or off a moment ago
  • Decide what should happen next based on what already happened
  • Continue a process from where it left off

But many real tasks depend on history. To make this possible, past results must be able to influence future behavior. The system needs information that persists over time, and that persistent information is called state.

Feedback: letting the past affect the present

Feedback is the key idea that makes persistent information possible. So far, we’ve described logic as flowing in one-directional chains: inputs → gates → outputs. However, memory arises when logic is arranged in loops. By feeding the output of a circuit back into its own input, it becomes possible for a system to maintain a state over time. Once feedback exists, the system can settle into one of multiple stable configurations, and remain there until something forces it to change.

Imagine a small circuit built from logic gates, wired in a loop. If a voltage appears at its output, that same voltage is fed back into the circuit, which causes the circuit to keep producing that voltage (1). If no voltage is present, the absence of voltage is also fed back, keeping the circuit quiet (0). That means that the circuit can settle into one of two possible stable situations (0 or 1).

This structure is called a latch, and it is the simplest form of memory: it stores one bit, not by physically storing an object, but by continuously maintaining a stable electrical condition.

Scaling memory

Several latches can be controlled together to form a register. Each latch stores one bit, while the register allows all of those bits to be read or updated as a group. An 8-bit register holds eight binary states. A 64-bit register holds sixty-four. When registers are connected to logic circuits, the system can perform a computation, store the result, and use that stored result as input to the next computation.

A bit is a single binary choice (0 or 1). A byte is a group of 8 bits. Larger units count more bytes, using SI prefixes: a kilobyte (KB) is 10³ bytes, a megabyte (MB) is 10⁶ bytes, a gigabyte (GB) is 10⁹ bytes, a terabyte (TB) is 10¹² bytes, a petabyte (PB) is 10¹⁵ bytes, an exabyte (EB) is 10¹⁸ bytes, and so on. Binary units also exist: 1 KiB is 1,024 bytes, 1 MiB is 1,048,576 bytes, and so on.

Modern computers work with enormous amounts of data: millions of pixels on a screen, gigabytes or terabytes of memory and stored information. In principle, you could imagine building billions of latches, but in practice this fails for several fundamental reasons:

  • Physical size: A latch is built from multiple transistors. Even with modern manufacturing techniques, transistors occupy enough space that billions of latches would require an impractically large chip.
  • Power consumption: Each latch consumes power continuously just to remember. Billions of always-on feedback loops would waste enormous energy and generate heat even when nothing is happening.
  • Wiring complexity: A memory element is only useful if it can be connected to the rest of the system. Each latch requires physical wiring to carry signals to and from it. As the number of latches grows, the amount of wiring grows even faster, which at large scales would be impractical.
  • Volatility: Latches store information by maintaining electrical activity, so they forget everything the instant that activity stops. Unplug the machine, and every latch forgets everything. A memory system built entirely from latches would lose all information whenever power is removed, making it unsuitable for long-term storage.

So while latches and registers are excellent for small, fast, temporary memory, they do not scale to the quantities of memory that real systems require. This leads to multiple kinds of memory, and no single design can optimize everything at once. Different memory technologies therefore make different trade-offs in terms of:

  • Speed: How quickly stored information can influence computation. This includes latency (i.e. how long it takes for the first bit to arrive after a request) and throughput (i.e. how many bits can be delivered per unit of time once transfer begins). A memory can be fast in one sense and slow in another: some memories respond quickly but deliver little data, while others respond slowly but stream vast amounts once active.
  • Density and cost: How much information can be packed into physical matter, and at what price. Higher density means more bits per unit area or volume, and possibly lower cost per bit, because more memory is produced from the same material.
  • Power usage: How much energy is required to preserve and access information. Power is spent to maintain state (especially in volatile memories), to move data across physical distance and to switch bits during reads and writes.
  • Volatility: Whether information survives the loss of power. Volatile memory stores information only while energy is continuously supplied. Non-volatile memory preserves information through physical or chemical stability. Non-volatile memories tend to be slower or harder to rewrite. Volatile memories are fast but forget instantly.
  • Distance from computation: How far information must travel to be used. The farther memory is (physically or through more system layers) the more time and energy it takes to use. Very fast computation requires memory that is extremely close, but only a small amount of memory can be placed that close.
  • Robustness: How faithfully bits represent information over time. This includes error rate (how often stored bits flip unintentionally), reliability (how predictable memory behavior is) and endurance (how many times memory can be rewritten before wearing out). Highly reliable and durable memories are slower and more expensive. Cheaper, denser memories require error correction, refresh cycles, and redundancy to remain usable.

Memory technologies

These are the main memory technologies used in computers, ordered by how closely they are integrated with computation, each optimized for a different balance of the mentioned properties:

Latches and registers

Built directly from transistor feedback loops that actively hold bits as long as power is supplied. They are placed directly alongside the circuits that carry out computation (e.g. CPU) and are accessed by direct wiring. Typically limited to dozens to a few hundreds of bytes per CPU core.

  • Speed: Fastest possible (minimal latency, very high throughput)
  • Density & cost: Extremely low density, super expensive per bit
  • Power usage: High
  • Volatility: Volatile
  • Distance from computation: Inside the CPU itself
  • Reliability & endurance: Extremely reliable, unlimited rewrites

SRAM

SRAM (Static Random Access Memory) stores each bit using a stable transistor feedback loop, similar to registers but arranged in large arrays. It bridges the speed gap between registers and DRAM memory. A standard SRAM memory usually ranges from a few kilobytes to a few tens of megabytes.

  • Speed: Very low latency, very high throughput
  • Density & cost: Low density, very expensive per bit
  • Power usage: High
  • Volatility: Volatile
  • Distance from computation: On-chip or very close
  • Reliability & endurance: Very reliable, unlimited writes

DRAM

In DRAM (Dynamic Random Access Memory) each bit is stored as electric charge in a tiny capacitor. Charge leaks over time, so memory must be periodically refreshed, even if unused. Access requires sensing very small voltages and restoring them. A typical personal computer is equipped with a few or tens of gigabytes of DRAM memory.

  • Speed: Higher latency than SRAM, very high throughput
  • Density & cost: Much higher density, far cheaper per bit
  • Power usage: Moderate (refresh + data movement)
  • Volatility: Volatile
  • Distance from computation: Off-chip but still relatively close
  • Reliability & endurance: Moderate error rates, very high endurance

Flash memory

Flash memory stores data by trapping electrons in insulated structures, allowing bits to persist without power. Used by SSDs and USB flash drives. It’s persistent storage that’s a lot faster than magnetic disks and far denser than RAM. Modern computers commonly include hundreds of gigabytes to several terabytes of flash-based storage.

  • Speed: High read throughput, slower writes, high latency for modification
  • Density & cost: Very high density, low cost per bit
  • Power usage: Low at rest, moderate during writes
  • Volatility: Non-volatile
  • Distance from computation: External device
  • Reliability & endurance: Limited write cycles, needs error correction

Magnetic disk

Magnetic disks store data as tiny magnetic orientations on a flat, spinning disk coated with a magnetic material. A precise mechanical system moves into position above the surface to read and write the stored information. Currently, hard disk drives (HDD) typically store multiple terabytes of data. They allow cheap mass storage at scale.

  • Speed: Very high latency
  • Density & cost: Very high density, very low-cost per bit
  • Power usage: Moderate
  • Volatility: Non-volatile
  • Distance from computation: Far (external device + mechanical moving parts)
  • Reliability & endurance: Mechanical failure risk

Magnetic tape

Magnetic tape stores data along long strips of magnetized material, optimizing for density, durability, and minimal energy usage rather than access speed. Retrieving data requires physically winding the tape, resulting in a huge latency, but once aligned, data can be streamed efficiently. Tape systems store tens of terabytes per cartridge and exabytes at the library level. Highly reliable over long time spans, ideal for archival long-term storage.

  • Speed: Extremely high latency, good streaming throughput
  • Density & cost: Among the highest density and lowest cost per bit
  • Power usage: Very low
  • Volatility: Non-volatile
  • Distance from computation: Extremely far
  • Reliability & endurance: Excellent for long-term storage

Memory, the bottleneck of computation

Computation appears to be mostly about the act of performing operations: adding, comparing, transforming, and deciding. In reality, these operations are cheap. What dominates cost, both in time and energy, is moving data to where it is needed. Modern systems spend more time waiting for memory than performing logic. Computer architecture is, in large part, the art of arranging memory so that the right information is in the right place at the right moment.

The layers above and below

Part I began with matter and energy, establishing that computation is constrained by physics. Part II then showed how electricity can be controlled and how transistors act as reliable switches. Part III has examined how arrangements of those switches enforce logical rules, and how state and memory follow. Together, these layers explain how machines can store information and enforce rules reliably.

However, so far this description remains static. Nothing explains how these rules are applied over time, how actions are ordered in a controlled sequence or how many independent parts coordinate without conflict.

What is missing is time.

The next chapter explains how computers impose timing and coordination, and how controlled execution emerges from components that still, individually, do nothing more than move bits around.