Flash memory acceleration method and accelerator
By adopting ART technology in the MCU system, using path prediction and buffer pre-read data, and combining with the LRU algorithm to optimize Flash memory access, the problem of insufficient Flash response speed in high-speed MCU applications is solved, and the system execution efficiency and performance are significantly improved.
Patent Information
- Application Number
- CN202410623141.2
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2024-05-20
- Publication Date
- 2024-08-23
AI Technical Summary
In high-speed MCU application scenarios, the response speed of Flash memory cannot meet the processor's rapid demand for processing instructions and data, resulting in low system execution efficiency.
The ART-based Flash memory acceleration method is used to predict the high-order bus address, use the buffer (Buf, Prebuf, Cache) to pre-read data, and combine the LRU algorithm to eliminate cached instructions, optimize the data access mode, and improve the instruction reading speed.
It effectively reduces the time loss caused by instruction jumps, improves system execution efficiency, and improves the performance of MCU in high-speed scenarios, especially in 32-bit MCUs, which can double the performance.
Smart Images

Figure CN118535498A
Abstract
Description
Technical Field
[0001] The present invention relates to the field of computer storage, and in particular to an ART-based Flash memory acceleration method and an accelerator. Background Art
[0002] With the continuous development and progress of the microcontroller MCU (Micro Controller Unit) chip field, Flash Memory has been widely used in MCU chips due to its advantages of small size, large capacity, low power consumption, high reliability, etc. In the MCU system, the processor needs to read the instructions and data in the Flash to execute the preset tasks.
[0003] In recent years, the market has had more demands for MCU applications in high-speed scenarios, such as high-speed hair dryers, servo motors, robots and other equipment. These high-speed application scenarios have strict restrictions on the speed at which the processor can process instructions and data, and the number of instructions that the processor needs to process per unit time has doubled. Therefore, it is far from enough to improve Flash performance only from the perspective of process manufacturing. How to significantly increase the response speed of Flash from the level of system design has become a key factor in improving MCU performance.
[0004] ART, Adaptive Real-Time Memory Accelerator, is a technology used to improve the performance of microcontrollers. Its main function is to make up for the contradiction between high-speed CPU and relatively slow flash instruction reading. When the instruction flash reading speed is fast enough, the CPU can be accelerated accordingly. Summary of the invention
[0005] A series of simplified concepts are introduced in the Summary of the Invention, which are all simplifications of the prior art in the field, and will be further described in detail in the Detailed Description of the Invention. The Summary of the Invention of the present invention does not mean to attempt to define the key features and essential technical features of the claimed technical solution, nor does it mean to attempt to determine the scope of protection of the claimed technical solution.
[0006] The technical problem to be solved by the present invention is to provide a Flash memory acceleration method and accelerator which can independently determine the optimal instruction fetching scheme based on ART technology during program running, effectively reduce the time loss caused by instruction jumps, and improve the system execution efficiency.
[0007] In order to solve the above technical problems, the present invention provides a Flash memory acceleration method based on ART, which includes:
[0008] Step 1, using the high bit of the bus address to perform a path prediction, and accessing a corresponding storage area according to the judgment result of the path prediction; the storage area includes an ART buffer Buf, an ART prefetch buffer Prebuf, an ART cache Cache and a flash memory;
[0009] Path prediction: Use path prediction technology to predict future data access patterns, which can be achieved by analyzing the program's historical access patterns, data flows, or other related information;
[0010] Buf: It is a temporary storage area used to store recently accessed data or data to be accessed soon. According to the results of path prediction, the relevant data can be read into Buf in advance so that it can be accessed quickly when needed;
[0011] Prebuf: Similar to Buf, but it focuses more on preparing data in advance. Based on the predicted access pattern, Prebuf can pre-read related data into the buffer before the data is actually accessed to reduce future data access latency.
[0012] Cache: It is a high-speed storage device used to store frequently accessed data. Based on the results of path prediction, data that is expected to be frequently accessed can be stored in the cache to increase access speed.
[0013] Flash memory,Flash memory is a non-volatile memory;
[0014] Step 2, determine the read object and the corresponding read, write and update operations according to the CPU instruction address fetching mode;
[0015] Step 3: Eliminate cache instructions according to the LRU algorithm.
[0016] Preferably, the Flash memory acceleration method is further improved. When implementing step 2, when the CPU sequentially fetches instructions, the CPU preferentially fetches data from the read Buf; if the read Buf is empty, the read address is compared with the prefetch Buf address register. If the addresses match, data is read from the corresponding prefetch Buf. After the data is read, the data of the next adjacent address is prefetched and filled into another prefetch Buf. The two prefetch Bufs work alternately.
[0017] Preferably, the Flash memory acceleration method is further improved. When implementing step 2, the CPU fetches instructions non-sequentially, the CPU reads data from the flash memory, and stores the read 64-bit data at the end of the cache. If the non-sequential instruction fetch operation is performed again, the CPU gives priority to reading instructions from the cache and updates the address unit of the instruction cache at the same time.
[0018] Preferably, the Flash memory acceleration method is further improved. When step 4 is implemented, during the process of Cache filling or filling up, according to the LRU algorithm, the newly read instructions are stored at the end of the Cache queue, the instruction at the head of the Cache queue will be removed from the queue, and the remaining instructions will step to the head of the queue in turn.
[0019] The present invention provides a Flash memory accelerator, which is based on ART and includes:
[0020] Flash interface, which is used to transfer data with the CPU;
[0021] A data flow control module is used to control the data flow of each module of the Flash memory accelerator, perform path prediction according to the high bit of the bus address, and access the corresponding storage area according to the judgment result of the path prediction; the storage area includes an acceleration cache controller and a flash memory;
[0022] An acceleration cache controller having a read buffer (Buf), a pre-fetch buffer (Prebuf) and a cache (Cache);
[0023] The erase / write module performs corresponding erase / write operations according to the instructions of the data flow control module.
[0024] Preferably, the Flash memory accelerator is further improved so that when the CPU sequentially fetches instructions, the CPU preferentially fetches data from the read Buf; if the read Buf is empty, the read address is compared with the pre-fetch Buf address register. If the addresses match, the data is read from the corresponding pre-fetch Buf. After the data is read, the data of the next adjacent address is pre-fetched and filled into another pre-fetch Buf. The two pre-fetch Bufs work alternately.
[0025] Preferably, the Flash memory accelerator is further improved, the CPU fetches instructions non-sequentially, the CPU reads data from the flash memory, stores the read 64-bit data at the end of the cache queue, and updates the address unit of the instruction cache module at the same time; when performing the non-sequential instruction fetch operation again, the CPU preferentially reads instructions from the cache, if it matches the cache address, the cache hits, and the read data can be directly returned; if it does not hit, it returns to reading data from the flash memory.
[0026] Preferably, the Flash memory accelerator is further improved. During the process of Cache filling or filling up, according to the LRU algorithm, the newly read instructions are stored at the end of the Cache queue, the instruction at the head of the Cache queue will be removed from the queue, and the remaining instructions will step to the head of the queue in turn.
[0027] The accelerator of the present invention comprises two 8-byte instruction pre-fetch modules and a high-speed cache memory with a depth of 64, and uses the least recently used replacement algorithm LRU (least-recently used), which reduces the memory access cost of instruction missing, thereby improving the performance of the accelerator. The accelerator can judge the optimal instruction fetching scheme by itself during program running, effectively reducing the time loss caused by instruction jumps and improving the execution efficiency of the system. In a 32-bit MCU, by selecting a 64-bit wide Flash as the system main memory, the performance can be doubled under high-frequency operation. The implementation process is detailed in the specific embodiment.
[0028] The present invention can at least achieve the following technical effects:
[0029] 1. Based on the physical characteristics of 64-bit Flash, a read operation can fetch at least two 32-bit instructions or four 16-bit instructions, while general-purpose cores are usually 32 bits, thereby improving core efficiency in high-frequency systems.
[0030] 2. If the CPU fetches instructions sequentially, then in an ideal case, single-cycle continuous instruction fetching can be achieved. ART uses two 8-byte buffers, the block size is the same as the Flash bit width, and instructions can be fetched directly from the buffer, avoiding the waiting time for accessing the register.
[0031] 3. If the CPU does not fetch instructions sequentially, then in an ideal case, the instruction can be hit from the cache, achieving single-cycle instruction fetch. By using a 64-depth cache and an LRU (least recently used) replacement algorithm, the cost of instruction miss access is reduced. BRIEF DESCRIPTION OF THE DRAWINGS
[0032] The drawings of the present invention are intended to illustrate the general characteristics of the methods, structures and / or materials used in specific exemplary embodiments of the present invention, and to supplement the description in the specification. However, the drawings of the present invention are schematic diagrams not drawn to scale, and thus may not accurately reflect the precise structure or performance characteristics of any given embodiment, and the drawings of the present invention should not be interpreted as limiting or restricting the range of values or properties covered by the exemplary embodiments of the present invention. The present invention is further described in detail below in conjunction with the drawings and specific embodiments:
[0033] Figure 1 It is a design block diagram of the memory accelerator ART of the present invention.
[0034] Figure 2 This is the design block diagram of the least recently used algorithm LRU.
[0035] Figure 3 This is a schematic diagram of the Flash read timing without ART enabled, showing the Flash read timing with two wait cycles inserted.
[0036] Figure 4 This is a schematic diagram of the Flash read timing with ART enabled. DETAILED DESCRIPTION
[0037] The following describes the implementation methods of the present invention through specific specific embodiments, and those skilled in the art can fully understand other advantages and technical effects of the present invention from the contents disclosed in this specification. The present invention can also be implemented or applied through different specific implementation methods, and the details in this specification can also be applied based on different viewpoints, and various modifications or changes can be made without deviating from the overall design concept of the invention. It should be noted that the following embodiments and the features in the embodiments can be combined with each other in the absence of conflict. The following exemplary embodiments of the present invention can be implemented in a variety of different forms and should not be interpreted as being limited to the specific embodiments described herein. It should be understood that these embodiments are provided to make the disclosure of the present invention thorough and complete, and to fully convey the technical solutions of these exemplary specific embodiments to those skilled in the art.
[0038] First embodiment;
[0039] refer to Figure 1 to Figure 4 As shown, the present invention provides a Flash memory acceleration method based on ART, comprising:
[0040] Step 1: Use the high bits of the bus address to predict the way, and access the corresponding Buf, Prebuf, and Cache according to the judgment result of the way prediction;
[0041] Step 2, the instruction prefetch module of the accelerator mainly includes two 8-byte data prefetch buffers and address registers. When the CPU sequentially fetches instructions, since a 64-bit wide Flash is selected and the core is generally 32 bits, one read can obtain 2 lines of 32-bit instructions or 4 lines of 16-bit instructions, depending on the program burned into the Flash. The read 64-bit instructions are saved in the current buffer, and at least 2 CPU cycles are required to execute the instruction line read last time, so the CPU takes data from the read buffer first; if the read buffer is empty, compare the read address with the prefetch buffer address register. If the address matches, read data from the corresponding prefetch buffer. After the data is read, prefetch the data of the next adjacent address and fill it into another prefetch buffer. The two prefetch buffers work alternately.
[0042] When the CPU fetches instructions non-sequentially, that is, when the program executes a jump instruction, the sequential instruction fetch is disrupted, and the read Buf and Prebuf addresses do not match the current read address. The CPU needs to read data from the Flash. After the data is read, the 64-bit data should be stored at the end of the cache queue, and the address unit of the instruction cache module should be updated. When the program executes a non-sequential instruction fetch operation again, the CPU will give priority to reading instructions from the cache. If it matches the cache address, the cache hits, and the read data can be directly returned without consuming memory access time. If it does not hit, it returns to repeat step 2;
[0043] Step 3: During the process of Cache filling or filling up, if the CPU reads a new instruction from the Flash, the Flash memory accelerator will always store the newly read instruction at the end of the Cache according to the least recently used algorithm LRU. When the Cache is not full, the other instructions in the Cache will step to the head of the queue in turn; when the Cache is full, the instruction at the head of the queue will be removed from the queue because it has been used least recently, and the remaining instructions in the Cache will step to the head of the queue in turn. Therefore, each time the Cache is accessed, the address unit of the instruction cache module must be updated, and the instructions in the Cache are replaced out of the queue, which is related to the Cache depth and frequency of use.
[0044] Second embodiment;
[0045] The present invention provides a Flash memory accelerator, which is based on ART and includes:
[0046] Flash interface, which is used to transfer data with the CPU;
[0047] A data flow control module is used to control the data flow of each module of the Flash memory accelerator, perform path prediction according to the high bit of the bus address, and access the corresponding storage area according to the judgment result of the path prediction; the storage area includes an acceleration cache controller and a flash memory;
[0048] An acceleration cache controller having a read buffer (Buf), a pre-fetch buffer (Prebuf) and a cache (Cache);
[0049] The erase / write module performs corresponding erase / write operations according to the instructions of the data flow control module.
[0050] Among them, when the CPU fetches instructions sequentially, the CPU gives priority to fetching data from the read buffer; if the read buffer is empty, the read address is compared with the prefetch buffer address register. If the addresses match, the data is read from the corresponding prefetch buffer. After the data is read, the data of the next adjacent address is prefetched and filled into another prefetch buffer. The two prefetch buffers work alternately.
[0051] The CPU fetches instructions non-sequentially. The CPU reads data from the flash memory and stores the read 64-bit data at the end of the cache queue. At the same time, the address unit of the instruction cache module is updated. When the non-sequential instruction fetch operation is performed again, the CPU reads instructions from the cache first. If it matches the cache address, it is a cache hit and the read data can be directly returned. If it does not hit, it returns to reading data from the flash memory.
[0052] During the process of cache filling or filling up, according to the LRU algorithm, the newly read instructions are stored at the end of the cache queue, the instruction at the head of the cache queue will be removed from the queue, and the remaining instructions will step to the head of the queue in turn.
[0053] Unless otherwise defined, all terms (including technical and scientific terms) used herein have the same meaning as those commonly understood by those skilled in the art to which the present invention belongs. It will also be understood that, unless expressly defined herein, terms such as those defined in general dictionaries should be interpreted as having a meaning consistent with their meaning in the context of the relevant art, and not interpreted in an ideal or overly formal sense.
[0054] The present invention has been described in detail above through specific implementation modes and embodiments, but these do not constitute limitations of the present invention. Without departing from the principles of the present invention, those skilled in the art may also make many variations and improvements, which should also be regarded as the protection scope of the present invention.
Claims
1. A Flash memory acceleration method based on ART, characterized in that: include: Step 1, using the high bit of the bus address to perform a path prediction, and accessing a corresponding storage area according to the judgment result of the path prediction; the storage area includes an ART buffer Buf, an ART prefetch buffer Prebuf, an ART cache Cache and a flash memory; Step 2, determine the read object and the corresponding read, write and update operation according to the CPU instruction address fetching mode; Step 3: Eliminate cache instructions according to the LRU algorithm.
2. The Flash memory acceleration method as claimed in claim 1, characterized in that: When implementing step 2, when the CPU fetches instructions sequentially, the CPU gives priority to fetching data from the read buffer; if the read buffer is empty, the read address is compared with the prefetch buffer address register. If the addresses match, the data is read from the corresponding prefetch buffer. After the data is read, the data of the next adjacent address is prefetched and filled into another prefetch buffer. The two prefetch buffers work alternately.
3. The Flash memory acceleration method as claimed in claim 1, characterized in that: When implementing step 2, the CPU fetches instructions non-sequentially, reads data from the flash memory, stores the read 64-bit data at the end of the cache, and updates the address unit of the instruction cache module at the same time; when performing the non-sequential instruction fetch operation again, the CPU gives priority to reading instructions from the cache. If it matches the cache address, it is a cache hit and the read data can be directly returned; if it does not hit, repeat this step.
4. The Flash memory acceleration method as claimed in claim 1, characterized in that: When implementing step 4, during the process of Cache filling or filling up, according to the LRU algorithm, the newly read instruction is stored at the end of the Cache queue, the instruction at the head of the Cache queue will be removed from the queue, and the remaining instructions will step to the head of the queue in turn.
5. A Flash memory accelerator based on ART, characterized in that: include: Flash interface, which is used to transfer data with the CPU; A data flow control module is used to control the data flow of each module of the Flash memory accelerator, perform path prediction according to the high bit of the bus address, and access the corresponding storage area according to the judgment result of the path prediction; the storage area includes an acceleration cache controller and a flash memory; An acceleration cache controller having a read buffer (Buf), a pre-fetch buffer (Prebuf) and a cache (Cache); The erase module performs corresponding erase operations according to the instructions of the data flow control module.
6. The Flash memory accelerator as claimed in claim 5, characterized in that: When the CPU fetches instructions sequentially, the CPU gives priority to fetching data from the read buffer; if the read buffer is empty, the read address is compared with the prefetch buffer address register. If the addresses match, the data is read from the corresponding prefetch buffer. After the data is read, the data of the next adjacent address is prefetched and filled into another prefetch buffer. The two prefetch buffers work alternately.
7. The Flash memory accelerator as claimed in claim 5, characterized in that: The CPU fetches instructions non-sequentially. The CPU reads data from the flash memory and stores the read 64-bit data at the end of the cache queue. At the same time, the address unit of the instruction cache module is updated. When the non-sequential instruction fetch operation is performed again, the CPU reads instructions from the cache first. If it matches the cache address, it is a cache hit and the read data can be directly returned. If it does not hit, it returns to reading data from the flash memory.
8. The Flash memory accelerator as claimed in claim 5, characterized in that: During the process of cache filling or filling up, according to the LRU algorithm, the newly read instructions are stored at the end of the cache queue, the instruction at the head of the cache queue will be removed from the queue, and the remaining instructions will step to the head of the queue in turn.
