A method of dynamic compression of instruction sets

By grouping the instruction set and recording the difference information, a compressed binary file is generated, which solves the problem of excessively large binary files caused by instruction redundancy and achieves more efficient storage and transmission.

CN122111507APending Publication Date: 2026-05-29METAX INTEGRATED CIRCUITS (SHANGHAI) CO LTD

Patent Information

Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
METAX INTEGRATED CIRCUITS (SHANGHAI) CO LTD
Filing Date
2026-04-24
Publication Date
2026-05-29

AI Technical Summary

Technical Problem

Existing technologies suffer from excessively large binary file sizes due to instruction redundancy. Traditional instructions have fixed lengths and cannot effectively reduce redundancy.

Method used

The instruction set is grouped, the key instructions in each group are identified, and the difference information between other instructions and the key instructions is recorded. The resulting compressed binary file stores only the key instructions and the difference information.

Benefits of technology

By using dynamic compression methods, the size of binary files is reduced, the cost of instruction storage and transmission is lowered, and the problem of instruction redundancy is effectively solved.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN122111507A_ABST
    Figure CN122111507A_ABST
Patent Text Reader

Abstract

The application relates to the chip design technical field, in particular to a kind of instruction set dynamic compression method.It includes: the instruction in original instruction set is grouped, and a key instruction is determined for each group;Wherein, each group includes at least 1 instruction, if a group includes more than 2 instructions, then the difference between any two adjacent instructions included in the group is less than or equal to the preset difference threshold;If a group includes other instructions in addition to the key instruction, then obtain the instruction difference information between each other instruction and the key instruction of the group;The instruction difference information between any other instruction and the key instruction of the group is used to represent the value and position information of the difference field between the other instruction and the key instruction of the group;Generate compressed binary file, the compressed binary file includes the encoding information of each group.The application can solve the problem of instruction redundancy and reduce the size of binary file.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] This invention relates to the field of chip design technology, and in particular to a method for dynamic instruction set compression. Background Technology

[0002] An instruction set (ISA) is the interface between software and hardware in a computer system. Software code is compiled by a compiler to generate a binary file, which contains instructions one by one. The hardware reads this binary file and then parses it according to the conventions of the instruction set to determine the function, configuration, source operands, destination operands, etc., of each instruction.

[0003] Traditional instructions, whether from Complex Instruction Set Computers (CISC) or Reduced Instruction Set Computers (RISC), have a fixed instruction length, such as 32 bits, 64 bits, or 120 bits. The number of instructions determines the size of the generated binary file. This facilitates decoding but introduces redundancy; for example, a program might perform the same operation only with different operands. Solving the problem of instruction redundancy and reducing the size of the binary file is a pressing issue. Summary of the Invention

[0004] The purpose of this invention is to provide a dynamic instruction set compression method to solve the problem of instruction redundancy and reduce the size of binary files.

[0005] According to the present invention, a method for dynamic compression of instruction sets is provided, the method comprising the following steps: S100: Obtain the raw instruction set consisting of multiple instructions.

[0006] S200, the instructions in the original instruction set are grouped, and a key instruction is determined for each group; wherein each group includes at least one instruction, and if a group includes more than two instructions, the difference between any two adjacent instructions in the group is less than or equal to a preset difference threshold.

[0007] S300, if a group includes other instructions besides the key instruction, then obtain the instruction difference information between each other instruction and the key instruction of the group; the instruction difference information between any other instruction and the key instruction of the group is used to characterize the value and position information of the difference field between the other instruction and the key instruction of the group.

[0008] S400, generate a compressed binary file, wherein the compressed binary file includes the encoding information of each group; wherein, if a group includes only 1 instruction, the encoding information of the group is the key instruction of the group or the result of lossless compression of the key instruction of the group; if a group includes 2 or more instructions, the encoding information of the group is the instruction difference information corresponding to the key instruction of the group and other instructions besides the key instruction, or the result of lossless compression of the instruction difference information corresponding to the key instruction of the group and other instructions besides the key instruction.

