Private archive copy · Unofficial site · Content copyright belongs to Runoob Tutorial and the original authors · View Original

The Overall Skeleton of a Computer

The Overall Skeleton of a Computer

In 1945, mathematician John von Neumann proposed a computer architecture blueprint that still has influence today.

The core idea of this blueprint is extremely simple, yet it laid the foundation for all general-purpose computers over the past eighty years.


A real-life analogy: the automated sorting system in a library

Imagine you walk into a large library and want to quickly find a book and mail it to a friend far away.

You would go through the following steps:

Step 1, input the request -- you type the book title at the library's computer terminal.

Step 2, look up the location -- the system queries the database by the book title and finds which shelf the book is on.

Step 3, retrieve the book -- a robotic arm takes the book off the shelf.

Step 4, pack and output -- wrap the book, stick on a shipping label, and send it to the post office.

Step 5, coordination and command -- all of this needs a central scheduling system to coordinate the order and pace.

If you translate this system into computer terms, it corresponds to the five major components of the von Neumann architecture:

Library analogy Computer component What it does
Query terminal Input device (Input) Brings external information into the computer
Books on the shelf Memory (Memory) The warehouse that stores programs and data
Robotic arm Arithmetic unit (ALU) Performs arithmetic and logical operations
Package delivery Output device (Output) Sends results out of the computer
Central scheduling system Control unit (Control Unit) Directs all parts to work in coordination

Did you notice? The key to this library system working properly is not each component itself, but a clear set of data-flow rules between them.

Likewise, the essence of the von Neumann architecture lies in "how the components connect and communicate".


Core principle: division of labor and collaboration of the five components

Overview of the five components

The von Neumann architecture divides a computer into five functionally independent yet closely collaborating parts:

Component English Plain-language understanding Core Features
Arithmetic unit ALU (Arithmetic Logic Unit) The computer's "abacus" Performs arithmetic and logical operations such as addition, subtraction, multiplication, division, AND, OR, NOT
Control unit Control Unit The computer's "command center" Fetches instructions from memory, decodes them, and issues control signals to direct other parts
Memory Memory The computer's "warehouse" Stores program instructions and operation data, read and written by address
Input device Input Devices The computer's "eyes and ears" Brings external information (keystrokes, mouse clicks, sensor data) into the computer
Output device Output Devices The computer's "mouth and hands" Sends computation results out in a form humans can perceive (display, print, sound)

The arithmetic unit and control unit together are what we commonly call the CPU (central processing unit). They are the computer's "brain", while memory and the input/output devices are the "nervous system" and "senses".

The architecture diagram below uses rectangles in five colors to represent the five components, and arrows on the connecting lines mark the direction of data flow.

Data bus

Address bus

Control bus

Data write

The figure below shows the most classic von Neumann architecture of a modern computer. The whole system consists of five parts: CPU, Memory, Input, Output, and I/O interfaces; the CPU itself contains the Control Unit, ALU, and Registers.

The CPU communicates with memory and I/O devices via the Data Bus, Address Bus, and Control Bus: the address bus specifies the access location, the data bus transfers instructions and data, and the control bus sends control signals such as read/write and interrupt; together the three complete information exchange inside the computer.

Three buses: the highway for data

The connections between the five components are not haphazard; information is passed in an orderly way through three groups of "buses":

Bus type English What it transfers Direction
Data bus Data Bus The actual instructions or operation data Bidirectional (CPU can read and write)
Address bus Address Bus The memory address the CPU wants to access Unidirectional (CPU outputs the address to memory)
Control bus Control Bus Control signals such as read/write enable and interrupt Issued by the control unit, directing all parts

Understanding the difference between these three buses is the key to grasping internal computer communication. You can remember it this way: the address bus says "where to go", the data bus is responsible for "carrying things", and the control bus decides "what action to take".

The "stored-program" idea: the soul of the von Neumann architecture

The five-component division is only the outer skeleton; the truly revolutionary aspect of the von Neumann architecture is the "Stored-Program" concept.

Before von Neumann, to make a computer perform a task you had to manually plug and unplug cables, set switches, and even swap circuit boards.

To switch to a different task, you had to readjust the physical connections of the hardware -- like having to reassemble the stove before every meal.

von Neumann's breakthrough:

This idea means the computer changed from a "special-purpose computing tool" into a "general-purpose computing platform".

Interactive demo: hover to explore the five components (runoob)

