Preliminary understanding of CPU

Source: Internet
Author: User

Understanding CPU

by Jackking_defier

First of all, the main content of this article is a brief description of the general principle of the CPU, the prerequisite knowledge I will put forward, but because of space I will not explain in detail the need for other basic knowledge. The basic course of engineering is studied by default.

I. GENERAL statement

Starting with the structure of the computer, in modern computers, the CPU is the core and is often likened to the human brain. Now the computer is "von Neumann machine","von Neumann machine" A notable feature is the operator, memory, controller, input devices and output devices. CPU is the combination of the operator and controller , because the operator and the controller in the logical relationship and circuit structure is very close, especially after the production process of LSI, so the two components are integrated on the same chip.

Understanding how the CPU works translates into understanding the functions and functions of the operators and controllers.

Second, the operation of the CPU

An operator consists of an ALU (arithmetic logic unit) and several general-purpose registers. //Register requires digital logic knowledge

The ALU is a chip, with the corresponding input, will give the corresponding output, by the logical operation table can determine the different pins will have the corresponding operation output. This can be analogous to the 74ls138 chip in the digital logic, except that 74181 gives the result of the corresponding input.
Here I think, many students have not studied the digital logic of this course, a brief introduction. Our high school physics has studied "and gate", "or gate" and "non-gate", that is, through the circuit can realize the logical "and", "or" and "non" operation. At the same time, there is a door called "and non-gate", that is, A and B first do and operations, and then do non-operational negation. The arithmetic of Boolean algebra can be used to express all the operations of "gate" with "non-gate", also is equivalent transformation. So that we have a different or, same or, or not a variety of gate circuits.

Through a number of input signals through the various gate circuit will produce one or more results, to meet our needs of the function. such as Adder, shifter, trigger, register, decoder.

The ALU is such a component that satisfies our computing function. Because of the many functions of the ALU, you can understand that you can do all kinds of basic arithmetic operations and basic logic operations.

Speaking of now, you should now know that the CPU has a full-time operation of the components of the ALU, and by the circuit can be achieved. The circuit can easily express the binary information, such as the high level is "1", the low level is "0". CPU processing data are binary, you can complete the subtraction operation through the original code, the inverse code and the complement, so that all operations through the circuit implementation.

Third, the instruction system

Machines can do the math because people use machine language, machine language can be recognized by the machine itself, but also can be understood. Machine language is composed of a line of statements, each statement has a certain meaning. For example, it can specify what the machine does, pointing out where the number of participating operations or other information is. We are used to calling every machine language statement a machine instruction, and the set of all machine instruction systems is called the machine's instruction system. The computer designers mainly study how to determine the machine instruction system, how to use hardware circuit, chip, equipment to realize the function of machine instruction system. Computer users are based on the instruction system, using assembly language to compile a variety of programs.

The content of the above paragraph means that all the operations we do with the computer are essentially reverted to instructions.

instructions are made up of opcode and address codes. It is divided into different fields. OpCode to indicate the action to be made, address code to indicate the address of the source operand of the instruction, the address of the result, and the address of the next instruction. (Here again the format of the instruction, instructions and the way the data is addressed, etc., easy to wrap around and limited to space, slightly) a directive contains information: what it is, and where it needs the parameters.

Instructions are stored in memory, which is what we normally call memory.

Four, the controller of the CPU

In the second section, I said CPU operation, this section mainly describes the CPU control. the essence of the CPU consists of two parts: the operator and the controller. for the von Neumann structure of the computer, once the program is put into memory, you can automatically complete the task of taking instructions and analyzing instructions through the computer, the controller is dedicated to do this work. it is responsible for coordinating and controlling the sequence of instruction of each part of the computer, whose basic function is taking instruction, analyzing instruction and executing instruction.

command , the controller must have the ability to automatically remove instructions from the memory.
Analysis Instructions , first, to analyze what to do, that is, what the controller needs to emit what kind of operation command; the second is to analyze the valid address of the operand participating in this operation.
The execution instruction , this phase is according to the analysis instruction produces "The Operation command" and "the operand address" the request, forms the Operation control signal sequence (different instruction has the different operation control signal sequence), through to the arithmetic device, the memory as well as I/O device operation, executes each instruction.

In addition, the controller has other control functions, all listed will make the head big. In short, it's control!

