Central processing unit

From Conservapedia
(Redirected from CPU)
Jump to: navigation, search
Block Diagram of a simple CPU

A Central Processing Unit (CPU) is the main control mechanism of a computer, containing control logic, registers, and arithmetic logic unit (ALU) as well as a memory interface. Some CPUs implement additional functionality, but often other capabilities are provided through peripheral processors that handle such things as input/output (I/O), floating-point arithmetic, and vector processing. All computers contain at least one CPU, but some contemporary computers contain over 1,000.

The purpose of a CPU is to execute programs. Programs are a series of numeric values, where each value indicates a specific operation. Each value is referred to as an instruction, and has a corresponding mnemonic for programming convenience. These values are known as machine code. All of the instructions that can be executed by a CPU are collectively known as the CPU's instruction set. Different CPU models usually implement completely different instruction sets, so that programs written for one CPU will not execute on a different one. Writing programs in machine code is difficult, so programs called assemblers were written to translate mnemonics into machine code, thus increasing the speed of writing, and the reliability of, programs. Since the 1960s, most programs have been written using a Programming Language, which are even easier to use than an assembler.

A microprocessor is any processor implemented on a single integrated circuit, however most microprocessors are CPUs. The largest producer of microprocessors used in general-purpose computers is Intel.

Operation

The basic operation of a CPU is the "Fetch, Decode, Execute" cycle.[1] The instruction fetcher fetches instructions from memory. The control logic decodes and executes the instruction. The ALU is used to perform arithmetic and logical operations such as adding a value in memory to a value in a register and storing the result in another register. On some CPUs, some instructions may require additional fetches from memory (e.g., to get or store operands). A program in memory is executed sequentially, with each instruction stored in a different memory location. The instruction pointer (IP) register keeps tracks of the current program position, and is updated (usually incremented) after each CPU cycle.

Architecture

A CPU's architecture distinguishes it from other CPUs. There are many aspects of CPU architecture.

Data size

CPUs are defined by the number of bits that can be handled in a single operation. For instance, a 16-bit CPU handles 2 bytes of data with most of its operations. The amount of data that can be transferred to and from memory is this number of bits, which determines the width of memory required for a given CPU. Most CPUs on the market today are 64-bit CPUs. Operations can be performed on larger or smaller numbers of bits, but such operations tend to run more slowly because the CPU is optimized for it's native data size.

Registers

Register sets are essentially a small amount of memory within the CPU, divided into a discrete number of registers. There are general-purpose registers that can be used by programs and special-purpose registers that are restricted to certain functions. General purpose registers are the native data size of the CPU. Thus a 32-bit CPU will have 32-bit wide general-purpose registers. Special-purpose registers are used to store flags indicating the result of arithmetic or logical operations, index into memory, and so forth. Typical registers used for indexing into memory were the Instruction Pointer (IP) - sometimes called the Program Counter (PC) - and the Stack Pointer (SP). Such registers which contain memory addresses tend to be twice the size of the CPU's data size. Thus, the IP on an 8-bit CPU was 16-bits, and the IP on a 16-bit CPU was 32-bits.

Instruction Set

The instruction set of a given CPU model defines the basic operations that can be performed by the CPU. These operations tend to be simple, such as adding two numbers, outputting a character, or moving data between registers. In a given line of processors, the instruction sets are compatible, although as the newer models are released, they usually had additional instructions added. Thus, newer processors were backwards compatible (meaning they could run the same programs as older processors), but older processors did not recognize the new instructions added to later models. Between processor lines, there is no compatibility. The instructions are stored in memory as "machine code" which are bit patterns that represent certain instructions. These bit patterns represent entirely different operations on different processor lines, which means that a program written for one CPU will not run on a different CPU line.

There are two aspects to an instruction set.

  • Orthogonality: An instruction set is considered "orthogonal" if the instructions work with all general-purpose registers. Instruction sets which limit certain instructions to certain registers are not considered orthogonal. In reality, instruction sets fall somewhere along a spectrum between complete orthogonality and non-orthogonality. The PDP-11 has an example of an orthogonal instruction set.
  • RISC/CISC: Reduced Instruction Set Computers (RISC) have fewer instructions than Complex Instruction Set Computers (CISC), which requires more instructions to complete the same task than on CISC processors. The advantage to RISC instruction sets is that they can be implemented with fewer transistors, which allows faster instruction execution in theory. In practice, the clock rate is the same on RISC and CISC CPUs. However, more cores can be fit into a given semiconductor space with a RISC architecture. ARM processors are examples of RISC CPUs. Intel iAPX processors are examples of CISC CPUs.

See also

References

External links