Hover your mouse over any component in the architecture diagram below and the corresponding detailed description card on the right will be highlighted. Click the "Run demo" button to watch a small dot move along the data-flow arrows -- simulating the complete path of data flowing from an input device into memory, into the CPU for computation, back to memory, and finally to an output device.

Data Fetch / read data Control signals

CPU (arithmetic unit + control unit)

ALU arithmetic unit

Control unit

Memory

Memory (runoob demo)

Input device

Output device

CPU

Arithmetic unit + control unit
The computer's "brain"

Memory

Stores instructions and data
Read and written by address

Input device

Keyboard / mouse
Data enters the computer

Output device

Monitor / printer
Results leave the computer

Click the button to watch the path of data flowing among the five components


Interactive demo: simulate a minimal stored-program computer

The Python code below simulates a minimal von Neumann computer -- with an arithmetic unit (doing addition), memory (storing instructions and data), a control unit (fetching and executing instructions in order via the PC pointer), and input/output.

Please read the comments carefully, then run it.

Example

"""
Minimal von Neumann computer simulator (runoob demo)
Demonstrates the collaboration of the five components: arithmetic unit, control unit, memory, input, output
"""

class

VonNeumannMachine:

   

"""A condensed von Neumann architecture computer"""

   

def

init

(

self

)

:

       

--- Memory ---

       

A one-dimensional array with addresses starting from 0, storing both instructions and data

       

self

.

memory

=

[

0

]

256

       

--- Arithmetic unit (ALU) + register file ---

       

self

.

accumulator

=

0

   

Accumulator ACC, the core register of the ALU

       

self

.

temp

=

0

         

Temporary register, used to hold operands

       

--- Control unit (Control Unit) ---

       

self

.

pc

=

0

           

Program counter PC, holds the address of the next instruction

       

self

.

running

=

True

   

Running flag

       

--- Input / Output ---

       

Data sent by the simulated input device

       

self

.

input_buffer

=

[

]

       

Data displayed by the simulated output device

       

self

.

output_buffer

=

[

]

   

============================================================

   

Input device: writes external data into a specified memory address

   

============================================================

   

def

input_to_memory

(

self

,

address

,

value

)

:

       

print

(

f

"[Input device] write data to memory address {address}: {value}"

)

       

self

.

memory

[

address

]

=

value

   

============================================================

   

Output device: reads data from a specified memory address and displays it

   

============================================================

   

def

output_from_memory

(

self

,

address

)

:

        val

=

self

.

memory

[

address

]

       

print

(

f

"[Output device] read data from memory address {address}: {val}"

)

       

self

.

output_buffer

.

append

(

val

)

   

============================================================

   

Memory: read / write operations (CPU accesses via the bus)

   

============================================================

   

def

mem_read

(

self

,

address

)

:

       

"""Read memory contents from a specified address"""

       

if

0

<=

address

<

len

(

self

.

memory

)

:

           

return

self

.

memory

[

address

]

       

raise

ValueError

(

f

"Illegal memory address: {address}"

)

   

def

mem_write

(

self

,

address

,

value

)

:

       

"""Write a value into the memory at a specified address"""

       

if

0

<=

address

<

len

(

self

.

memory

)

:

           

self

.

memory

[

address

]

=

value

       

else

:

           

raise

ValueError

(

f

"Illegal memory address: {address}"

)

   

============================================================

   

Arithmetic unit (ALU): performs arithmetic operations

   

============================================================

   

def

alu_add

(

self

,

operand

)

:

       

"""ALU addition: ACC = ACC + operand"""

        old_acc

=

self

.

accumulator

       

self

.

accumulator

=

operand

       

print

(

f

"[ALU arithmetic unit] addition: {old_acc} + {operand} = {self.accumulator}"

)

   

def

alu_load

(

self

,

operand

)

:

       

"""ALU load operation: load an immediate value into ACC"""

       

self

.

accumulator

=

operand

       

print

(

f

"[ALU arithmetic unit] load: ACC = {operand}"

)

   

============================================================

   

Control unit: fetch, decode, dispatch, update PC

   

============================================================

   

def

fetch

(

self

)

:

       

"""Fetch stage: fetch the next instruction from memory according to PC"""

        instruction

=

self

.

mem_read

(

self

.

pc

)

       

print

(

f

"\n[Controller FETCH] PC={self.pc}, fetched instruction code: {instruction}"

)

       

self

.

pc

=

1

 

After fetching, PC automatically increments by 1, pointing to the next instruction

       

return

