← All posts
Tech · Jul 6, 2026 · 15 min

Part I: The 0s and 1s Inside CPUs and GPUs

Before a CPU or GPU can run a program, it first needs a way to turn electricity into 0s and 1s. This part starts at silicon and slowly builds up to the transistor, the tiny switch at the heart of every modern chip.

Note: This post follows my own attempt to understand how CPUs and GPUs work and why they are built differently. Some explanations are simplified, and any mistakes are part of the learning trail.

In middle school, we often learned that the Central Processing Unit, or CPU, is the “brain” of a computer, while the Graphics Processing Unit, or GPU, is used to create graphics. Those definitions are not wrong, but they feel incomplete now, especially in the age of AI. Yes, the CPU is still the brain of the computer, but what does that really mean? What kind of “thinking” is this brain doing? And yes, the GPU is still used to create graphics. That is why video games depend so heavily on it. But the GPU is no longer only about graphics. Today, it also powers many of the systems behind modern AI.

So the question is not just “What is a CPU?” or “What is a GPU?” The better question is: why are they built differently, and why are GPUs so useful for some kinds of work that CPUs are not as good at?

Before comparing CPUs and GPUs, we need to ask what they are made of.

At the lowest level, both CPUs and GPUs begin with semiconductor material, usually silicon. This material is useful because its electrical behavior sits between a conductor and an insulator. A conductor, like copper, allows electricity to flow easily, while an insulator, like glass, blocks it. A semiconductor sits somewhere in the middle, which means its ability to conduct electricity can be carefully controlled. Pure silicon, however, is not useful enough for building modern computer chips on its own. In its crystal form, each atom has 4 outer electrons and bonds with nearby atoms. At normal temperatures, a few electrons can gain enough energy to break free and move, which is why pure silicon can conduct electricity a little. However, most of its electrons are locked into bonds, so this conductivity is weak and not controlled enough for building modern chips.

To make this material more useful, engineers add tiny amounts of other elements to it in a process called doping. Doping changes how easily charge can move through the crystal. Phosphorus has 5 outer electrons, while silicon has 4 and when phosphorus is added, 4 of its electrons bond with nearby silicon atoms, but the 5th electron is left over and can move more freely. This creates n-type silicon, where electrons are the main mobile charge carriers. Engineers can also add boron, which has 3 outer electrons. Since boron has one fewer electron than silicon, it creates a missing-electron spot called a hole. Nearby electrons can move into these holes, making the holes behave like positive charge carriers. This creates p-type silicon.

Engineers do not dope the entire piece of silicon in the same way, yhey create tiny selected regions inside it. Some regions are made n-type, and some are made p-type. N-type silicon has extra mobile electrons, so electrons can move through it more easily. P-type silicon has holes, which are missing-electron spots that nearby electrons can move into.

So what happens when an n-type region and a p-type region are placed next to each other inside the same piece of silicon? Near the boundary of the two regions, some electrons from the n-type side move into nearby holes on the p-type side. When an electron fills a hole, that electron is no longer free to move around, and the hole is no longer available either. So the area near the boundary loses many of its mobile charge carriers. This thin boundary area is called the depletion region.

Now you may ask why don't the electrons from the n-type side moving until they fill all the holes on the p-type side, creating one large depleted region? At first, some electrons do move across the boundary because there are many mobile electrons on the n-type side and many holes on the p-type side. But every time an electron leaves the n-type side, it leaves behind an atom that is now missing one negative electron, so that atom becomes positively charged. And when that electron fills a hole on the p-type side, it is added to a place that was missing an electron, making the nearby atom negatively charged.

These charged atoms are fixed in place because they are part of the silicon crystal. They cannot move around like mobile electrons and holes can. As more electrons cross, more fixed positive charges build up on the n-type side of the boundary, and more fixed negative charges build up on the p-type side. Opposite charges attract, and like charges repel, so this charged boundary starts pulling electrons back toward the n-type side and pushing away additional electrons that try to cross. After a small number of electrons move, this push-back becomes strong enough to stop most further crossing. That is why only a thin depletion region forms near the boundary instead of the entire n-type and p-type regions being depleted.

Before silicon can become a switch, we need to name the invisible things moving through it: current, voltage, resistance, and ground.

Before going further, let’s define four important ideas: current, voltage, resistance, and ground. Current means the movement of electric charge. In a metal wire, this usually means electrons moving through the metal. In silicon, it can mean electrons moving through n-type regions or holes moving through p-type regions. So when we say “current flows,” we mean that mobile charge carriers are moving through a material.

Voltage is the difference between two points that can make charge want to move. A useful analogy is water height. Water flows from a higher place to a lower place because there is a height difference. But that height difference does not appear by itself; something, like a pump, must lift the water up. Similarly, a voltage difference appears when an energy source separates charge and creates a high side and a low side. In a computer, the chip receives this energy from the computer’s power system, and tiny wires inside the chip carry these high and low voltage levels.

