| The CPU is the brains of the computer. Sometimes referred to simply as the processor or central processor, the CPU is where most calculations take place. In terms of computing power, the CPU is the most important element of a computer system. On large machines, CPUs require one or more printed circuit boards. On personal computers and small workstations, the CPU is housed in a single chip called a microprocessor. Two typical components of a CPU are: -
The arithmetic logic unit (ALU), which performs arithmetic and logical operations. -
The control unit, which extracts instructions from memory and decodes and executes them, calling on the ALU when necessary. CPU operation The fundamental operation of most CPUs, regardless of the physical form they take, is to execute a sequence of stored instructions called a program. Herein we are discussing devices that conform to the common aforementioned Von Neumann architecture. The program is represented by a series of numbers that are kept in some kind of computer memory. There are three steps that nearly all Von Neumann CPUs use in their operation, fetch, decode, and execute. | The first step, fetch, involves retrieving an instruction (which is a number or sequence of numbers) from program memory. The location in memory is determined by a program counter, which stores a number that identifies the current location in this sequence. In other words, the program counter keeps track of the CPU's place in the current program. Having been used to fetch an instruction, the program counter is the instruction that the CPU fetches from memory is used to determine what the CPU is to do.In the decode step, the instruction is broken up into parts that have significance to the CPU. The way in which the numerical instruction value is interpreted is defined by the CPU's Instruction set architecture (ISA). |
| Often, one group of numbers of the instruction, called the opcode, indicates which operation to perform. The remaining parts of the number usually provide information required for that instruction, such as operands for an addition operation. The operands may contain a constant value in the instruction itself (called an immediate value), or a place to get a value: a register or a memory address. In older designs the portions of the CPU responsible for instruction decoding were unchangable hardware devices. However, in more abstract and complicated CPUs and ISAs, a microprogram is often used to assist in translating instructions into various configuration signals for the CPU. This microprogram is often rewritable and can be modified to change the way the CPU decodes instructions even after it has been manufactured. After the fetch and decode steps, the execute step is performed. During this step, various portions of the CPU are "connected" (by a switching device such as a multiplexer) so they can perform the desired operation. If, for instance, an addition operation was requested, an ALU will be connected to a set of inputs and a set of outputs. The inputs provide the numbers to be added, and the outputs will contain the final sum. If the addition operation produces a result too large for the CPU to handle, an arithmetic overflow flag in a flags register may also be set (see the discussion of integer precision below). Various structures can be used for providing inputs and outputs. Often, relatively fast and small memory areas called CPU registers are used when a result is temporary or will be needed again shortly. Various forms of computer memory (for example, DRAM) are also often used to provide inputs and outputs for CPU operations. These types of memory are much slower compared to registers, both due to physical limitations and because they require more steps to access than the internal registers. However, compared to the registers, this external memory is usually more inexpensive and can store much more data, and is thus still necessary for computer operation. Some types of instructions manipulate the program counter. These are generally called "jumps" and facilitate behavior like loops, conditional program execution (through the use of a conditional jump), and functions in programs. [3] Many instructions will also change the state of digits in a "flags" register. These flags can be used to influence how a program behaves, since they often indicate the outcome of various operations. For example, one type of "compare" instruction considers two values and sets a number in the flags register according to which one is greater. This flag could then be used by a later instruction to determine program flow. After the execution of the instruction, the entire process repeats, with the next instruction cycle normally fetching next-in-sequence instruction due to the incremented value in the program counter. In more complex CPUs than the one described here, multiple instructions can be fetched, decoded, and executed simultaneously. This section describes what is generally referred to as a 'single cycle data path,' which in fact is quite common among the simple CPUs used in many electronic devices (often called microcontrollers). |