Instruction processing method, device, electronic device and readable storage medium

By adjusting the jump address operand in the verification instruction stream to meet the preset requirements, the problem of jump instruction abnormality is solved and the effectiveness of verification test is improved.

CN118626153BActive Publication Date: 2024-11-15BEIJING INSTITUTE OF OPEN SOURCE CHIP
View PDF 0 Cites 0 Cited by

Patent Information

Application Number
CN202411116740.1
Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
Filing Date
2024-08-14
Publication Date
2024-11-15
Estimated Expiration
2044-08-14

AI Technical Summary

Technical Problem

In the verification test, the jump address of the jump instruction does not meet the preset requirements, resulting in the verification test failure. How to solve the problem of jump instruction abnormality.

Method used

By obtaining the jump instruction in the verification instruction stream that does not meet the preset requirements, adjust its operands to make its jump address meet the preset requirements, thereby generating the target verification instruction stream.

Benefits of technology

By adjusting the operand of the jump address, the problem of jump instruction is solved and the effectiveness of verification test is improved.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN118626153B_ABST
    Figure CN118626153B_ABST
Patent Text Reader

Abstract

The embodiment of the present invention provides an instruction processing method, device, electronic device and readable storage medium. The method includes: when there is a jump instruction in the verification instruction stream, obtaining the jump instruction whose jump address does not meet the preset requirements in the verification instruction stream as the instruction to be processed; adjusting the jump address operand contained in the instruction to be processed so that the jump address of the adjusted instruction to be processed meets the preset requirements, and obtaining a target verification instruction stream. In this way, by obtaining the jump instruction whose jump address does not meet the preset requirements from the verification instruction stream, the instruction to be processed that may trigger a jump exception can be obtained, and then by jumping the operand of the instruction to be processed so that the jump address of the instruction to be processed after the jump meets the preset requirements, the problem of jump exception of the jump instruction can be solved, and the verification test effect can be greatly improved through the target verification instruction stream.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present invention relates to the field of computer technology, and in particular to an instruction processing method, device, electronic device and readable storage medium. Background Art

[0002] With the development of computer technology, integrated chips or processor units need to be verified and tested. Currently, verification tests are often performed by generating a large number of random instructions through an instruction generator.

[0003] However, the instructions generated by the instruction generator may include jump instructions, and the operands of different instructions include randomly generated values ​​and directed inserted values. When executing a jump instruction, it may jump to an unknown address or an incorrect address, causing the verification test to fail. Therefore, how to solve the jump instruction exception has become an urgent problem to be solved. Summary of the invention

[0004] The purpose of the embodiments of the present invention is to provide an instruction processing method, device, electronic device and readable storage medium to solve the problem of abnormal jump instructions. The specific technical solution is as follows:

[0005] In a first aspect of the present invention, a method for processing an instruction is provided, the method comprising:

[0006] In the case where there are jump instructions in the verification instruction stream, obtaining jump instructions in the verification instruction stream whose jump addresses do not meet preset requirements as instructions to be processed;

[0007] The jump address operand contained in the instruction to be processed is adjusted so that the jump address of the instruction to be processed after the adjustment meets the preset requirement, thereby obtaining a target verification instruction stream.

[0008] In a second aspect of the present invention, there is also provided an instruction processing device, the device comprising:

[0009] An acquisition module, used for acquiring, when there are jump instructions in the verification instruction stream, jump instructions whose jump addresses do not meet preset requirements in the verification instruction stream as instructions to be processed;

[0010] The adjustment module is used to adjust the jump address operand contained in the instruction to be processed so that the adjusted jump address of the instruction to be processed meets the preset requirement, thereby obtaining a target verification instruction stream.

[0011] In a third aspect of the present invention, there is also provided an electronic device, comprising a processor, a communication interface, a memory and a communication bus, wherein the processor, the communication interface and the memory communicate with each other via the communication bus;

[0012] Memory, used to store computer programs;

[0013] The processor is used to implement the method described in the first aspect when executing the program stored in the memory.

[0014] In a fourth aspect of the implementation of the present invention, a computer-readable storage medium is further provided, wherein the computer-readable storage medium stores instructions, which, when executed on a computer, enable the computer to execute the method described in the first aspect above.

[0015] In a fifth aspect of the implementation of the present invention, there is also provided a computer program product comprising instructions, which, when executed on a computer, enables the computer to execute the method described in the first aspect above.

[0016] The instruction processing method provided by the embodiment of the present invention obtains the jump instruction whose jump address does not meet the preset requirements in the verification instruction stream as the instruction to be processed when there is a jump instruction in the verification instruction stream; adjusts the jump address operand contained in the instruction to be processed so that the jump address of the adjusted instruction to be processed meets the preset requirements, and obtains the target verification instruction stream. In this way, by obtaining the jump instruction whose jump address does not meet the preset requirements from the verification instruction stream, the instruction to be processed that may trigger a jump exception can be obtained, and then by jumping the operand of the instruction to be processed so that the jump address of the instruction to be processed after the jump meets the preset requirements, the problem of jump exception of the jump instruction can be solved, and the verification test effect can be greatly improved through the target verification instruction stream. BRIEF DESCRIPTION OF THE DRAWINGS