Resistance is how strongly a material or part of a circuit opposes the movement of charge. In the water analogy, it is like a narrow pipe that makes water harder to push through. Even if there is a voltage difference, current may not flow easily if the path has high resistance. A resistor is a component designed to provide resistance, but resistance is not only found in resistors. Wires, silicon regions, and transistor channels can all have resistance.

Ground, often written as GND, is the point we choose to call 0 volts. It is the reference point that other voltages are compared to. So when a wire is close to ground, we can treat it as low voltage, or 0. When a wire has a higher voltage compared to ground, we can treat it as high voltage, or 1. In simple terms, voltage is the push created by a difference between two points, current is the movement of charge, resistance is what makes that movement harder or easier, and ground is the reference point we call zero.

Now we can return to the silicon regions. With charge, voltage, resistance, and ground in mind, we can finally see how arranged silicon becomes a switch.

Using the arranged silicon regions, we can now build a switch. This switch is called a transistor. It is not a mechanical switch that moves up and down. Instead, it is an electronic switch that controls whether charged particles can move through a tiny region of silicon. A useful switch needs three parts: one side where charge can come from, called the source; another side where charge can go, called the drain; and a separate control point, called the gate, that decides whether movement between the source and drain is allowed or blocked.

In the simplified transistor below, the source and drain are both n-type regions, while the body between them is p-type. This connects directly to the depletion-region idea from before. Wherever an n-type region meets a p-type region, a boundary forms where mobile charges are reduced. So the source-body boundary and the drain-body boundary both act like barriers. This is why electrons in the source cannot simply flow across the p-type body to the drain.

It may seem strange that the source and drain are both n-type. Does that mean they are both negatively charged? Not exactly. N-type does not mean the whole region is negative. It means electrons are the main mobile charge carriers there. The region is still mostly balanced overall, because the mobile electrons are balanced by fixed positive atoms in the silicon crystal. The source and drain are made n-type because they have many mobile electrons available. If a path exists between them, electrons can move through that path easily. But the p-type body between them interrupts that path.

The gate creates the missing path using voltage. It sits above the p-type body, separated from the silicon by a very thin insulating layer, so current does not flow directly from the gate into the silicon. But the gate’s voltage can still affect the charges underneath it. When the gate voltage is low, the p-type body between source and drain stays as it is, so electrons do not have an easy path across. When the gate voltage is high enough, it attracts electrons toward the surface under the gate and pushes holes away. If enough electrons gather there, a thin electron-rich path forms between the n-type source and the n-type drain. This path is the channel.

But the channel only creates a possible path. For charge to actually move, the source and drain must also be connected to different voltage levels by the surrounding circuit. One side is connected closer to ground, or low voltage, and the other side is connected to a higher voltage. Once the channel appears, electrons have both a path and a reason to move through it.

Now that one transistor can be turned ON and OFF with voltage, the next step is to connect many transistors together so they can follow simple rules.

A transistor gives us a controllable ON and OFF state. When the transistor is OFF, charge cannot move easily through it. When it is ON, charge can move through the channel. By itself, one transistor is only a tiny switch, but when many transistors are connected together, they can create rules. Inside a chip, a signal is usually represented by voltage. A low voltage, often connected to ground, is treated as 0. A high voltage is treated as 1. So the job of a logic gate is to look at its input signals and decide what voltage the output wire should have. Should the output be pulled down to ground, giving 0? Or should it be connected to a high voltage, giving 1?

A logic gate is just a small circuit made from transistors that follows one of these rules. For example, a NOT gate has one input and produces the opposite output. If the input is 0, the transistors inside the gate connect the output to high voltage, so the output becomes 1. If the input is 1, the transistors connect the output to ground, so the output becomes 0. Other gates follow other rules. An AND gate gives 1 only when both inputs are 1. An OR gate gives 1 when at least one input is 1. These rules may sound simple, but they are already computation. The chip is using physical switches to transform input signals into output signals. By combining many of these gates, computers can build circuits that add numbers, compare values, store bits, move data, and decide which instruction should happen next.

Once we have logic gates, we can start building larger circuits. A circuit is just a planned arrangement of gates and wires, where the output of one gate can become the input of another. Some circuits perform arithmetic, such as adding numbers. Some compare values. Some choose between different inputs. Some are arranged so that they can hold onto a value, becoming a tiny form of memory. As these circuits become larger, they start forming the parts of a processor. There are circuits that perform calculations, circuits that store small pieces of data, circuits that move data from one place to another, and circuits that decide which operation should happen next. Put together, these circuits form a processor core: a unit that can follow instructions.

There is something beautiful about this journey, how a single silicon atom becomes part of the machines that now power artificial brains. A silicon atom does not know anything about numbers, memory, graphics, or AI. It only knows how to bond with nearby atoms. But when billions of these atoms form a crystal, when tiny amounts of phosphorus and boron reshape parts of that crystal, when electrons move, holes are filled, and tiny channels appear and disappear, the material slowly becomes a machine. What begins as silicon and charge becomes switches; switches become logic; logic becomes circuits; and circuits become the cores inside CPUs and GPUs.

سمیع