Von Neumann Computer Architecture

Von Neumann Computer Architecture

The Von Neumann architecture is a computer design published by Hungarian mathematician John von Neumann in 1945 that still forms the basis of the great majority of computer systems today.

The first feature of a Von Neumann design is that it has a memory, or store as Von Neumann originally called it. The program for the computer is held within that memory and the program can be easily swapped out for a different one. This is a stored program design.

Many early computers did not load software into memory as a modern machine usually does. The program design was fixed into circuitry and in order to exchange the program for a different one, the actual circuitry of the machine would need to be adjusted or completely redesigned. Basic calculators of decades past used to have this kind of design where the program was fixed into the design of the circuitry of the calculator and could not be modified. Even early games consoles had the program fixed into the electronics because this approach was cheaper with the technology of the time. The stored program machine is a lot more flexible as it can run many different programs without electrical modification.

A second feature of Von Neumann architecture is that the program is stored in the same kind of memory as data. While this now seems like an obvious approach, in other designs such as the Harvard architecture the program is stored in one form of memory, the data in an entirely separate memory and the two do not mix. A benefit of storing the program and data together is that memory can be flexibly divided between the different usages. One program may be large but requires little data, another program may be small but needs lots of data. All of the available memory is available to both usages whereas in another design some memory may be wasted. Another benefit is it makes programming tools easier to produce when there is no distinction between data and software. A compiler for example is a program that writes another program. It’s awkward if it’s output is partially considered data but then later becomes program code.

The Von Neumann architecture is composed of only a few components, but using these parts we can form a complete computer system:

Von Neumann Architecture diagram

The Arithmetic and Logic Unit (ALU) is circuitry that performs calculations. A basic ALU may do as little as just addition, but in modern machines it usually has a wide range of mathematical operations available. It also performs comparisons such as determining if one number is bigger than another.

The registers are special very fast memory that is used as temporary scratch space to hold the numbers whilst calculations and other operations are in progress. Registers may hold the input numbers to the calculation that the ALU is performing, the output of the calculation and any intermediate results. Each register typically holds only one number each but it is possible for a single register to hold several numbers for certain specialist instructions. Some registers are considered as individual bits, where each bit has a different meaning. An individual bit with a specific meaning may be called a flag.

Some registers are generally available for the programmer to use for whatever purpose they wish, although there may be restrictions on which registers may be used with which CPU instructions depending on the CPU design. Some very simple CPUs may have as few as one general purpose register, which has historically been called the accumulator and most CPU instructions work with this single register. Modern sophisticated CPUs usually have a dozen or more general purpose registers that instructions can freely switch between. The term accumulator is more commonly used in the simpler designs than have only one general register. The term is less commonly used in designs with many general purpose registers.

Some registers have special purposes and must be used only in a particular way. Other registers are private to the CPU for its own use only and are not directly accessible to the programmer. Some examples of registers that are not for general use are as follows. It should be noted that a CPU may not have all of these registers and may have others, but these are a selection that are often found in many designs:

  • Program Counter: This register works like a bookmark that stores the current position in the program. When the software wants to jump to a different position in the program it changes the program counter register to the new position. There is normally a CPU feature to automatically move the program counter onto the next instruction when the previous one has finished running. The programmer can usually both read and write the program counter. An alternative name for this register is the instruction pointer.
  • Status Register: This stores useful information about calculation results and program execution as flags or individual bits. One flag might indicate if the result of the last calculation was negative. Another flag might indicate if the last calculation result was too big to fit in a register (overflowed). It might also contain information about recent program errors that can be useful for debugging. The programmer can read the status register but may not be able to write it directly.
  • Index Register: This is a register often used with certain instruction addressing modes, particularly index addressing which can be useful when accessing arrays. The operand of a cpu instruction may refer to a memory address which is the start of an array. The content of the index register acts an an offset and is added to the memory address specified in the operand.
  • Memory Address Register (MAR): This register holds the memory address of the instruction or data that the CPU is about to access. Whilst is could be, it is not typically available to the programmer and cannot usually be directly read or written. It is used as part of the internal operation of the CPU.
  • Memory Data Register (MDR): Similarly to the MAR this register is usually private to the CPU and is not generally available to the programmer. It is used as scratch space by the CPU to hold numbers in the process of being transferring to and from memory.
  • Current Instruction Register (CIR): Stores the full instruction (including any operands) that the CPU is currently processing. This is also a private register unavailable to the programmer.

The Control Unit is the director of the computer that coordinates the operation of all the parts. It collects the program instructions from memory (the fetch phase), determines what steps are required to execute it (the decode phase) and then directs the execution of the steps. It might for example tell the ALU that an addition is needed and which registers should be used based on the instruction it has retrieved from memory.

Finally there is input and output. This is a representation of all kinds of devices for feeding data into the computer and presenting data back to the user, such as keyboards, disks, the network, monitors, USB or printers.

These days several of the parts, usually at least the ALU, Control Unit and Registers, are contained within a single chip called the Central Processing Unit or CPU. This does not have to be the case though and all of the parts can be in different chips. In the past they often were entirely independent as chip technology was not good enough to contain an entire CPU all in one. As technology has improved, quite frequently now for smaller and simpler computers, all of the parts including the memory and input/output interfaces are contained within a single chip. This is known as a System-on-a-Chip or SoC as it has (virtually) the whole computer in a single electronic component. Using only a single chip makes the computer cheaper. Inexpensive SoC devices have enabled computers to proliferate into all kinds of devices.

Credit: EDSAC photo by Geni