Self-adaptive compression method dynamically selected according to real-time data mode
By real-time detection of the pattern of PC address sequence in an embedded system and dynamically selecting the compression algorithm, the problem that static compression strategies in the prior art cannot adapt to data pattern changes is solved, and more efficient data compression and system performance is achieved.
Patent Information
- Application Number
- CN202411632954.4
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2024-11-15
- Publication Date
- 2025-02-28
AI Technical Summary
Data compression technology in existing embedded systems relies on static strategies and cannot be dynamically adjusted according to real-time data changes, resulting in poor compression efficiency in different application scenarios, especially inability to effectively cope with rapid changes in data patterns.
An adaptive compression method is provided, by real-time detection of the mode of the program counter (PC) address sequence, dynamically selecting the most suitable compression algorithm, including repeated address processing, continuous address processing and random address processing.
Improves data compression efficiency, reduces system cost and complexity, improves system performance and real-time, and reduces system power consumption, suitable for embedded applications that are sensitive to power consumption.
Smart Images

Figure CN119536813A_ABST
Abstract
Description
Technical Field
[0001] The invention relates to the field of embedded systems, and in particular to an adaptive compression method dynamically selected according to a real-time data mode. Background Art
[0002] Currently, in the field of embedded systems, data compression technology mainly relies on static compression strategies. These strategies are determined at design time and cannot be dynamically adjusted according to real-time data changes, resulting in poor compression efficiency in different application scenarios. In particular, existing technologies cannot effectively cope with rapid changes in data patterns, such as the variability of program counter (PC) address sequences. These address sequences may show repetitive, continuous or random patterns during execution, and static compression algorithms can often only optimize for one of the patterns and cannot fully adapt to various data patterns, thus affecting the overall performance and compression efficiency of the system. Summary of the invention
[0003] In order to overcome the deficiencies of the above technologies, the present invention provides a method for dynamically selecting the most suitable compression algorithm according to the real-time data mode.
[0004] The technical solution adopted by the present invention to overcome the technical problems is: An adaptive compression method dynamically selected according to real-time data patterns, comprising: S1. Initialize the previous PC address prev_PC; S2. Determine whether there is a new PC address input, if yes, execute step S3, if not, execute step S8; S3. Read the current PC address curr_PC; S4. Determine whether the current PC address curr_PC is repeated, if it is repeated address processing, if otherwise, execute step S5; S5. Determine whether the current PC address curr_PC is a continuous address or a random address. If it is a continuous address, execute step S6; if it is a random address, execute step S7; S6. Perform continuous address processing; S7. Perform random address processing; S8. Complete the processing after the cycle ends.
[0005] Further, step S1 includes the following steps: S1-1. Initialize the initial value of the previous PC address prev_PC after reading the first PC address; S1-2. Initialize the repeat counter repeat_count, the repeat counter repeat_count records the number of consecutively repeated addresses, and set the initial value of the repeat counter repeat_count to 1; S1-3. Initialize the continuous counter dalta_count, the continuous counter dalta_count records the number of continuous addresses, and set the initial value of the continuous counter dalta_count to 1; S1-4. Initialize the current data mode. The initial value of the current data mode is undefined.
[0006] Furthermore, after reading the current PC address curr_PC in step S3, the next PC address is read from the input data stream.
[0007] Further, step 4 includes the following steps: S4-1. If the previous PC address prev_PC is equal to the current PC address curr_PC, it is determined to be a duplicate address; S4-2. Increase the repeat counter repeat_count by 1; S4-3. Update prev_PC = curr_PC; S4-4. Return to execute step S2.
[0008] Furthermore, in step S5, if the difference between the previous PC address prev_PC and the current PC address curr_PC is a fixed value, it is determined that the current mode is a continuous address; if the difference is not a fixed value, it is determined that the current mode is a random address.
[0009] Preferably, the fixed value is 1.
[0010] Further, step S6 includes the following steps: S6-1. Add 1 to the continuous counter dalta_count; S6-2. Update prev_PC = curr_PC; S6-3. Return to execute step S2.
[0011] Further, step S7 includes the following steps: S7-1. If the current PC address curr_PC is a repeated address and repeat_count>1, then output the run-length encoded RLE data packet and reset repeat_count=1; S7-2. If the current PC address curr_PC is a continuous address and dalta_count>1, then output the difference encoding Delta data packet and reset dalta_count=1; S7-3. Adaptively Huffman encode the current PC address curr_PC and output it; S7-4. Update prev_PC = curr_PC; S7-5. Return to execute step S2.
[0012] Further, step S8 includes the following steps: S8-1. If the current PC address curr_PC is a repeated address and repeat_count> 1, the run-length encoded RLE data packet is output; S8-2. If the current PC address curr_PC is a continuous address and dalta_count>1, then the difference encoded Delta data packet is output.
[0013] The beneficial effects of the present invention are: improved data compression efficiency: an adaptive hardware compression algorithm is adopted to dynamically select the optimal compression algorithm according to the real-time data mode, saving storage space. Reduced system cost and complexity: data parsing and compression are completed inside the chip, without the need for external pins and tracking tools, reducing packaging costs and system complexity. Improved system performance: the hardware module runs independently, does not occupy CPU resources, and ensures the real-time performance of the system. Reduced system power consumption: a low-power design strategy is adopted to dynamically adjust power consumption according to system load, reducing the overall power consumption of the system, and is suitable for embedded applications that are sensitive to power consumption. Possessing good configurability and extensibility: through the configuration interface, users can flexibly set compression parameters and monitoring ranges to meet different application requirements. BRIEF DESCRIPTION OF THE DRAWINGS
[0014] Figure 1 The method flow of the present invention Figure I ; Figure 2 The method flow of the present invention Figure II ; Figure 3 The method flow of the present invention Figure III . DETAILED DESCRIPTION
[0015] The following is combined with Figure 1 , Attachment Figure 2 , Attachment Figure 3 The present invention is further described.
[0016] An adaptive compression method dynamically selected according to real-time data patterns, comprising: S1. Initialize the previous PC address prev_PC.
[0017] S2. Determine whether a new PC address is input, if yes, execute step S3, if not, execute step S8.
[0018] S3. Read the current PC address curr_PC.
[0019] S4. Determine whether the current PC address curr_PC is repeated. If so, perform duplicate address processing. If not, execute step S5.
[0020] S5. Determine whether the current PC address curr_PC is a continuous address or a random address. If it is a continuous address, execute step S6; if it is a random address, execute step S7.
[0021] S6. Perform continuous address processing.
[0022] S7. Perform random address processing.
[0023] S8. Complete the processing after the cycle ends.
[0024] According to the real-time characteristics of the program counter (PC) address sequence, the optimal compression strategy is dynamically selected to improve data compression efficiency and system performance. The algorithm mainly includes three compression methods: differential coding, run length coding and adaptive Huffman coding. Through the compression strategy control module, intelligent switching is performed according to the mode of input data (repeated, continuous, random). The principles and algorithm flow of each compression method will be introduced in detail below.
[0025] In one embodiment of the present invention, step S1 comprises the following steps: S1-1. Initialize the initial value of the previous PC address prev_PC is set after reading the first PC address.
[0026] S1-2. Initialize the repeat counter repeat_count, which records the number of consecutively repeated addresses. Set the initial value of the repeat counter repeat_count to 1.
[0027] S1-3. Initialize the continuous counter dalta_count, the continuous counter dalta_count records the number of continuous addresses, and the initial value of the continuous counter dalta_count is set to 1.
[0028] S1-4. Initialize the current data mode. The initial value of the current data mode is undefined.
[0029] In one embodiment of the present invention, after reading the current PC address curr_PC in step S3, the next PC address is read from the input data stream.
[0030] In one embodiment of the present invention, step 4 comprises the following steps: S4-1. If the previous PC address prev_PC is equal to the current PC address curr_PC, it is determined to be a duplicate address.
[0031] S4-2. Increase the repeat counter repeat_count by 1.
[0032] S4-3. Update prev_PC=curr_PC.
[0033] S4-4. Return to execute step S2.
[0034] In one embodiment of the present invention, in step S5, if the difference between the previous PC address prev_PC and the current PC address curr_PC is a fixed value, the current mode is determined to be a continuous address; if the difference is not a fixed value, the current mode is determined to be a random address.
[0035] In this embodiment, preferably, the fixed value is 1.
[0036] In one embodiment of the present invention, step S6 includes the following steps: S6-1. Increase the continuous counter dalta_count by 1.
[0037] S6-2. Update prev_PC=curr_PC.
[0038] S6-3. Return to execute step S2.
[0039] In one embodiment of the present invention, step S7 includes the following steps: S7-1. If the current PC address curr_PC is a repeated address and repeat_count>1, reset repeat_count=1 after outputting the run-length encoded RLE data packet.
[0040] S7-2. If the current PC address curr_PC is a continuous address and dalta_count>1, then output the difference encoded Delta data packet and reset dalta_count=1.
[0041] S7-3. Perform adaptive Huffman encoding on the current PC address curr_PC and output it.
[0042] S7-4. Update prev_PC = curr_PC.
[0043] S7-5. Return to execute step S2.
[0044] In one embodiment of the present invention, step S8 includes the following steps: S8-1. If the current PC address curr_PC is a repeated address and repeat_count>1, a run-length encoded RLE data packet is output.
[0045] S8-2. If the current PC address curr_PC is a continuous address and dalta_count>1, then the difference encoded Delta data packet is output.
[0046] Finally, it should be noted that the above description is only a preferred embodiment of the present invention and is not intended to limit the present invention. Although the present invention has been described in detail with reference to the aforementioned embodiments, those skilled in the art can still modify the technical solutions described in the aforementioned embodiments or replace some of the technical features therein by equivalents. Any modification, equivalent replacement, improvement, etc. made within the spirit and principle of the present invention shall be included in the protection scope of the present invention.
Claims
1. An adaptive compression method dynamically selected according to real-time data mode, characterized in that: include: S1. Initialize the previous PC address prev_PC; S2. Determine whether there is a new PC address input, if yes, execute step S3, if otherwise, execute step S8; S3. Read the current PC address curr_PC; S4. Determine whether the current PC address curr_PC is repeated, if it is repeated address processing, if otherwise, execute step S5; S5. Determine whether the current PC address curr_PC is a continuous address or a random address. If it is a continuous address, execute step S6; if it is a random address, execute step S7; S6. Perform continuous address processing; S7. Perform random address processing; S8. Complete the processing after the cycle ends.
2. The adaptive compression method according to claim 1, characterized in that: Step S1 includes the following steps: S1-1. Initialize the initial value of the previous PC address prev_PC after reading the first PC address; S1-2. Initialize the repeat counter repeat_count, the repeat counter repeat_count records the number of consecutively repeated addresses, and set the initial value of the repeat counter repeat_count to 1; S1-3. Initialize the continuous counter dalta_count, the continuous counter dalta_count records the number of continuous addresses, and set the initial value of the continuous counter dalta_count to 1; S1-4. Initialize the current data mode. The initial value of the current data mode is undefined.
3. The adaptive compression method according to claim 1, characterized in that: After reading the current PC address curr_PC in step S3, the next PC address is read from the input data stream.
4. The adaptive compression method according to claim 2, characterized in that: Step 4 includes the following steps: S4-1. If the previous PC address prev_PC is equal to the current PC address curr_PC, it is determined to be a duplicate address; S4-2. Increase the repeat counter repeat_count by 1; S4-3. Update prev_PC = curr_PC; S4-4. Return to execute step S2.
5. The adaptive compression method according to claim 1, characterized in that: In step S5, if the difference between the previous PC address prev_PC and the current PC address curr_PC is a fixed value, it is determined that the current mode is a continuous address; if the difference is not a fixed value, it is determined that the current mode is a random address.
6. The adaptive compression method according to claim 5, characterized in that: The fixed value is 1.
7. The adaptive compression method according to claim 2, characterized in that: Step S6 includes the following steps: S6-1. Add 1 to the continuous counter dalta_count; S6-2. Update prev_PC = curr_PC; S6-3. Return to execute step S2.
8. The adaptive compression method according to claim 2, characterized in that: Step S7 includes the following steps: S7-1. If the current PC address curr_PC is a repeated address and repeat_count>1, then output the run-length encoded RLE data packet and reset repeat_count=1; S7-2. If the current PC address curr_PC is a continuous address and dalta_count>1, then output the difference encoding Delta data packet and reset dalta_count=1; S7-3. Adaptively Huffman encode the current PC address curr_PC and output it; S7-4. Update prev_PC = curr_PC; S7-5. Return to execute step S2.
9. The adaptive compression method according to claim 2, characterized in that: Step S8 includes the following steps: S8-1. If the current PC address curr_PC is a repeated address and repeat_count> 1, the run-length encoded RLE data packet is output; S8-2. If the current PC address curr_PC is a continuous address and dalta_count>1, then the difference encoded Delta data packet is output.