CPU

Manual Auto

Program Counter

0

Instruction Register

NIL
► Fetch
Decode
Execute

Accumulator

0

RAM

Address# Type Value

What is this and how does it work?

This simulator demonstrates the basic functioning of a Central Processing Unit (CPU) in a computer. At its core, every modern computer operates on similar principles, no matter how complex its tasks may seem.

The simulation shows five main components:

  • CPU: the brain of the computer, containing registers for temporary data storage and processing.
  • RAM (Random Access Memory): where instructions and data are stored for quick access.
  • Clock: represented by the "Clock Tick" button, it drives the CPU through its cycle.
  • Program Counter: keeps track of which instruction to execute next.
  • Accumulator: shows the current cycle of the execution phases, the CPU needs to fetch, decode, and execute every instruction present in RAM before moving to the next phase of the cycle.

The CPU operates in a continuous "Fetch-Decode-Execute" cycle:

  1. Fetch: the CPU pulls instructions from memory (RAM).
  2. Decode: the CPU figures out what they mean.
  3. Execute: the CPU carries out those tasks.

In this simulator, you can see (and edit) this cycle in action. The program loaded into RAM is a simple counting program. With each complete cycle, it increments a value stored in RAM.

While this simulation runs at a speed we can observe, real CPUs execute billions of instructions per second. This incredible speed allows computers to perform complex tasks like playing video games or displaying this web page.

You can interact with this simulator by clicking the "Clock Tick" button to step through each phase of the cycle, or by switching to "Edit Mode" to modify the instructions in RAM. Or you can enable the "Auto-Run" mode to see the simulation progress automatically.