Home > Common Problem > Where the program must be stored before it can be accessed and executed by the CPU

Where the program must be stored before it can be accessed and executed by the CPU

coldplay.xixi
Release: 2020-08-29 11:12:28
Original
14434 people have browsed it

The program must be stored in the memory before it can be accessed and executed by the CPU, and the contents of the instruction register need to be transferred to the address bus first. When the PC runs the program, it transfers the program from the external memory to the RAM. When the CPU is running, the program is directly read from the flash.

Where the program must be stored before it can be accessed and executed by the CPU

When the CPU executes a program, the instruction must exist in the memory, and the contents of the instruction register need to be transferred to the address bus first.

The specific way for x86cpu and microcontroller to read the program. When running the program, the pc transfers the program from the external memory (hard disk) to RAM and runs it from Programs and data are read from the RAM, while the program of the microcontroller is solidified in the flash. When the CPU is running, the program is read directly from the flash, and the data is read from the RAM. The specific reasons for this difference are analyzed. The x86 architecture CPU is based on Feng Neumann system, that is, data and programs are stored together, and the RAM resources of PCs are quite abundant, ranging from tens of M to hundreds of M or even several G, which can objectively withstand a large amount of program data.

The architecture of single-chip microcomputers is mostly Haval system, that is, programs and data are stored separately, and the on-chip RAM resources of a single chip are quite limited. Excessive internal RAM will bring costs. substantial improvement. From the above analysis, it can be known that the program of the microcontroller can be stored in flash based on two considerations, namely the architecture and the amount of RAM resources.

Therefore, today, as technology not only advances but on-chip RAM capacity continues to increase, RAM resources are no longer the main factor restricting this difference. For the system structure, we only need to change the way the CPU reads the program. .

The specific method of storing embedded system programs in RAM "For many embedded systems, many of their codes are stored in norflash and run directly in flash. I recently learned that my new A piece of code in the company's software was loaded into RAM in order to improve the running speed. They spent a lot of time solving this problem at that time. I carefully studied the link script and used the GNU Linux cross tool chain. .Address allocation is written in an ld script.

They are implemented as follows: 1. Write the code you need to run in ram in a separate c file, and then set it in the script The running address is separated from the storage address. Set the necessary flag variables for the start and end of the code. 2. Copy the code at the storage address to the running address in the code. The difference between the Von Neumann system and the Harvard system The difference is whether the program space and the data space are integrated.

Most early microprocessors adopted the von Neumann structure, with the typical representative being Intel's X86 microprocessor. Take Instructions and operand fetching are both on the same bus and are performed through time-division multiplexing. The disadvantage is that when running at high speed, instructions and operands cannot be fetched at the same time, thus forming a bottleneck in the transmission process.

The application of Harvard bus technology is represented by DSP and ARM. The internal program space and data space of the chip using the Harvard bus architecture are separated, which allows instructions and operands to be fetched at the same time, thereby greatly improving the computing power. For example, the STM320LF240x series DSP is an enhanced Harvard structure that accesses multiple storage spaces through three sets of parallel buses.

If you want to learn more about programming, please pay attention to the php training column !

The above is the detailed content of Where the program must be stored before it can be accessed and executed by the CPU. For more information, please follow other related articles on the PHP Chinese website!

Related labels:
source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template