[0017] In order to more clearly illustrate the embodiments of the present invention or the technical solutions in the prior art, the drawings required for use in the embodiments or the description of the prior art are briefly introduced below.

[0018] Figure 1 is a flowchart of a method for processing instructions in an embodiment of the present invention;

[0019] Figure 2 is a schematic diagram of the structure of an instruction processing device in an embodiment of the present invention;

[0020] Figure 3 Schematic diagram of an electronic device in an embodiment of the present invention. DETAILED DESCRIPTION

[0021] The following will be combined with the drawings in the embodiments of the present invention to clearly and completely describe the technical solutions in the embodiments of the present invention. Obviously, the described embodiments are part of the embodiments of the present invention, not all of the embodiments. Based on the embodiments of the present invention, all other embodiments obtained by ordinary technicians in this field without creative work are within the scope of protection of the present invention.

[0022] The terms "first", "second", etc. in the specification and claims of the present invention are used to distinguish similar objects, and are not used to describe a specific order or sequence. It should be understood that the data used in this way can be interchangeable when appropriate, so that the embodiments of the present invention can be implemented in an order other than those illustrated or described here, and the objects distinguished by "first", "second", etc. are generally of one type, and the number of objects is not limited. For example, the first object can be one or more. In addition, the term "and / or" in the specification and claims is used to describe the association relationship of associated objects, indicating that three relationships can exist. For example, A and / or B can represent: A exists alone, A and B exist at the same time, and B exists alone. The character " / " generally indicates that the objects associated before and after are in an "or" relationship. In the embodiments of the present invention, the term "multiple" refers to two or more, and other quantifiers are similar.

[0023] Figure 1 is a flowchart of a method for processing instructions in an embodiment of the present invention. Figure 1 As shown, the method includes:

[0024] Step 101: When there are jump instructions in the verification instruction stream, obtain the jump instructions in the verification instruction stream whose jump addresses do not meet preset requirements as instructions to be processed.

[0025] Step 102: Adjust the jump address operand contained in the instruction to be processed so that the adjusted jump address of the instruction to be processed meets the preset requirement, thereby obtaining a target verification instruction stream.

[0026] The embodiment of the present invention can be applied to an instruction generator or an instruction sequence generator, or can also be applied to other computer devices, which is not limited by the embodiment of the present invention. The above-mentioned instruction sequence generator can be a tool for generating instruction sequences for processor unit testing (UNIT TESTINT, UT), which can generate instruction streams in a directed or random manner for UT verification of the processor unit.

[0027] The verification instruction stream refers to the instruction stream generated by the instruction sequencer, which includes instructions of various functions, such as addition instructions, subtraction instructions, jump instructions, etc. Specifically, the verification instruction stream is usually generated by the instruction sequencer based on a configuration file, and the configuration file may include the types and instructions of the required verification instructions, or the types and instructions of the verification instructions that need to be eliminated.

[0028] Specifically, the embodiment of the present invention may actively obtain the instruction stream generated by the instruction sequence generator as the verification instruction stream, or the instruction sequence generator may directly use the generated instruction stream as the verification instruction stream, which is not limited by the embodiment of the present invention.

[0029] Furthermore, the embodiment of the present invention can first detect whether there is a jump instruction in the verification instruction stream. Specifically, since the opcodes of instructions that perform different operations are different, the embodiment of the present invention can traverse the opcodes of all verification instructions contained in the verification instruction stream. If there is a verification instruction whose opcode belongs to a jump instruction, it can be determined that there is a jump instruction in the verification instruction stream. Alternatively, the embodiment of the present invention can also parse the configuration file of the instruction sequencer. If the instruction attribute of the configuration file includes a jump attribute, or the configuration file is configured with a directed insertion jump instruction, it can be determined that there is a jump instruction in the verification instruction stream.

[0030] Furthermore, the embodiment of the present invention can obtain the jump instruction whose jump address does not meet the preset requirement in the verification instruction stream as the instruction to be processed. The preset requirement may be that the jump address is out of range. When the jump address does not meet the preset requirement, the jump instruction may point to an unknown address or an erroneous address, causing the verification instruction stream to fail to execute correctly.

[0031] Optionally, the embodiment of the present invention may further include:

[0032] Step 111: Determine the instruction fetch range of the verification instruction stream based on the verification configuration file; the preset requirement is that the jump address belongs to the instruction fetch range.

[0033] Among them, the above-mentioned instruction fetch range refers to the address space of the verification instruction stream. Specifically, the above-mentioned verification configuration file is used to guide the instruction sequencer to generate the verification instruction stream, which can usually include a group configuration group, each group has multiple base segments, and each base segment can contain configuration information such as include_type, include_instr, insert_instr, exclude_type, exclude_instr, dpd, etc. The user can set the instruction type, quantity, dependency, exception mode, random mode, etc. Among them, include_type indicates which attributes of instructions the base instruction fragment needs to include, such as integer, floating point, vector, etc., and the instructions can be divided into many attributes according to the instruction set architecture and microarchitecture. The above-mentioned include_instr indicates which specific instructions need to be included, for example, add addition instructions, sub subtraction instructions, etc. need to be included. The above-mentioned insert_instr indicates the directional insertion of an instruction, and the value of its register or immediate value can be specified. The above-mentioned exclude indicates which attributes or specific instructions need to be eliminated, and these instructions are not generated in the instruction stream. The above-mentioned dpd represents the configuration information related to instruction dependency. In addition, the verification configuration file may also include a starting address of the verification instruction stream and the number of instructions.

