I understand the concept that the CPU's machine code is what translates the binary input into commands, and then executes these commands, many billion times per second. I can understand how, given this concept, everything works -- breakneck calculations and a fantastically comprehensive codebook allow for advanced processes.

But explain to me why is this is given? In other words, if someone was pitching this idea to me as a mere concept, I would think they were absurd -- obviously it works, so please show me my error! Why does this work at all? Where is this codebook stored physically on the CPU, and beyond the mere logic of it, how does the codebook 'force,' so to speak, the physical hardware to 'obey' the commands that it translates? What is intimately going on here..? Is there a 'codebook' register that, when it reflects a specific code, 'decodes' this information by physically sending an electrical charge to a specific series of wires? How then does this work..?

I have read various resources, but all of them explain how the CPU works without explaining precisely why it does in a purely physical sense. Every resource escapes this by using an oddly anthropomorphizing analogy, or using an explanation laden with words that have no business being used to describe the automatic processes of machines like those 'quoted' above. Any straight-forward explanation or resources on this specific question would be greatly appreciated.

  • 6
    $\begingroup$ This is far too broad. Essentially, you're saying, "I've seen books on CPU architecture but I don't like them. Please write me another one!" $\endgroup$ – David Richerby Nov 30 '15 at 20:53
  • $\begingroup$ Perhaps the answers to this question would help. $\endgroup$ – Rick Decker Dec 1 '15 at 15:08
  • $\begingroup$ Why it works in a purely physical sense? Well, mostly... transistors. Which also means... quantum physics. Did that help? :) $\endgroup$ – Luaan Mar 7 '16 at 12:32

This is a very broad question which would be far easier to answer in person with a whiteboard than in a short online missive.

I found this document for the design of a simple computer from Purdue (part of an engineering program assignment). The document shows the design of an 8 bit computer that would be far simpler to explain than your average CPU of today. It has a very simple "codebook" of only 6 instructions using a 3 bit opcode. More complex systems perform in a similar way, but with larger opcodes and more instructions.

The "codebook" in this example is decoded by logic gates (physical hardware) and referred to as the "Instruction Decoder and Micro-sequencer" in the document. This is a section of hardware that typically will take the instruction's opcode to determine how to sequence data through various parts of the computer in order to complete the intended instruction. This is done in stages based on a system clock and counting through different phases of an operation.


At a very basic level, the CPU implements a Boolean circuit with memory. That is, the basic building blocks of a CPU are logic gates (in practice, NAND gates) and flip flops (memory units). These are electrical creatures, and if you want to understand how they work physically, you'll have to study electromagnetism.

(Modern CPUs are quite a bit more complicated than that. They have cache memories and microcode that machine code is compiled to. But you can ignore these details to start with.)

The book The Elements of Computing Systems explains how to build a barebones CPU using NAND gates and flip-flops. Through the link you can find lecture notes, the first few of which explain how how to construct a CPU.


Not the answer you're looking for? Browse other questions tagged or ask your own question.