[0009] Compared with the prior art, the present invention has at least the following beneficial effects: This invention groups the instructions in the original instruction set, obtains the instruction difference information between the instructions in each group (excluding the critical instruction) and the critical instruction, and the generated compressed binary file includes only the instruction difference information (or the result of compression) corresponding to the critical instruction and the other instructions in each group. Thus, this invention introduces dynamic compression, identifying and eliminating instruction redundancy at the instruction set level (rather than within a single instruction), grouping highly similar instructions into a single group, storing only one complete critical instruction within each group, and storing only the differences of the remaining instructions. Compared to existing solutions that store a large number of similar instructions, this invention stores only the differences of the remaining instructions within a group (excluding the critical instruction), reducing the cost of instruction storage and transmission, solving the problem of instruction redundancy, and reducing the size of the binary file. Attached Figure Description

[0010] To more clearly illustrate the technical solutions in the embodiments of the present invention, the accompanying drawings used in the description of the embodiments will be briefly introduced below. Obviously, the accompanying drawings described below are only some embodiments of the present invention. For those skilled in the art, other drawings can be obtained based on these drawings without creative effort.

[0011] Figure 1 A flowchart of the instruction set dynamic compression method provided in an embodiment of the present invention. Detailed Implementation

[0012] The technical solutions of the embodiments of the present invention will be clearly and completely described below with reference to the accompanying drawings. Obviously, the described embodiments are only some embodiments of the present invention, and not all embodiments. Based on the embodiments of the present invention, all other embodiments obtained by those skilled in the art without creative effort are within the scope of protection of the present invention.

[0013] According to this embodiment, a method for dynamic compression of instruction sets is provided, the method including the following steps, such as... Figure 1 As shown: S100: Obtain the raw instruction set consisting of multiple instructions.

[0014] In this embodiment, the order of instructions in the original instruction set is fixed, and the length of each instruction in the original instruction set is equal. Optionally, the instructions can be binary instructions or non-binary instructions.

[0015] S200, the instructions in the original instruction set are grouped, and a key instruction is determined for each group; wherein each group includes at least one instruction, and if a group includes more than two instructions, the difference between any two adjacent instructions in the group is less than or equal to a preset difference threshold.

[0016] As an optional implementation, the difference between any two adjacent instructions is the sum of the absolute values ​​of the differences between their corresponding fields. For example, if two adjacent instructions are 0001_0001_0001 and 0001_0002_0001, then the difference between these two adjacent instructions is 1; as another example, if two adjacent instructions are 0001_0001_0001 and 0001_0003_0001, then the difference between these two adjacent instructions is 2.

[0017] As another optional implementation, the difference between any two adjacent instructions is the sum of the XOR results of their corresponding fields. For example, if two adjacent instructions are 0001_0001_0001 and 0001_0002_0001, then the difference between these two adjacent instructions is 1; as another example, if two adjacent instructions are 0001_0001_0001 and 0001_0003_0001, then the difference between these two adjacent instructions is 1.

[0018] As a specific implementation, grouping the instructions in the original instruction set includes: S201: Scan the instructions in the original instruction set according to their order, and sequentially obtain the differences between two adjacent instructions.

[0019] S202, sequentially determine whether the obtained differences are less than or equal to the preset difference threshold. If not, the previous instruction corresponding to the difference is assigned to the current group and the group is ended. The next instruction corresponding to the difference is used as the starting instruction of a new group. If yes, the previous and next instructions corresponding to the difference are assigned to the current group. Continue to determine whether the next difference is less than or equal to the preset difference threshold until the determination result is no or all differences are determined.

[0020] As an optional specific implementation, the preset difference threshold is an empirical value; when the difference between two instructions is less than or equal to the preset difference threshold, the two instructions are determined to be similar; otherwise, the two instructions are determined to be dissimilar.

[0021] In this embodiment, each group includes at least one instruction. For example, if the difference between the first and second instructions in the original instruction set is greater than a preset difference threshold, the difference between the second and third instructions in the original instruction set is greater than a preset difference threshold, and the difference between the third and fourth instructions in the original instruction set is less than or equal to a preset difference threshold, then the first instruction is in a separate group, the second instruction is in a separate group, and the third and fourth instructions are combined into one group.