instruction

   

def

decode_and_execute

(

self

,

instruction

)

:

       

"""
        Decode + execute stage:
        We define a minimal instruction set (opcode + operand mixed encoding):
          1 LOAD immediate -- load the value of the next memory cell into ACC
          2 ADD address -- add the value at the specified address to ACC
          3 STORE address -- store the value of ACC into the specified address
          255 HALT -- halt
        """

       

if

instruction

==

1

:  

LOAD

            operand

=

self

.

mem_read

(

self

.

pc

)

           

self

.

pc

=

1

           

print

(

f

"[Controller DECODE] instruction: LOAD, operand: {operand}"

)

           

self

.

alu_load

(

operand

)

       

elif

instruction

==

2

:  

ADD

            address

=

self

.

mem_read

(

self

.

pc

)

           

self

.

pc

=

1

            operand

=

self

.

mem_read

(

address

)

           

print

(

f

"[Controller DECODE] instruction: ADD address[{address}] (value {operand})"

)

           

self

.

alu_add

(

operand

)

       

elif

instruction

==

3

:  

STORE

            address

=

self

.

mem_read

(

self

.

pc

)

           

self

.

pc

=

1

           

print

(

f

"[Controller DECODE] instruction: STORE address[{address}] (value = {self.accumulator})"

)

           

self

.

mem_write

(

address

,

self

.

accumulator

)

       

elif

instruction

==

255

:  

HALT

           

print

(

f

"[Controller DECODE] instruction: HALT (halt)"

)

           

self

.

running

=

False

       

else

:

           

print

(

f

"[Controller] unknown instruction: {instruction}, halt"

)

           

self

.

running

=

False

   

============================================================

   

Run the full program

   

============================================================

   

def

run

(

self

)

:

       

"""Main loop: repeatedly fetch -> decode -> execute until halt"""

       

print

(

"="

55

)

       

print

(

"Minimal von Neumann computer starting"

)

       

print

(

"="

55

)

       

while

self

.

running

:

            instr

=

self

.

fetch

(

)

       

Fetch instruction

           

self

.

decode_and_execute

(

instr

)

 

Decode + execute

       

print

(

"\n"

"="

55

)

       

print

(

"Program execution finished, computer halted"

)

       

print

(

"="

55

)

================================================================

Example program: compute 10 + 20 and store the result at address 100

================================================================

machine

=

VonNeumannMachine

(

)

Program written into memory (instructions and data mixed together; this is "stored-program")

Address 0: LOAD 10 (opcode 1, operand 10)

Address 2: ADD 100 (opcode 2, operand 100, meaning take the addend from address 100)

Address 4: STORE 200 (opcode 3, operand 200, meaning store the result to address 200)

Address 6: HALT (opcode 255)

machine.

memory

[

0

]

=

1

machine.

memory

[

1

]

=

10

   

LOAD operand: immediate 10

machine.

memory

[

2

]

=

2

machine.

memory

[

3

]

=

100

   

ADD operand: address 100 where the data is located

machine.

memory

[

4

]

=

3

machine.

memory

[

5

]

=

200

   

STORE operand: address 200 where the result is stored

machine.

memory

[

6

]

=

255

   

HALT

Store the addend 20 at address 100 (simulating the input device writing data)

machine.

input_to_memory

(

100

,

20

)

Run the program

machine.

run

(

)

View the result

result

=

machine.

mem_read

(

200

)

print

(

f

"\nFinal result: value in memory address 200 = {result}"

)

machine.

output_from_memory

(

200

)

print

(

f

"Output device buffer: {machine.output_buffer}"

)

Run this program and you will see instructions being fetched, decoded, and executed one by one. This is what happens hundreds of millions of times per second in your computer -- except that a real CPU's instruction set is far more complex.


Summary and check

In a nutshell

The von Neumann architecture divides a computer into five parts -- arithmetic unit, control unit, memory, input devices, output devices -- connected by three groups of buses, stores programs and data in the same memory, and has the CPU automatically fetch and execute instructions in order.

Self-test questions

Question 1: Among the five components of the von Neumann architecture, which two together are called the CPU?

Correct answer: B

Question 2: What is the role of the address bus? What is its data transfer direction?

Correct answer: C. The address bus outputs address information from the CPU to memory; it is unidirectional.

Question 3: What is the core significance of the "stored-program" idea?

Correct answer: B. Stored-program turned the computer from a special-purpose device into a general-purpose platform, where software can be changed flexibly.