Based on the above, you can derive the functions that the CPU must have:

    • Command Control , the sequence of the control program execution. when the program runs, the directives are generally executed sequentially.
    • operation Control that produces the control commands required to complete each instruction. according to the instruction request to the hardware to produce the operation control signal sequence, in layman's terms, is to turn the instruction into the direct operation of the hardware.
    • Time Control , time control for various operations. The operation of the computer is more sensitive to time, and the concept of the cycle is mentioned later.
    • data processing , arithmetic and logic operations on the data. this is mainly by the Alu.
    • processing interrupts ,//is the CPU interrupted operation, the following will refer to interrupts, in the CPU is also a very important concept.
V. Structure of the CPU

According to the previously mentioned CPU must have the function, to take instructions, must have a register dedicated to the address of the current instruction, tell you where to remove the command to execute now, to analyze the instruction, must have the register of the current instruction and the code to decode the instructions of the component, That is, to analyze what the operation of this directive corresponds to, what needs to be done; to execute the instruction, there must be a control unit CU capable of issuing various sequence of operation commands; to complete the arithmetic and logical operation, there must be a register of the operands and the ALU of the component that implements the operation; In order to handle some anomalies and special requests, An interrupt system is also required.

CPU mainly consists of four parts: ALU, CU, register, interrupt system.

In the digital logic, registers can store binary information. Some of the main registers and their functions in the CPU:

    • MAR: The memory address register that holds the address of the storage unit that will be accessed.
    • MDR: Memory data register for storing data. The data is going to be stored in the storage unit or just read out of the storage unit.
    • PC: Program counter, storing the address of the current instruction, has the Count function. in general, the next instruction address is pc+1, which is executed sequentially. Directly modifying this value is to transfer the class instruction and jump to another location to continue execution.
    • IR: Instruction register, which holds the instruction that will be executed at the moment.
      Mainly through the four registers, the CPU can exchange information with main memory. because the program and the data required by the program exist in main memory.

Here, for example, the CPU takes instructions from the main memory path. /mm represents memory /
Fetch instruction: Pc–>mar–>mm–>mdr–>ir
Explanation: The PC stores the address of the instruction we will execute, the current instruction address into the address register mar, and then the command memory read operation, the current instruction from memory read into the data register MDR, and then the current instruction from the MDR to the instruction register IR, followed by decoding the execution part, followed by the operation code of the instruction, by the CU decoding to execute.

The control unit CU provides a sequence of micro-operation commands to complete the instruction operation of the computer.

Six, instruction Cycle

The time required for the CPU to take out and execute an instruction is called the instruction cycle, which is the time that the CPU completes an instruction.

The instruction cycle is simple, divided into two stages: the reference period and the execution period .
In most cases, the CPU is "Fetch – Execute – Fetch – Execute" Automatically work in the order. Just mentioned the access to the command, all instructions are the path, so the reference period is the same. According to the instruction situation, the execution cycle length is different, some do not even, directly is the transfer instruction.

A more important concept is mentioned here: interruption
Interrupts are better understood to be interrupted during CPU execution. It's too much to say in this. I can use my language to let you understand: this is like you go to Internet cafes, is based on time billing, this time can be understood as the instruction cycle. While you are still playing, someone accidentally pulled out the network cable, you have to interrupt, you have to go to plug the network cable to continue to play. Here you have to keep the previous position, do not be occupied by others, the game does not quit, so that you can continue to play after processing. Because you also like to play this game, the general thing is not to move your, this time the man called you to play ball, you said is busy, play the game to play again. This means that there is a priority ranking, the priority of playing games, so you block out this can interfere with your interruption, continue your current operation, to play the game.
Because in the CPU will also be interrupted by a variety of situations, you can control the software according to the rules, if it is a power outage or something, that is not operational.
There are many divisions and concepts in this piece of the cycle, such as machine cycles, cycle cycles, and so on. Do not say too much, afraid of you around.
You can understand the point that the CPU is very tight on time, and everything goes according to the time steps.


The transfer of data between the CPU components is also dependent on the bus, the bus extension is also many, you can simply understand to transfer data.
There are many of these I did not elaborate, I am sure that I can not finish, because I began to write the discovery, which are linked, I can not only say a part, so the basic principle of the computer to say a bit, the CPU is the core of the computer, the CPU is how to work, the detailed content or from the "computer composition principle."
I look back, I seem to be the ultimate simplification of this textbook, a lot of it is a stroke, but can be a non-computer professional students to get an initial understanding of the CPU article.

Preliminary understanding of CPU

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.