microprocessor

Build the Intel 4004: The World's First Microprocessor, in Your Browser

Denny Denny
5 min read

TL;DR: We rebuilt the 1971 Intel 4004 — the world’s first commercial microprocessor — as a genuinely 4-bit CPU inside DigiSim, using ordinary logic blocks: a control unit, program counter, instruction register, a 4-bit ALU, an accumulator, flags, and RAM. It runs a real stored program (4 × 3 by repeated addition) through the classic fetch–decode–execute–store cycle, and a dedicated product display counts a clean 0 → 4 → 8 → 12 before halting. Open it as a template and step through it yourself.

In November 1971, Intel ran an ad in Electronic News announcing “a new era of integrated electronics.” The product was the Intel 4004: a complete central processing unit on a single chip, about 2,300 transistors, clocked at 740 kHz, originally designed to power the Busicom 141-PF printing calculator. It was 4 bits wide. It fit on your fingertip. And it quietly started the era of computing that everything since — your laptop, your phone, the microcontroller in your microwave — descends from.

We wanted to make that history tangible, not just a museum photo. So we rebuilt the 4004’s ideas as a working circuit you can run, pause, and poke at in the browser.

Can you actually build a CPU out of logic gates?

A faithful, transistor-level 4004 is not something you hand-wire on a canvas — the real chip multiplexes a 4-bit bus across an 8-phase clock, has sixteen index registers and a three-level address stack, and decodes 46 instructions. That’s thousands of carefully timed elements.

But the essence of the 4004 — what makes it a stored-program computer rather than a pile of gates — is very buildable. And that essence is the thing worth teaching:

  • a 4-bit datapath (the 4004’s defining trait),
  • an accumulator and a flags register,
  • a program counter walking through instructions held in memory,
  • an instruction register and a control unit that turns each opcode into the right sequence of control signals,
  • and buses that move data between all of it without colliding.

That is exactly what this circuit is: a complete, if minimal, 4-bit microprocessor assembled from DigiSim’s component palette.

Try it

A working 4-bit Intel 4004–style CPU in DigiSim. The clock is running — watch the state lights step and the PRODUCT display climb.

Prefer the full editor? Open the Intel 4004 template, or find it inside the simulator under Demo → Others → “Intel 4004 — World’s First Microprocessor.”

What happens when you press play

The control unit drives every instruction through four states — FETCH → DECODE → EXECUTE → STORE — and you can watch them on the little state lights:

  1. Fetch. The program counter puts an address on the bus; RAM returns the instruction byte; the instruction register latches it.
  2. Decode. The opcode’s low nibble feeds the control unit; the program counter steps to the next instruction.
  3. Execute / Store. The control unit raises the right signals — read an operand from memory, route the accumulator into the ALU, perform an add or subtract, write the result back, update the zero flag.

To keep data from colliding, the machine uses three separate tri-state buses — one for addresses, one for memory operands, one for ALU results — so no two components ever drive the same wire at the same time. (If you’ve read our post on tri-state buffers and bus arbitration, this is that idea doing real work.)

The program: 4 × 3, the only way a tiny CPU knows how

The 4004 had no multiply instruction — neither does this machine. So it multiplies the way the Busicom calculator’s firmware did: repeated addition. In pseudo-assembly:

        ; product = 0, counter = 3, addend = 4
loop:   ACC = product + 4      ; add the multiplicand
        product = ACC
        ACC = counter - 1      ; count down
        counter = ACC
        if counter != 0 goto loop   ; the zero flag decides
        ACC = product          ; 12, for the display
        HALT

Three trips through the loop, three additions, and the product reaches 12. The conditional jump is driven entirely by the zero flag the ALU sets — exactly how a real branch works.

One honest detail: the display

Here’s a subtlety we hit while building it, because it’s a great lesson in its own right. This machine has a single accumulator, and it has to time-share it between the running product and the loop counter. So if you wire a display straight to the accumulator, it flickers through 0, 4, 0, 3, 2, 0, 4, 8, … — correct, but unreadable.

The fix is a tiny piece of hardware: a dedicated product register that latches the accumulator only when the product is written back to memory. The two write targets differ by a single address bit, so the latch enable is just one AND and one NOT gate. With that, the PRODUCT display shows the clean story — 0 → 4 → 8 → 12 — and holds 12 when the machine halts. Real CPUs are full of small, clever registers like this; here you can see exactly why one earns its place.

A tribute, not a forgery

We’ll say it plainly: this is a teaching reconstruction, not a cycle-accurate, transistor-faithful 4004. It’s a von-Neumann simplification with a single unified memory, where the real 4004 separated program ROM from data RAM and squeezed everything across a multiplexed bus. What it is faithful to is the part that matters for understanding: a 4-bit stored-program machine that fetches, decodes, executes, branches, and halts — running a real program you can read.

That’s the whole point of a simulator. The 4004 launched a revolution from behind a sealed gold package almost nobody ever saw inside. Here, the package is open. Press play, single-step the clock, change the constants in memory, and watch a microprocessor think — one nibble at a time.

Open the Intel 4004 in DigiSim →