[0022] As an optional specific implementation, determining a key instruction for each group includes: determining the first instruction, any instruction, or the instruction with the highest frequency of occurrence of any group as the key instruction of that group.

[0023] As a preferred embodiment, determining a key instruction for each group includes: S210, for any group, if the number of instructions included in the group is greater than or equal to a preset number threshold, then proceed to S220; the preset number threshold is greater than or equal to 3.

[0024] In this embodiment, if a group includes 1 or 2 instructions, as an optional specific implementation, the first instruction in the group can be determined as the key instruction.

[0025] Optionally, the preset quantity threshold is an empirical value.

[0026] S220, obtain the total difference between each instruction in the group and other instructions, and determine the instruction with the smallest total difference as the key instruction of the group.

[0027] In this embodiment, the difference between any two instructions in a group can be calculated. Therefore, the total difference between each instruction in the group and other instructions can also be calculated. For example, for a group containing four instructions, the total difference between the first instruction and other instructions in the group is: the difference between the first instruction and the second instruction, diff. 1,2 +Difference between instruction 1 and instruction 3 (diff) 1,3 +Difference between instruction 1 and instruction 4 (diff) 1,4 The total difference between instruction 2 and other instructions in this group is: the difference between instruction 1 and instruction 2 (diff). 1,2 +Difference between instruction 2 and instruction 3 2,3+Difference between instruction 2 and instruction 4 2,4 The total difference between instruction 3 and other instructions in this group is: the difference between instruction 1 and instruction 3 (diff). 1,3 +Difference between instruction 2 and instruction 3 2,3 +Difference between instruction 3 and instruction 4 (diff) 3,4 The total difference between instruction 4 and other instructions in this group is: the difference between instruction 1 and instruction 4 (diff). 1,4 +Difference between instruction 2 and instruction 4 2,4 +Difference between instruction 3 and instruction 4 (diff) 3,4 .

[0028] Based on S110-S120, the instruction with the smallest difference from other instructions in the group can be selected as the critical instruction. As a result, the total difference between the critical instruction and other instructions in the group is small, which can reduce the average length of the instruction difference information obtained later, and further reduce the size of the binary file after compression.

[0029] S300, if a group includes other instructions besides the key instruction, then obtain the instruction difference information between each other instruction and the key instruction of the group; the instruction difference information between any other instruction and the key instruction of the group is used to characterize the value and position information of the difference field between the other instruction and the key instruction of the group.

[0030] As a specific implementation, obtaining the instruction difference information between each other instruction and the key instruction of the group includes: S310, compare the target instruction with the corresponding field of the key instruction in the group; the target instruction is any other instruction.

[0031] S320 identifies all fields with differing values ​​and records the value difference of each field with differing values ​​in the target instruction relative to the key instruction of that group.

[0032] For example, a key instruction in a group is 0001_0001_0001. This group also includes two other instructions, 0001_0002_0001 and 0001_0003_0001. For this group, 0001_0002_0001 differs from the key instruction 0001_0001_0001 in the value of the fifth field, and the difference is 1. 0001_0003_0001 also differs from the key instruction 0001_0001_0001 in the value of the fifth field, and the difference is 2.

[0033] S330: Based on the value difference and the corresponding field position information, generate instruction difference information between the target instruction and the key instruction of the group.

[0034] As an optional implementation, the instruction difference information includes at least one encoding unit, each encoding unit containing a value difference and corresponding field position information. For example, if 0001_0002_0001 has a value difference of 1 in the 5th field compared to the critical instruction 0001_0001_0001, then the corresponding instruction difference information includes one encoding unit, which is used to specify that the field with the value difference is the 5th field and that the corresponding value difference is 1. As another example, if 0001_0002_0003 has value differences of 2 and 1 in the 1st and 5th fields compared to the critical instruction 0001_0001_0001, then the corresponding instruction difference information includes two encoding units: one encoding unit is used to specify that the field with the value difference is the 1st field and that the corresponding value difference is 2; the other encoding unit is used to specify that the field with the value difference is the 5th field and that the corresponding value difference is 1. As a specific implementation, an encoding unit is represented as: [value difference][field position], and the instruction difference information is represented as: [first value difference][first field position][second value difference][second field position]...

