(1) embedded microprocessor
The core of embedded system hardware layer is embedded microprocessor. The biggest difference between embedded microprocessor and general CPU is that most embedded microprocessors work in systems specially designed for specific user groups. It integrates many tasks of general CPU completed by the board into the chip, which is beneficial to the miniaturization of embedded system in design, and also has high efficiency and reliability.
The architecture of embedded microprocessor can adopt von Neumann architecture or Harvard architecture; The instruction system can choose reduced instruction set computer (RISC) and complex instruction set computer (CISC). RISC computer only contains the most useful instructions in the channel, which ensures that the data channel can execute each instruction quickly, thus improving the execution efficiency and making the design of CPU hardware structure simpler.
Embedded microprocessors have different architectures. Even in the same architecture, they may have different clock frequencies and data bus widths, or integrate different peripherals and interfaces. According to incomplete statistics, there are more than 1000 kinds of embedded microprocessors in the world and more than 30 series of architectures, among which the mainstream systems are ARM, MIPS, PowerPC, X86 and SH. However, unlike the global PC market, no embedded microprocessor can dominate the market. Only 32-bit products have more than 65,438+000 embedded microprocessors. The choice of embedded microprocessor depends on the specific application.
(2) Memory
Embedded systems need memory to store and execute code. The memory of embedded system includes cache, main memory and auxiliary memory, and its storage structure is shown in figure 1-2.
1 & gt; stash
Cache is a memory array with small capacity and high speed. It is located between the main memory and the embedded microprocessor core, and stores the most commonly used program codes and data for a period of time. When data needs to be read, the microprocessor reads data from the cache as much as possible, rather than from the main memory, which greatly improves the performance of the system and improves the data transmission rate between the microprocessor and the main memory. The main goal of Cache is to reduce the memory access bottleneck caused by memory (such as main memory and auxiliary memory) to the microprocessor core, so that the processing speed is faster and the real-time performance is stronger.
In embedded system, caches are all integrated in embedded microprocessor, which can be divided into data cache, instruction cache or mixed cache, and the size of caches depends on different processors. Generally, high-end embedded microprocessors will integrate cache.
2> main memory
Main memory is a register that embedded microprocessor can directly access, and it is used to store programs and data of the system and users. It can be located inside or outside the microprocessor with a capacity of 256KB~ 1GB. Generally, the on-chip memory has small capacity and high speed, and the off-chip memory has large capacity, depending on the specific application.
Commonly used as main memory are:
ROM classes include NOR Flash, EPROM and PROM.
RAM class SRAM, DRAM and SDRAM, etc.
Among them, NOR Flash has been widely used in the embedded field because of its advantages of many erasable times, fast storage speed, large storage capacity and low price.
3> auxiliary memory
Auxiliary memory is used to store a large number of program codes or information. It has a large capacity, but its reading speed is much slower than that of main memory. It is used to store users' information for a long time.
External memory commonly used in embedded systems: hard disk, NAND Flash, CF card, MMC, SD card.
(3) General equipment interface and I/O interface
The interaction between embedded system and the outside world needs some common device interfaces, such as A/D, D/A, I/O, etc. The peripheral realizes the input/output function of the microprocessor by connecting other off-chip devices or sensors. Each peripheral usually has only one function, which can be off-chip or built-in. There are many kinds of peripherals, from simple serial communication devices to very complex 802.438+0438+0 wireless devices.
Common device interfaces in embedded systems are A/D (analog-to-digital conversion interface) and D/A (digital-to-analog conversion interface), and I/O interfaces are RS-232 (serial communication interface), Ethernet (Ethernet interface), USB (universal serial bus interface), audio interface, VGA video output interface, I2C (field bus) and SPI. There is an intermediate layer between the hardware layer and the software layer, which is also called Hardware Abstraction Layer (HAL) or Board Support Package (BSP). It separates the upper software from the lower hardware, so that the lower driver of the system has nothing to do with the hardware. The upper software developer can develop according to the interface provided by BSP layer, without caring about the specific situation of the lower hardware. This layer generally includes initialization of related underlying hardware, data input and output operations and configuration functions of hardware devices. BSP has the following two characteristics.
Hardware Dependence: Because the hardware environment of embedded real-time system has application dependency, BSP, as the interface of upper software and hardware platform, needs to provide the operating system with methods to operate and control specific hardware.
Operating system correlation: Different operating systems have their own software hierarchy, so different operating systems have specific hardware interface forms.
In fact, BSP is a software layer between the operating system and the underlying hardware, including most software modules closely related to the hardware in the system. Designing a complete BSP needs to complete two parts: hardware initialization of embedded system and BSP functions, and designing hardware-related device drivers.