[0034] Optionally, the operation of determining the instruction fetch range of the verification instruction stream based on the verification configuration file may specifically include:

[0035] S1111. Obtain the starting address and the number of instructions of the verification instruction stream from the verification configuration file.

[0036] S1112. Determine an instruction fetch range of the verification instruction stream based on the starting address and the number of instructions.

[0037] The starting address of the verification instruction stream refers to the address of the first verification instruction, that is, the value of the Program Counter (PC) of the first instruction. The number of instructions refers to the number of verification instructions contained in the verification instruction stream. Specifically, the starting address and the number of instructions can be pre-configured in the verification configuration file according to actual needs.

[0038] Furthermore, in a specific instruction set architecture, the size of an instruction is often fixed, for example, in an open source instruction set architecture (RISC-V instruction set architecture, RISC-V), an instruction usually occupies 4 bytes. Accordingly, the embodiment of the present invention can obtain the address of the last instruction in the verification instruction stream as the maximum instruction fetch address of the verification instruction stream according to the starting address and the number of instructions of the verification instruction stream, thereby obtaining the instruction fetch range from the starting address to the maximum instruction fetch address.

[0039] For example, taking the starting address of the verification instruction stream in the RISC-V instruction set architecture as 0x80000000 and the number of instructions as N, it can be obtained that the instruction fetch range of the verification instruction stream should be: 0x80000000~[0x80000000+4*(N-1)].

[0040] Furthermore, after determining the instruction fetch range of the verification instruction stream through the verification configuration file, it can be determined whether the jump address of the jump instruction belongs to the instruction fetch range. When the jump address of the jump instruction does not belong to the instruction fetch range, the jump instruction may jump to an incorrect address or an unknown address, resulting in the fetching of an incorrect instruction or the inability to fetch the instruction. Therefore, an embodiment of the present invention can determine the jump instruction whose jump address does not belong to the instruction fetch range as an instruction to be processed.

[0041] Furthermore, after obtaining the instruction to be processed, the embodiment of the present invention can adjust the operands contained in the instruction to be processed so that the adjusted address of the instruction to be processed meets the above preset requirements, thereby obtaining a target verification instruction stream.

[0042] Among them, the above-mentioned jump address operand refers to the operand related to the jump address in the instruction to be processed. Specifically, the operand of the jump instruction can be a register and / or an immediate number. For a jump instruction containing a register, its jump address is usually the value of the register plus an immediate number. In one case, the immediate number can be 0. Correspondingly, for a jump instruction containing only an immediate number, its jump address is usually the current PC value of the jump instruction plus the immediate number. It can be seen from this that the embodiment of the present invention can control the jump address of the jump instruction by adjusting the register or immediate number of the jump instruction.

[0043] Specifically, since the jump address does not meet the preset requirements in the verification instruction stream, it is often because the jump address is too large. Therefore, the embodiment of the present invention can replace the register in the instruction to be processed with a register that stores a smaller value, or load a smaller immediate value into the register through a data loading instruction (for example: lui instruction), and reduce the jump address of the instruction to be processed by initializing the register, and check again whether the jump address corresponding to the initialized register meets the preset requirements. In another case, if there is only an immediate value in the instruction to be processed, the embodiment of the present invention can directly modify the operand of the instruction to be processed, modify it to a smaller value, and check again whether the jump address corresponding to the modified immediate value meets the preset requirements.

[0044] Furthermore, by jumping the operands contained in the instruction to be processed in the above manner, the jump address of the adjusted instruction to be processed meets the preset requirements, which can solve the problem of abnormal jump instructions. The verification test effect can be greatly improved by verifying the target instruction stream.

[0045] In summary, in an embodiment of the present invention, when there is a jump instruction in the verification instruction stream, a jump instruction whose jump address does not meet the preset requirements is obtained as a to-be-processed instruction; the jump address operand contained in the to-be-processed instruction is adjusted so that the jump address of the adjusted to-be-processed instruction meets the preset requirements, and a target verification instruction stream is obtained. In this way, by obtaining a jump instruction whose jump address does not meet the preset requirements from the verification instruction stream, a to-be-processed instruction that may trigger a jump exception can be obtained, and then by jumping the operand of the to-be-processed instruction so that the jump address of the to-be-processed instruction after the jump meets the preset requirements, the problem of jump exception of the jump instruction can be solved, and the verification test effect can be greatly improved through the target verification instruction stream.

[0046] Optionally, the embodiment of the present invention may further include:

[0047] S21. For any jump instruction, input the verification instruction before the jump instruction in the verification instruction stream into the simulator to obtain the execution result of each verification instruction.

