Embedded development cpu is an important part of digital processing system

Cpu is an important part of digital processing systems. In my opinion, microcontrollers, microprocessors, and dsps can all be called cpu, but their focus is different. Specifically, the traditional sense of the SCM is more emphasis on embedded computing, for example, we often use the 51, avr, arm chip not only contains the computing and control functions, it also covers the timer, serial port, parallel port, Usb, i2c bus and other external resources. The cpu is generally only present as a core of the dsp, and it usually contains another core that is dedicated to digital signal processing. The microprocessor, that is, the processor on the PC we often talk about, has a relatively single job and focuses on the processing of calculation and control functions. Therefore, in general, the single chip microcomputer and dsp cannot Compared to it, with the help of the South Bridge chip and the North Bridge chip, the pc's microprocessor can concentrate on its own employees, and there will be a big increase in efficiency.

For friends, the most common CPU in life is the x86 cpu. Of course, if any friend likes a toy like apple, he will know something about arm. The rest is the cpu of some special fields, such as the more powerpc chips used in the communications industry, the sun sparc chips used in high-performance servers, and the mips chips used in scientific computing. Therefore, no matter what chips are encountered, the same applies to the development of friends at the application layer, but only in some small places need to pay attention to. For example:

(1) Data alignment

(2) The problem of endianness of data

(3) Pushing of function parameters

(4) Execution problems of cpu

(5) Cpu cache and memory consistency issues

Of course, if we want to think about simple application layer design, considering that these contents are already very difficult. However, we consider the question of how to design an embedded operating system, so let's also look at what the general cpu contains below. In this way, as long as you have mastered the design and implementation of a cpu, the knowledge of other cpu will be comprehended.

Any cpu, no matter what the function is completed, usually has these basic designs:

Register

Stack register

Pc register

Status register

Arithmetic register

Registers are the basic resources inside the CPU. Regardless of when the cpu code is executed, these resources are shared, so these registers need to be protected when the cpu interrupts, function calls, and thread switches. The basic measure is to save them to the temporary stack. go with. The stack register records where the current stack is used, the pc register keeps track of where the current code has run, where the next instruction is, and so on. The status register saves the current execution of the CPU, including whether the calculation overflows, whether the interrupt is off or on, whether there is an o divisor exception, and so on. As for the arithmetic register, it varies depending on the CPU, and some cpu registers are relatively few, for example x86 registers; some cpu registers are more, such as powerpc. The use of arithmetic registers is used for many purposes, such as data access, calculations, shifting, returning calculation results, and so on.

2. Instruction set

Addressing instructions

Math operation instructions

Logical operation instructions

Soft interrupt instruction

Jump instruction

Remote call instruction

Io access instructions

Stack operation instructions

The instruction set directly determines the type of a particular CPU. Just as intel and amd produce cpu though there are differences, but their cpu uses the x86 instruction set, and the marwell, samsung, and qualcomm production cpu are certainly different, but their instruction set is the arm instruction set. So, if the software runs on marwell, it can generally run on Samsung. The instruction set is very complicated and has many contents. But generally speaking, the above contents are all kinds of instructions that cpu must complete. Of course, the most important thing is interrupt and stack processing instructions.

3. Interrupts and exception handling mechanisms

No matter what cpu, the content of the interruption is indispensable. Just think about it, if a cpu only knows to keep running, its execution efficiency is actually very low. Having an interrupted CPU not only allows the CPU to deal with more peripheral IOs, but also greatly improves the efficiency of its own operation. Different methods of handling CPU interrupts are similar. In the entire CPU address space, there is usually an interrupt vector table in the lower address area. Each entry in the table records the processing function corresponding to each interrupt.

Therefore, as long as the interrupt occurs, the CPU will first push the next pc address onto the stack, and then jump to the corresponding processing function executed at the corresponding interrupt address in the interrupt vector table. This process is done automatically by the cpu and does not require us to care. This way, for us, it is actually no different from the function call in the cpu. After waiting for the interrupt handler to complete, we use the ret instruction to return to the previously pushed IP address and continue with the following code. The whole process is like the interruption did not happen at all.

Therefore, the understanding of cpu is mainly to understand the register, instruction set and interrupt. With an in-depth understanding of interrupts and stacks, there is actually no difficulty.

Keyboard

Wireless Mechanical Keyboard,Adjustable Tilt Keyboard,Laser Keyboard,Multimedia Button Keyboard

Guangzhou Lufeng Electronic Technology Co. , Ltd. , https://www.lufengelectronics.com