CS50 Machine Architecture Notes

Contents


Computer Architecture

Computer components

There are three main computer components, from an architectural point of view:

CPU

The CPU (or Central Processing Unit) is the "brain" of the computer. It contains the mechanisms that actually perform the computations that the computer does on your behalf.

Memory

The memory (also called RAM, which stands for Random Access Memory) is the scratch paper that the CPU uses to store data and partial results from computations that are in progress.

Note that the CPU often contains some small amount of scratch memory as well. This memory is usually called registers. In most architectures, the registers are treated quite differently than other memory, but a few architectures treat them in similar ways.

I/O
I/O (which stands for Input/Output) is the mechanism that the CPU uses to input data, either directly to the CPU or into memory, from file, keyboard, network, or other external devices, to output data to files, the screen, network, or other external devices.

It may seem odd for contemporary users to refer to a file as an external device, since for computers like PCs and Macs, files are stored on disks that generally reside inside the computer. Similarly, the screen and keyboard are also tightly integrated with most contemporary computers, so that it's difficult to imagine a computer without a keyboard and screen (and mouse and disk...). What is really meant by input and output is with respect to the CPU and RAM and other devices in the system- not whether the data actually enters or exits the box that computer resides in.

The CPU

In general, a CPU contains the following pieces:

Register File

The register file is a small set of memory locations that can each be used to store a single item (usually a character, integer, or a floating point number).

Control

The control logic decides what operation in the program to perform next.

Each program, by the time the CPU gets it, is broken down into a sequence of operations. By default, the control logic is quite simple- execute the operations in the sequence that appear in the program. However, the control logic can also execute the operations in a sequence that is computed as the part of the program itself- for example, with the C if statement.

Datapath

The datapath is where the action actually takes place. Data it taken from a register or registers, operated upon, and the results are placed back into a register (or registers).

One component of the datapath is the ALU (the Arithmetic Logic Unit), which is the brain of the CPU (just as the CPU is the brain of the computer). The ALU is responsible for computing the mathematical functions that actually implement the arithmetic and logic operations that the CPU executes. It may seem quite surprising that all of the operations that the CPU can compute reduce to a small set of logical and arithmetic functions.

Memory Organization


Please bring any errors or inconsistencies in this document to the attention of the author.

Dan Ellard - (ellard@deas.harvard.edu)