What does the CPU do?

Author: Release time:2020-01-07 Source: Font: Big Middle Small View count:596

Main functions of cpu

1. Processing instructions

English Processing instructions, which refers to the execution order of instructions in the control program. There is a strict order between the instructions in the program, and the order of the program must be strictly executed to ensure the correctness of the computer system work.

2, perform the operation

In English Perform an action, the function of an instruction is often realized by a series of operations performed by components in the computer. The CPU should generate corresponding operation control signals according to the functions of the instructions and send them to the corresponding components, so as to control these components to operate according to the requirements of the instructions.

3.Control time

English Control time, time control is the timing of the implementation of various operations. During the execution of an instruction, what operations should be performed at any time should be strictly controlled. Only then can the computer work methodically.

4.Processing data

That is, performing arithmetic and logical operations on data, or performing other information processing. Its function is mainly to interpret computer instructions and process data in computer software and execute instructions.

cpu

The role of the CPU

The CPU fetches instructions from memory or cache memory, places them into instruction registers, and decodes the instructions. It breaks down instructions into a series of micro-operations, and then issues various control commands to execute a series of micro-operations, thereby completing the execution of an instruction. An instruction is a basic command that a computer specifies to perform the type and operand of an operation. An instruction is composed of one byte or multiple bytes, which includes an opcode field, one or more fields related to the operand address, and some status words and feature codes that characterize the state of the machine. Some instructions directly include the operand itself.

Extract

The first stage, fetch, retrieves the instruction (either a value or a series of values) from memory or cache. The memory location is specified by the Program Counter. (The program counter holds a value for identifying the position of the program. In other words, the program counter records the trace of the CPU in the program.)

Decoding

The CPU determines its execution behavior according to the instructions fetched from the memory. During the decoding phase, the instructions are broken into meaningful fragments. The values are interpreted as instructions according to the instruction set architecture (ISA) definition of the CPU. A part of the instruction value is an opcode, which indicates which operations are to be performed. Other values usually provide the necessary information for the instruction, such as the target of an addition operation.

Carried out

After the extraction and decoding phases, the execution phase is immediately followed. In this stage, various CPU components capable of performing required calculations are connected. For example, if an addition operation is required, the arithmetic logic unit will be connected to a set of inputs and a set of outputs. The input provides the values to be added, and the output will contain the result of the sum. The ALU contains a circuit system that makes it easy for the output to perform simple common operations and logical operations (such as addition and bit operations). If the addition operation produces a result that is too large for the CPU processing, the operation overflow flag may be set in the flags register.

At last

Finally, the operation results are often written into the internal registers of the CPU for fast access by subsequent instructions. In other cases, the results may be written into slower but larger and cheaper main memory. Some types of instructions manipulate the program counter without directly producing results. These are generally called "jumps" and bring cyclic behavior, conditional execution (via conditional jumps), and functions into the program. Many instructions change the status bits of the flags register. These flags can be used to influence program behavior, because they often show various results. For example, a "compare" instruction is used to determine the size of two values, and a value is set on the flag register according to the comparison result. This flag can be used to determine the program direction by subsequent jump instructions. After the instruction is executed and the result is written back, the program counter value is incremented, repeating the entire process, and the next instruction cycle normally fetches the next sequential instruction.

Hot News

Hot product