[0048] S22. Based on the execution results of the verification instructions and the operand of the jump instruction, obtain the jump address of the jump instruction.

[0049] The above-mentioned simulator refers to a device or software used to simulate the execution scenario of the central processing unit instructions, and can be any simulator that supports the instruction set architecture to which the instruction stream belongs for verification. For example, taking RISC-V as an example, the simulator in the embodiment of the present invention can be a RISC-V architecture simulator (riscv-isa-sim, spike), a computer instruction set architecture simulator (NJU Emulator, Nemu) or a general electronic system simulator (gem5), etc., which can be selected according to actual needs, and the embodiment of the present invention does not limit this.

[0050] Furthermore, since each instruction in the verification instruction stream is executed in sequence, if the register included in the jump instruction overlaps with the register included in the verification instruction before the jump instruction, the jump address of the jump instruction is associated with the execution result of the verification instruction before the jump instruction. Therefore, in order to ensure the accuracy of the jump address of the jump instruction, the embodiment of the present invention can use a simulator to truly simulate the processor execution scenario, input the verification instruction before the jump instruction in the verification instruction stream into the simulator, so that the simulator executes each verification instruction input in sequence, and then the execution result of each verification instruction input can be obtained.

[0051] Furthermore, the embodiment of the present invention can obtain the jump address of the jump instruction based on the execution results of each verification execution and the operand of the jump instruction. Specifically, the jump address is usually composed of a base value and an immediate value. If the base value of the jump address is a register, the current value of the register can be obtained based on the execution results of each verification instruction, and then the jump address of the jump instruction can be obtained based on the current value plus the immediate value. Exemplarily, taking the jump instruction JALRx27, x3, #12 as an example, the instruction is used to indicate a jump to the value of register x3 plus the immediate number 12 to execute, so the embodiment of the present invention can obtain the current value of register x3 based on the output of the simulator, and then obtain the jump address of the jump instruction by adding 12 to the current value.

[0052] In the embodiment of the present invention, for any jump instruction, the verification instruction in the verification instruction stream that is located before the jump instruction is input into the simulator to obtain the execution result of each verification instruction; based on the execution result of each verification instruction and the operand of the jump instruction, the jump address of the jump instruction is obtained. In this way, the embodiment of the present invention can timely adjust the jump instruction with abnormalities through the simulator to obtain a verification instruction stream with better verification effect.

[0053] Optionally, the operation of adjusting the jump address operand included in the instruction to be processed may include:

[0054] S31. When the jump address operand included in the instruction to be processed is a register, based on the execution results of the verification instructions, determine the jump address corresponding to the register included in the verification instructions in the instruction to be processed.

[0055] S32. Using a register whose corresponding jump address in the instruction to be processed meets the preset requirement, replace the register included in the instruction to be processed to obtain an adjusted instruction to be processed.

[0056] When the operand included in the instruction to be processed is a register, it indicates that the jump address of the instruction to be processed is related to the register value, and thus the embodiment of the present invention needs to adjust the register related to the jump address in the instruction to be processed.

[0057] Specifically, since the execution results of each verification instruction before the instruction to be processed are obtained through the simulator, the data of the registers contained in each verification instruction can be directly read to obtain the current value of each register. Furthermore, the current value of the register contained in each verification instruction can be substituted into the instruction to be processed to determine the jump address corresponding to each register in the instruction to be processed, that is: add the current value of each register to the immediate value of the instruction to be processed to obtain the jump address corresponding to the register contained in each verification instruction in the instruction to be processed.

[0058] Furthermore, the embodiment of the present invention can compare the jump addresses corresponding to each register, and use the register whose jump address meets the preset requirements to replace the register related to the jump address in the instruction to be processed, so as to obtain the adjusted instruction to be processed. Optionally, if there are multiple registers whose corresponding jump addresses meet the preset requirements in the instruction to be processed, a register can be randomly selected for replacement, or a register with the smallest or smaller jump address can be selected for replacement, and the embodiment of the present invention does not limit this.

[0059] In an embodiment of the present invention, when the jump address operand contained in the instruction to be processed is a register, based on the execution results of each verification instruction, the jump address corresponding to the register contained in each verification instruction in the instruction to be processed is determined; the register corresponding to the jump address in the instruction to be processed is used to replace the register contained in the instruction to be processed, so as to obtain the adjusted instruction to be processed. In this way, the verification instruction stream can be executed by the simulator, and the value of each register can be obtained based on the execution results of each verification instruction, and based on the value of each register, a register can be selected to replace the register contained in the instruction to be processed, so that the jump address of the instruction to be processed can meet the preset requirements, and the problem of abnormal jump of the jump instruction can be effectively prevented.

[0060] Optionally, the above operation on the jump address operand included in the instruction to be processed may further include:

[0061] S41. When the jump address operand included in the instruction to be processed is an immediate number, regenerate the immediate number for the instruction to be processed to obtain an adjusted instruction to be processed.