[0035] S400, generate a compressed binary file, wherein the compressed binary file includes the encoding information of each group; wherein, if a group includes only 1 instruction, the encoding information of the group is the key instruction of the group or the result of lossless compression of the key instruction of the group; if a group includes 2 or more instructions, the encoding information of the group is the instruction difference information corresponding to the key instruction of the group and other instructions besides the key instruction, or the result of lossless compression of the instruction difference information corresponding to the key instruction of the group and other instructions besides the key instruction.

[0036] In this embodiment, the positional relationship between key instructions and instruction difference information in the generated compressed binary file is the same as the positional relationship of their corresponding instructions in the original instruction set, to ensure that the order of instructions obtained by decompressing the compressed binary file is the same as their order in the original instruction set. For example, if the difference between the first and second instructions in the original instruction set is greater than a preset difference threshold, the difference between the second and third instructions in the original instruction set is greater than a preset difference threshold, and the difference between the third and fourth instructions in the original instruction set is less than or equal to a preset difference threshold, then the key instruction in the first group of the compressed binary file is the first instruction in the original instruction set, and the key instruction in the second group of the compressed binary file is the second instruction in the original instruction set. If the method of determining the first instruction in each group as the key instruction is adopted, then the key instruction in the third group of the compressed binary file is the third instruction in the original instruction set, and the instruction difference information of the first instruction in the third group of the compressed binary file is the instruction difference information corresponding to the fourth instruction in the original instruction set.

[0037] As a specific implementation, the compressed binary file also includes header information for each group. The header information for each group is located before the encoded information of each group and can be used to distinguish different groups. It can also be used to indicate the position of key instructions included in each group (applicable to scenarios where the positions of key instructions within a group are different).

[0038] As an optional specific implementation, only the critical instructions are losslessly compressed, while the instruction difference information corresponding to other instructions is not losslessly compressed. Then, the result of losslessly compressing the critical instructions and the instruction difference information corresponding to other instructions in this group is: the lossless compression result of the critical instructions in this group and the instruction difference information corresponding to other instructions in this group.

[0039] As an optional specific implementation, lossless compression is performed on the instruction difference information corresponding to the critical instructions and other instructions. Then, the result of lossless compression of the instruction difference information corresponding to the critical instructions and other instructions in this group is: the lossless compression result of the critical instructions and the lossless compression result of the instruction difference information corresponding to the other instructions in this group.

[0040] As an optional specific implementation, lossless compression is performed only on the instruction difference information corresponding to instructions other than critical instructions, without performing lossless compression on critical instructions. Then, the result of lossless compression of the instruction difference information corresponding to the critical instructions and instructions other than critical instructions in this group is: the lossless compression result of the instruction difference information corresponding to the critical instructions and instructions other than critical instructions in this group.

[0041] In this embodiment, lossless compression is used to ensure the accuracy of the decompressed instructions. It should be understood that after decompressing the compressed binary file, the key instructions of each group and the instruction difference information (if any) corresponding to other instructions within the group can be obtained. Each other instruction can then be retrieved based on the instruction difference information and the corresponding key instruction.

[0042] This embodiment groups the instructions in the original instruction set, obtains the instruction difference information between the instructions in the group (excluding the key instruction) and the key instruction, and the generated compressed file includes only the instruction difference information (or the result of compression) corresponding to the key instruction and the other instructions in each group. Thus, this embodiment introduces dynamic compression, identifying and eliminating instruction redundancy at the instruction set level (rather than within a single instruction), grouping highly similar instructions into a group, storing only one key instruction in its entirety within the group, and storing only the differences of the remaining instructions. Compared to the existing technology that stores a large number of similar instructions, this embodiment stores only the differences of the remaining instructions in a group (excluding the key instruction), which reduces the cost of instruction storage and transmission, solves the problem of instruction redundancy, and reduces the size of the binary file.

