TDT4160: Computers and Digital Design
This compendium tries to explain the essence of the course. The information provided is largely based on the course book "Structured Computer Organization" and the lecture slides. Please note that this compendium is written by students, so please be critical to what you read.
Anyone is allowed to edit this compendium, so feel free to make improvements.
Von Neumann Architecture
The von Neumann arichitecture describes a machine with five basic parts: the memory, the arithmetic logic unit, the control unit, and the input and output equipment.
- Von Neumann architecture
- Computer systems are built up from three types of components: processors, memories, and I/O devices.
- CPU (Central Processing Unit)
- The part of the computer that fetches instrucitons one at a time from a memory, decodes them, and executes them.
- The part of the computer where programs and data are stored.
- I/O (Input/output) devices
- The parts of the computer used to transfer information into and out of the processor and main memory.
The CPU (Central Procssing Unit) is the "brain of the comptuer. Its function is to execute programs stored in the main memory by fetching their instrucitons, examining them, and then executing them one after another. The components are connected by a bus, which is a collection of parallell wires for transmitting address, data, and control signals. Buses can be external to the CPU, connecting it to memory and I/O dvices, but also internal to the CPU.
The CPU is composed of several distinct parts.
- The control unit
- Component responsible for fetching insturctions from main memory and determining their type.
- The arithmetic logic unit
- Component that performs operations such as addition and Boolean AND needed to carry out the instructions.
The CPU also contains a small, high-speed memory used to store temporary results and certain control information. This memory is made up of a number of registers, each having a certain size and function.
- Program counter (PC)
- Points to the next instruction to be fetched for execution.
- Instruction Register (IR)
- Holds the instruction currently being executed.
- Memory Address Register (MAR)
- Holds the address of the memory location currently being access by the processor.
- Memory Buffer/Data Register (MDR)
- Holds the data being transferred to or from the memory location currently being accessed.
Most computers have numerous other registers as well, some of them general purpose as well as some for specific purposes.
The memory is the part of the computer where programs and data are stored.
Instruction Set Architecture
The instruction set is a set of instructions that a computer is able to understand and execute. The specifics of the instructions may vary from computer to computer, but in the following section the most common ones are listed.
- Move data from RAM to registers.
- Move data from registers to RAM.
- Copy data among registers.
- Add two numbers together.
- Compare one number with another.
- JUMP IF CONDITION
- Jump if condition to another address in RAM
- Jump to another address in RAM.
- Output to a device.
- Input from a device such as a keyboard.
An instuction consists of an opcode, usually alongwith additional information suchg as where operands come from and where results go to. The general subject of specifying where the operands are (i.e, their addresses) is called addressing. There can vbe several possible formats for level 2 instructions. An instruction always has an opcode to tell what the instruction does. There can be zero, one, two, or three addresses present. On some machines, all instructions have the same length; on others there may be many different lengths. Instructions may be shorter than, the same length as, or longer than the word length. Having all the instructions be the same length is simmpler and makes decoding erasier but often wastes space, since all instructions then have to be as long as the longest one. Other trade-offs are also possible.
Most instructions have operands, so some way is needed to specify where they are. This is called addressing.
- Immediate addressing
- The address part of an instruction actually contains the operand itself rather than an address or other information describing where the operand is.
Immediate addressing has the virtue of not requiring an extra memory reference ot fetch the operand. It has the disadvantage that only a constant can be supplied this way. Also, the numberof values is limited by the size of the field. Still, amny architecture use this technique for specifiying small integer constants.
- Direct addressing
- The address part of an instruction contains the operands full address in memory.
Like immediate addressing, direct addressing is restricted in its use: the instruction will always access exactly the same memory location. So while the value can change, thel ocation cannot. Thus direct addressing can only be used to access global variables whose address is known at compile time. Nevertheless, many programs have global variables,so this mode is widely used.
- Register addressing
- The address part of an instruction specifies a register rather than a memory location.
- Regoster indirect addressing
- The addres