[0062] S42. When the adjusted jump address of the instruction to be processed does not meet the preset requirement, re-execute the operation of regenerating an immediate number for the instruction to be processed until the adjusted jump address of the instruction to be processed meets the preset requirement.

[0063] Wherein, when the operand contained in the instruction to be processed is an immediate number, the jump address of the instruction to be processed is the PC value of the instruction to be processed + the immediate number, so the embodiment of the present invention can directly regenerate the immediate number for the instruction to be processed. Specifically, the immediate number can be randomly generated for it, or an immediate number smaller than the original value can be generated for it, which is not limited by the embodiment of the present invention.

[0064] Furthermore, when the adjusted jump address of the instruction to be processed still does not meet the preset requirement, an immediate value is regenerated for it until the adjusted jump address of the instruction to be processed meets the above preset requirement.

[0065] In an embodiment of the present invention, when the jump address operand contained in the instruction to be processed is an immediate number, the immediate number is regenerated for the instruction to be processed to obtain an adjusted instruction to be processed; when the jump address of the adjusted instruction to be processed does not meet the preset requirement, the operation of regenerating the immediate number for the instruction to be processed is re-executed until the jump address of the adjusted instruction to be processed meets the preset requirement. In this way, the embodiment of the present invention can jump the instruction to be processed whose jump address operand is an immediate number so that its jump address meets the preset requirement.

[0066] Optionally, the verification instruction stream belongs to an open source instruction set architecture, and the operation of inputting the verification instruction located before the jump instruction in the verification instruction stream into the simulator may specifically include:

[0067] Step A: converting the verification instruction located before the jump instruction in the verification instruction stream from a text format to a binary format to obtain a binary instruction stream.

[0068] Step B: Input the binary instruction stream into the simulator.

[0069] Among them, in the case where the verification instruction stream belongs to the open source instruction set architecture, the instruction stream generated by the instruction sequence generator for UT testing is often in text format (txt), and the simulator that supports the open source instruction set architecture can often only recognize the binary format (bin), so the embodiment of the present invention can convert the required verification instructions into bin format through a computer programming language (python) script, and then input the binary instruction stream into the simulator. Specifically, the bin file (binary instruction stream) can be placed in the start segment (start) of the simulator's executable file (Executable and Linkable Format, elf), and the simulator can also be specified with the instruction fetch start address of the bin file, that is: the start address of the verification instruction stream.

[0070] Optionally, the embodiment of the present invention may further include:

[0071] S51, inputting the target verification instruction stream into the processor unit to be tested.

[0072] S52: Generate a verification result based on the instruction execution result of the processor unit to be tested.

[0073] The processor unit to be tested refers to any processor module that has a UT test requirement, which may be a function, a class, or other functional software module, etc., and the embodiment of the present invention does not limit this. Furthermore, the present invention may input a target verification instruction stream containing an adjusted jump instruction into the processor unit to be tested, and generate a verification result based on the instruction execution result of the processor unit to be tested.

[0074] Among them, the above instruction execution results are obtained after the processor unit to be tested runs the target verification instruction stream. Furthermore, the instruction execution results can be compared with the preset reference execution results, and then the verification results can be generated according to the comparison results of the two. Specifically, the verification results can be generated according to the ratio of the number of results that are consistent with the comparison to the total number of results. Of course, the verification results can also be generated according to the weights of different verification instructions and whether the results of each verification instruction are consistent. The specific settings can be made according to actual needs, and the embodiments of the present invention are not limited to this.

[0075] In the embodiment of the present invention, the target verification instruction stream is input into the processor unit to be tested; and the verification result is generated based on the instruction execution result of the processor unit to be tested. In this way, the problem of jump instruction jump exception in UT test can be greatly reduced, thereby improving the UT test effect.

[0076] For example, the verification instruction stream includes the following verification instructions:

[0077] Table 1 Address space and instruction flow distribution

[0078]

[0079] Among them, 13 instructions are shown in Table 1, among which A~K are used to represent instructions of other functions, which are only for illustration. Among them, pc refers to the memory address where the instruction is located, that is, the instruction counter. It can be seen that the starting address of the verification instruction stream is 0x80000000, and its instruction fetch range is 0x80000000~ 0x80000048, which contains two jump instructions, namely "JAL x11, #8", and "JALR x27, x3, #12". Among them, "JAL x11, #8" is used to indicate the address of jumping to pc+8, that is, jumping to the address 80000036 to fetch and execute. This address belongs to the above instruction fetch range and can fetch normal instruction codes, so this jump instruction meets the preset requirements. "JALR x27, x3, #12" is used to indicate a jump to the jump address of the value of register x3 plus the immediate value 12. However, the value of the x3 register cannot be determined when generating the verification instruction stream. If its value is large (for example: 44), the jump address (44+12) does not belong to the instruction fetch range of the above instruction, which will cause a jump exception. In addition, the above x11 register and x27 register are not related to the jump address. They are used to store the pc value of the current instruction to save the scene.

