There is an 8-bit CPU inside the single-chip microcomputer. At the same time, we know that the CPU contains an arithmetic unit, a controller and several registers. The internal structure and working principle of the 51 single-chip microcomputer CPU.
From the figure we can see that the dotted box is the internal structure of the CPU. The CPU of the 8-bit MCS-51 microcontroller consists of an arithmetic logic unit ALU (Arithmetic Logic Unit), accumulator A (8 bits), register B (8 bits), program status word PSW (8 bits), program counter PC (sometimes also called instruction pointer, i.e. IP, 16 bits), address register AR (16 bits), data register DR (8 bits), instruction register IR (8 bits), instruction decoder ID, controller and other components.
Picture 1
1. The main functions of the arithmetic unit (ALU)
A) Arithmetic and logical operations, which can operate on half-byte (a byte is 8 bits, half-byte is 4 bits) and single-byte data.
B) Arithmetic operations such as addition, subtraction, multiplication, division, addition 1, subtraction 1, comparison, etc.
C) Logical operations such as AND, OR, XOR, complement, loop, etc.
D) Bit processing function (i.e. Boolean processor).
Since there is no register inside the ALU, the operands participating in the operation must be placed in the accumulator A. Accumulator A is also used to store the results of the operation.
For example: when executing the instruction ADD A, B
executes this instruction, the content in accumulator A is input into the ALU through the input port In_1, register B is input into the ALU through the internal data bus and the input port In_2, and the result of A+B is sent back to the accumulator A through the output port Out of the ALU and the internal data bus.
2. Program counter PC
The function of PC is to store the address of the instruction to be executed. It has 16 bits in total and can directly address the 64K ROM. The lower 8 bits of PC are output through port P0, and the upper 8 bits are output through port P2. In other words, the program counter PC points to where the program is executed, and it always follows the execution of the program. We know that the user program is stored in the internal ROM. If we want to execute the program, we must read it out byte by byte from the ROM, and then execute it in the CPU. So which line does the ROM execute specifically? This requires our program counter PC to indicate. The
program counter PC has the function of automatically adding 1, that is, after reading a byte of instruction code from the memory, PC automatically adds 1 (pointing to the next storage unit).
3. Instruction register IR
The function of the instruction register is to store the instruction code to be executed.
Here we first briefly understand the process of CPU executing instructions. First, the instruction code is read from the program memory (ROM) and sent to the instruction register. After being decoded by the decoder, the timing and control circuit sends the corresponding control signal to complete the function of the instruction. We will explain in detail the execution process of instructions in the microcontroller in another lesson later.
4. The instruction decoder ID
is used to decode the instructions sent to the instruction register. The so-called decoding is to convert the instructions into the electrical signals required to execute the instructions. When the instructions are sent to the decoder, the decoder decodes the instructions. According to the signals output by the decoder, the CPU control circuit regularly generates various control signals required to execute the instructions, so that the microcontroller can correctly execute the various operations required by the program.
5. Address register AR (16 bits)
AR is used to store the address information of the external memory unit to be addressed. The address code of the memory unit where the instruction code is located is generated by the program counter PC, and the address code of the memory unit where the operand in the instruction is located is given by the operand of the instruction. From the above figure, we can see that the address register AR is connected to the external memory through the address bus AB.
6. Data register DR
is used to store data information written to the external memory or I/O port. It can be seen that the data register has a latching function for output data. The data register is directly connected to the external data bus DB.
7. Program status word PSW
is used to record the status of the operation process, such as overflow, carry, etc.
For example, the content of accumulator A is 83H, and the execution is:
ADD A, #8AH; accumulator A is added to the immediate value 8AH, and the result is stored in A.
After the instruction, the result of the sum will be [1]0DH, but accumulator A has only 8 bits and can only store the lower 8 bits, that is, 0DH, and the highest bit B8 in the result cannot be stored. For this reason, a carry flag C is set in the CPU. When a carry occurs during addition, the carry flag C is 1.
8. The timing component
consists of a clock circuit and a pulse distributor to generate the timing pulse signal required by the micro-operation control component.
Previous article:What are the components of the MCS-51 microcontroller?
Next article:The structure and working principle of the P1 port of the mcs-51 single chip microcomputer
- Popular Resources
- Popular amplifiers
- Learn ARM development(14)
- Learn ARM development(15)
- Learn ARM development(16)
- Learn ARM development(17)
- Learn ARM development(18)
- Embedded system debugging simulation tool
- A small question that has been bothering me recently has finally been solved~~
- Learn ARM development (1)
- Learn ARM development (2)
Professor at Beihang University, dedicated to promoting microcontrollers and embedded systems for over 20 years.
- LED chemical incompatibility test to see which chemicals LEDs can be used with
- Application of ARM9 hardware coprocessor on WinCE embedded motherboard
- What are the key points for selecting rotor flowmeter?
- LM317 high power charger circuit
- A brief analysis of Embest's application and development of embedded medical devices
- Single-phase RC protection circuit
- stm32 PVD programmable voltage monitor
- Introduction and measurement of edge trigger and level trigger of 51 single chip microcomputer
- Improved design of Linux system software shell protection technology
- What to do if the ABB robot protection device stops
- Learn ARM development(14)
- Learn ARM development(15)
- Analysis of the application of several common contact parts in high-voltage connectors of new energy vehicles
- Wiring harness durability test and contact voltage drop test method
- From probes to power supplies, Tektronix is leading the way in comprehensive innovation in power electronics testing
- From probes to power supplies, Tektronix is leading the way in comprehensive innovation in power electronics testing
- Sn-doped CuO nanostructure-based ethanol gas sensor for real-time drunk driving detection in vehicles
- Design considerations for automotive battery wiring harness
- Do you know all the various motors commonly used in automotive electronics?
- What are the functions of the Internet of Vehicles? What are the uses and benefits of the Internet of Vehicles?
- Discover Schottky diodes in daily life
- [RVB2601 Creative Application Development] Graphical display and simple recognition of sound (work submission)
- TCP protocol requires restarting the circuit board for each connection
- The world is moving towards 5G. Do you think it’s time to switch to a 5G phone?
- [Good book download] 300 examples of classic intelligent circuits!
- Allegro Issues
- 【National Technology N32G430】1: Preliminary Study
- How to layout the PCB of photovoltaic power supply?
- A Beginner's Guide to PCB Design
- Ultrasonic utility knife (cutting knife) 2999RMB ???