[0043] While specific embodiments of the invention have been described in detail by way of example, those skilled in the art should understand that the examples are for illustrative purposes only and not intended to limit the scope of the invention. It should also be understood that various modifications can be made to the embodiments without departing from the scope and spirit of the invention. The scope of the invention is defined by the appended claims.

Claims

1. A method for dynamic compression of instruction sets, characterized in that, The method includes the following steps: S100, obtain the raw instruction set consisting of multiple instructions; S200, the instructions in the original instruction set are grouped, and a key instruction is determined for each group; wherein each group includes at least one instruction, and if a group includes two or more instructions, the difference between any two adjacent instructions in the group is less than or equal to a preset difference threshold. S300, if a group includes other instructions besides the key instructions, then obtain the instruction difference information between each other instruction and the key instructions of the group; the instruction difference information between any other instruction and the key instructions of the group is used to characterize the value and position information of the difference field between the other instruction and the key instructions of the group; S400, generate a compressed binary file, wherein the compressed binary file includes the encoding information of each group; wherein, if a group includes only 1 instruction, the encoding information of the group is the key instruction of the group or the result of lossless compression of the key instruction of the group; if a group includes 2 or more instructions, the encoding information of the group is the instruction difference information corresponding to the key instruction of the group and other instructions besides the key instruction, or the result of lossless compression of the instruction difference information corresponding to the key instruction of the group and other instructions besides the key instruction.

2. The instruction set dynamic compression method according to claim 1, characterized in that, Grouping the instructions in the original instruction set includes: S201, Scan the instructions in the original instruction set according to the order of the instructions in the original instruction set, and obtain the differences between two adjacent instructions in turn. S202, sequentially determine whether the obtained differences are less than or equal to the preset difference threshold. If not, the previous instruction corresponding to the difference is assigned to the current group and the group is ended. The next instruction corresponding to the difference is used as the starting instruction of a new group. If yes, the previous and next instructions corresponding to the difference are assigned to the current group. Continue to determine whether the next difference is less than or equal to the preset difference threshold until the determination result is no or all differences are determined.

3. The instruction set dynamic compression method according to claim 1, characterized in that, Determining a key instruction for each group includes: identifying the first instruction, any instruction, or the instruction with the highest frequency of occurrence in any group as the key instruction for that group.

4. The instruction set dynamic compression method according to claim 1, characterized in that, Determine a key instruction for each group, including: S210, for any group, if the number of instructions included in the group is greater than or equal to a preset number threshold, then proceed to S220; the preset number threshold is greater than or equal to 3. S220, obtain the total difference between each instruction in the group and other instructions, and determine the instruction with the smallest total difference as the key instruction of the group.

5. The instruction set dynamic compression method according to claim 1, characterized in that, The difference between any two adjacent instructions is the sum of the absolute values ​​of the differences between the corresponding fields of the two adjacent instructions, or the sum of the XOR results of the corresponding fields of the two adjacent instructions.

6. The instruction set dynamic compression method according to claim 1, characterized in that, Obtaining instruction difference information between each other instruction and the key instruction of this group includes: S310, compare the target instruction with the corresponding field of the key instruction in the group; the target instruction is any other instruction. S320, identify all fields with different values, and record the value difference of each field with different values ​​in the target instruction relative to the key instruction of that group; S330: Based on the value difference and the corresponding field position information, generate instruction difference information between the target instruction and the key instruction of the group.

7. The instruction set dynamic compression method according to claim 6, characterized in that, The instruction difference information includes at least one encoding unit, and each encoding unit contains a value difference and the corresponding field position information.

8. The instruction set dynamic compression method according to claim 1, characterized in that, The result of lossless compression of the instruction difference information corresponding to the critical instruction and other instructions in this group is: the lossless compression result of the critical instruction and the instruction difference information corresponding to other instructions in this group, or the lossless compression result of the critical instruction and the instruction difference information corresponding to other instructions in this group, or the lossless compression result of the critical instruction and the instruction difference information corresponding to other instructions in this group.