[0080] Therefore, the embodiment of the present invention can input all the verification instructions before the JALR instruction into the simulator, obtain the current value of the x3 register, and determine whether the jump address of the JALR instruction belongs to the instruction fetch range. If it does, no adjustment is required. If it does not, based on the instruction execution result of the simulator, a register with a smaller storage value can be selected from the aforementioned registers, and the x3 register in the JALR instruction can be modified to the selected register. Optionally, in the case where there is no register that meets the requirements, a smaller immediate number can be loaded into the register through a data loading instruction (for example: lui instruction), and the jump address of the instruction to be processed is reduced by initializing the register, and the jump address corresponding to the initialized register is checked again to see if it meets the preset requirements. In this way, the jump address of the JALR instruction can meet the preset requirements.

[0081] Figure 2 FIG. 1 is a schematic diagram of the structure of an instruction processing device in an embodiment of the present invention. Figure 2 As shown, the device 20 may include:

[0082] The acquisition module 201 is used for acquiring, when there are jump instructions in the verification instruction stream, jump instructions whose jump addresses do not meet preset requirements in the verification instruction stream as instructions to be processed;

[0083] The adjustment module 202 is used to adjust the jump address operand contained in the instruction to be processed so that the adjusted jump address of the instruction to be processed meets the preset requirement, thereby obtaining a target verification instruction stream.

[0084] Optionally, the device further comprises:

[0085] A first input module, for inputting, for any jump instruction, the verification instruction in the verification instruction stream that is located before the jump instruction into the simulator, so as to obtain the execution result of each verification instruction;

[0086] The address acquisition module is used to acquire the jump address of the jump instruction based on the execution results of the verification instructions and the operand of the jump instruction.

[0087] Optionally, the adjustment module includes:

[0088] A determination submodule, configured to determine, when the jump address operand contained in the instruction to be processed is a register, based on the execution results of the verification instructions, the jump address corresponding to the register contained in each verification instruction in the instruction to be processed;

[0089] The replacement submodule is used to replace the register included in the instruction to be processed with the register whose corresponding jump address in the instruction to be processed meets the preset requirement, so as to obtain the adjusted instruction to be processed.

[0090] Optionally, the adjustment module includes:

[0091] A generating submodule, used for regenerating an immediate number for the instruction to be processed when the jump address operand contained in the instruction to be processed is an immediate number, so as to obtain an adjusted instruction to be processed;

[0092] The execution submodule is used to re-execute the operation of regenerating an immediate number for the instruction to be processed when the adjusted jump address of the instruction to be processed does not meet the preset requirement, until the adjusted jump address of the instruction to be processed meets the preset requirement.

[0093] Optionally, the device further comprises:

[0094] A determination module is used to determine the instruction fetch range of the verification instruction stream based on the verification configuration file; the preset requirement is that the jump address belongs to the instruction fetch range.

[0095] Optionally, the determining module includes:

[0096] A configuration acquisition submodule, used to obtain the starting address and the number of instructions of the verification instruction stream from the verification configuration file;

[0097] The range determination submodule is used to determine the instruction fetch range of the verification instruction stream based on the starting address and the number of instructions.

[0098] Optionally, the device further comprises:

[0099] A second input module, used for inputting the target verification instruction stream into the processor unit to be tested;

[0100] The result generating module is used to generate a verification result based on the instruction execution result of the processor unit to be tested.

[0101] In summary, the instruction processing device provided by the embodiment of the present invention obtains the jump instruction whose jump address does not meet the preset requirements in the verification instruction stream as the instruction to be processed when there is a jump instruction in the verification instruction stream; adjusts the jump address operand contained in the instruction to be processed so that the jump address of the adjusted instruction to be processed meets the preset requirements, and obtains the target verification instruction stream. In this way, by obtaining the jump instruction whose jump address does not meet the preset requirements from the verification instruction stream, the instruction to be processed that may trigger a jump exception can be obtained, and then by jumping the operand of the instruction to be processed so that the jump address of the instruction to be processed after the jump meets the preset requirements, the problem of jump exception of the jump instruction can be solved, and the verification test effect can be greatly improved through the target verification instruction stream.

[0102] As for the device embodiment, since it is basically similar to the method embodiment, the description is relatively simple, and the relevant parts can be referred to the partial description of the method embodiment.

[0103] The various embodiments in this specification are described in a progressive manner, and each embodiment focuses on the differences from other embodiments. The same or similar parts between the various embodiments can be referenced to each other.

[0104] Regarding the instruction processing device in the above embodiment, the specific manner in which each module performs operations has been described in detail in the embodiment of the method, and will not be elaborated here.

[0105] An embodiment of the present invention further provides an electronic device, comprising: a processor and a memory for storing instructions executable by the processor, wherein the processor is configured to execute the above instruction processing method.

[0106] Reference Figure 3, is a schematic diagram of the structure of an electronic device provided by an embodiment of the present invention. Figure 3 As shown, the electronic device includes: a processor, a memory, a communication interface and a communication bus, and the processor, the memory and the communication interface communicate with each other through the communication bus; the memory is used to store at least one executable instruction, and the executable instruction enables the processor to execute the instruction processing method of the aforementioned embodiment.

[0107] It should be noted that the electronic devices in the embodiments of the present application include mobile electronic devices and non-mobile electronic devices.

[0108] The processor may be a CPU (Central Processing Unit), a general-purpose processor, a DSP (Digital Signal Processor), an ASIC (Application Specific Integrated Circuit), an FPGA (Field Programmble Gate Array) or other editable devices, transistor logic devices, hardware components or any combination thereof. The processor may also be a combination that implements computing functions, such as a combination of one or more microprocessors, a combination of a DSP and a microprocessor, etc.

[0109] The communication bus may include a path for transmitting information between the memory and the communication interface. The communication bus may be a PCI (Peripheral Component Interconnect) bus or an EISA (Extended Industry Standard Architecture) bus, etc. The communication bus may be divided into an address bus, a data bus, a control bus, etc. For ease of representation, Figure 3 The fact that only one line is used in the diagram does not mean that there is only one bus or only one type of bus.

[0110] The memory may be a ROM (Read Only Memory) or other types of static storage devices that can store static information and instructions, a RAM (Random Access Memory) or other types of dynamic storage devices that can store information and instructions, or an EEPROM (Electrically Erasable Programmable ReadOnly), a CD-ROM (Compact Disa Read Only), a magnetic tape, a floppy disk, an optical data storage device, etc.

[0111] The embodiment of the present invention also provides a non-transitory computer-readable storage medium, when the instructions in the storage medium are executed by a processor of an electronic device (server or terminal), the processor is enabled to execute Figure 1 The instruction processing method shown.

[0112] The present invention also provides a computer program product comprising instructions, which, when executed on a computer, causes the computer to execute Figure 1 The instruction processing method shown.

[0113] An embodiment of the present application also provides a chip, which includes a processor and a communication interface, wherein the communication interface is coupled to the processor, and the processor is used to run programs or instructions to implement the various processes of the above-mentioned instruction processing method embodiment, and can achieve the same technical effect. To avoid repetition, it will not be repeated here.

[0114] It should be understood that the chip mentioned in the embodiments of the present application can also be called a system-level chip, a system chip, a chip system or a system-on-chip chip, etc.

[0115] The various embodiments in this specification are described in a progressive manner, and each embodiment focuses on the differences from other embodiments. The same or similar parts between the various embodiments can be referenced to each other.

[0116] It should be understood by those skilled in the art that the embodiments of the present invention can be provided as methods, devices, or computer program products. Therefore, the embodiments of the present invention can be implemented in whole or in part by software, hardware, firmware, or any combination thereof. When implemented using software, it can be implemented in whole or in part in the form of a computer program product. The computer program product includes one or more computer instructions. When the computer program instructions are loaded and executed on a computer, the process or function described in the embodiment of the present invention is generated in whole or in part. The computer can be a general-purpose computer, a special-purpose computer, a computer network, or other programmable device. The computer instructions can be stored in a computer-readable storage medium, or transmitted from one computer-readable storage medium to another computer-readable storage medium. For example, the computer instructions can be transmitted from one website site, computer, server, or data center to another website site, computer, server, or data center by wired (e.g., coaxial cable, optical fiber, digital subscriber line (DSL)) or wireless (e.g., infrared, wireless, microwave, etc.) means. The computer-readable storage medium can be any available medium that can be accessed by a computer or a data storage device such as a server or data center that includes one or more available media integrated. The available medium may be a magnetic medium (eg, a floppy disk, a hard disk, a magnetic tape), an optical medium (eg, a DVD), or a semiconductor medium (eg, a solid state disk (SSD)).

[0117] The embodiments of the present invention are described with reference to the flowcharts and / or block diagrams of the methods, terminal devices (systems), and computer program products according to the embodiments of the present invention. It should be understood that each process and / or block in the flowchart and / or block diagram, as well as the combination of the processes and / or blocks in the flowchart and / or block diagram, can be implemented by computer program instructions. These computer program instructions can be provided to a processor of a general-purpose computer, a special-purpose computer, an embedded processor, or other programmable data processing terminal device to generate a machine, so that the instructions executed by the processor of the computer or other programmable data processing terminal device generate instructions for implementing the processes in the flowchart and / or block diagram. Figure 1 A process or multiple processes and / or boxes Figure 1 A device that provides the functions specified in a block or multiple blocks.

[0118] These computer program instructions may also be stored in a computer readable memory capable of directing a computer or other programmable data processing terminal device to operate in a predictable manner, so that the instructions stored in the computer readable memory produce a manufactured product including an instruction device, which implements the process Figure 1 A process or multiple processes and / or boxes Figure 1 A function specified in one or more boxes.

[0119] These computer program instructions can also be loaded onto a computer or other programmable data processing terminal device so that a series of operating steps are executed on the computer or other programmable terminal device to produce a computer-implemented process, thereby providing instructions for executing on the computer or other programmable terminal device to implement the process. Figure 1 A process or multiple processes and / or boxes Figure 1 The steps for the functions specified in one or more boxes.

[0120] Although the preferred embodiments of the present invention have been described, those skilled in the art may make additional changes and modifications to these embodiments once they have learned the basic creative concept. Therefore, the appended claims are intended to be interpreted as including the preferred embodiments and all changes and modifications that fall within the scope of the embodiments of the present invention.

[0121] Each embodiment in this specification is described in a related manner, and the same or similar parts between the embodiments can be referred to each other, and each embodiment focuses on the differences from other embodiments. In particular, for the system embodiment, since it is basically similar to the method embodiment, the description is relatively simple, and the relevant parts can be referred to the partial description of the method embodiment.

[0122] It should be noted that the various data-related processes in the embodiments of the present application are all carried out in compliance with the corresponding data protection laws and policies of the country where the device is located, and with the authorization given by the owner of the corresponding device.

[0123] Finally, it should be noted that, in this article, relational terms such as first and second, etc. are only used to distinguish one entity or operation from another entity or operation, and do not necessarily require or imply any such actual relationship or order between these entities or operations. Moreover, the terms "include", "comprise" or any other variants thereof are intended to cover non-exclusive inclusion, so that a process, method, article or terminal device including a series of elements includes not only those elements, but also other elements not explicitly listed, or also includes elements inherent to such process, method, article or terminal device. In the absence of further restrictions, the elements defined by the sentence "comprise a ..." do not exclude the existence of other identical elements in the process, method, article or terminal device including the elements.

[0124] The above is a detailed introduction to an instruction processing method, device, electronic device and readable storage medium provided by the present invention. Specific examples are used in this article to illustrate the principles and implementation methods of the present invention. The description of the above embodiments is only used to help understand the method of the present invention and its core idea. At the same time, for those skilled in the art, according to the idea of ​​the present invention, there will be changes in the specific implementation method and application scope. In summary, the content of this specification should not be understood as a limitation on the present invention.

Claims

1. A command processing method, characterized in that: The method comprises: In the case where there are jump instructions in the verification instruction stream, obtaining jump instructions in the verification instruction stream whose jump addresses do not meet preset requirements as instructions to be processed; Adjusting the jump address operand contained in the instruction to be processed so that the adjusted jump address of the instruction to be processed meets the preset requirement, thereby obtaining a target verification instruction stream; The method further comprises: Obtaining the starting address and the number of instructions of the verification instruction stream from the verification configuration file; Based on the starting address and the number of instructions, an instruction fetch range of the verification instruction stream is determined; the preset requirement is that the jump address belongs to the instruction fetch range; the instruction fetch range represents the address space of the verification instruction stream.

2. The method according to claim 1, characterized in that The method further comprises: For any jump instruction, input the verification instruction before the jump instruction in the verification instruction stream into the simulator to obtain the execution result of each verification instruction; Based on the execution results of the verification instructions and the operand of the jump instruction, the jump address of the jump instruction is obtained.

3. The method according to claim 2, characterized in that The step of adjusting the jump address operand contained in the instruction to be processed includes: In the case where the jump address operand included in the instruction to be processed is a register, determining the jump address corresponding to the register included in each verification instruction in the instruction to be processed based on the execution result of each verification instruction; The register included in the instruction to be processed is replaced by a register whose corresponding jump address in the instruction to be processed meets the preset requirement, so as to obtain an adjusted instruction to be processed.

4. The method according to claim 2, characterized in that: The step of adjusting the jump address operand contained in the instruction to be processed includes: In the case where the jump address operand contained in the instruction to be processed is an immediate number, regenerating the immediate number for the instruction to be processed to obtain an adjusted instruction to be processed; When the adjusted jump address of the instruction to be processed does not meet the preset requirement, the operation of regenerating the immediate number for the instruction to be processed is re-executed until the adjusted jump address of the instruction to be processed meets the preset requirement.

5. The method according to any one of claims 1 to 4, characterized in that: The method further comprises: Inputting the target verification instruction stream into the processor unit to be tested; A verification result is generated based on the instruction execution result of the processor unit to be tested.

6. An instruction processing device, characterized in that: The device comprises: An acquisition module, used for acquiring, when there are jump instructions in the verification instruction stream, jump instructions whose jump addresses do not meet preset requirements in the verification instruction stream as instructions to be processed; An adjustment module, used for adjusting the jump address operand contained in the instruction to be processed so that the adjusted jump address of the instruction to be processed meets the preset requirement, thereby obtaining a target verification instruction stream; A determination module, configured to determine an instruction fetch range of the verification instruction stream based on a verification configuration file; the preset requirement is that a jump address belongs to the instruction fetch range; the instruction fetch range represents an address space of the verification instruction stream; The determination module comprises: A configuration acquisition submodule, used to obtain the starting address and the number of instructions of the verification instruction stream from the verification configuration file; A range determination submodule is used to determine the instruction fetch of the verification instruction stream based on the starting address and the number of instructions. Refers to the range.

7. An electronic device, characterized in that: It includes a processor, a communication interface, a memory and a communication bus, wherein the processor, the communication interface and the memory communicate with each other through the communication bus; Memory, used to store computer programs; A processor, for implementing any of the methods described in claims 1-5 when executing a program stored in a memory.

8. A computer-readable storage medium having a computer program stored thereon, characterized in that: When the program is executed by a processor, the method according to any one of claims 1 to 5 is implemented.