Instruction stream file generation method and device, electronic equipment and readable medium
By comparing the instruction information in the initial instruction flow file with the reference information generated by the preset decoding tool, the detection information is generated, which solves the problem that the correctness of the instruction flow file can only be discovered during the execution process, and realizes the problem that the instruction flow file is correct during the generation process. The correctness of the instruction file can be known, which reduces costs and improves verification efficiency.
Patent Information
- Application Number
- CN202411112120.0
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2024-08-14
- Publication Date
- 2024-09-10
- Estimated Expiration
- 2044-08-14
AI Technical Summary
In the existing technology, the correctness of the instruction stream file can only be discovered during the execution process, resulting in high costs and possibly slowing down the verification progress.
By obtaining the instruction information in the initial instruction stream file and comparing it with the reference information generated by the preset decoding tool, detection information is generated to represent the correctness of the instruction file, so that the correctness of the instruction file can be known during the generation process.
It reduces the cost of knowing the correctness of the instruction file, avoids the problem of slowing down the verification progress due to incorrect instruction files, and improves the verification efficiency.
Smart Images

Figure CN118626151A
Abstract
Description
Technical Field
[0001] The present invention relates to the field of computer technology, and in particular to a method, device, electronic device and readable medium for generating an instruction stream file. Background Art
[0002] Currently, there are scenarios where instruction stream files need to be used. For example, in the central protocol Unit (CPU) verification scenario, instruction stream files need to be executed for verification.
[0003] In the prior art, the instruction stream file used is often directly generated by an instruction generator, and the generated instruction stream file is directly used subsequently. Among them, the instruction stream file includes multiple instruction files, one instruction file corresponds to one instruction, and the instruction file specifically includes the instruction address, instruction code, and instruction information of the instruction represented by the instruction code. The verification engineer can perform CPU verification based on these contents. In this way, the error in the instruction stream can only be found when an error occurs during the subsequent execution of the instruction stream file, that is, the correctness of the instruction file can only be known through execution. In this way, the cost of knowing the correctness of the instruction file is high. Summary of the invention
[0004] The embodiments of the present invention provide a method, device, electronic device and readable medium for generating an instruction stream file, which can reduce the cost of obtaining the correctness of the instruction file while obtaining a target instruction stream file.
[0005] In order to solve the above problems, an embodiment of the present invention discloses a method for generating an instruction stream file, the method comprising: Obtaining an instruction file of an initial instruction stream file; the initial instruction stream file is generated based on an instruction generator; Based on a preset decoding tool and the instruction code in the instruction file, generating corresponding instruction information for the instruction file as reference information; Taking the instruction information included in the instruction file as original information, and comparing the original information with the reference information to obtain a comparison result; the comparison result is used to indicate whether the original information is consistent with the reference information; Generate detection information for the instruction file based on the comparison result; the detection information is used to indicate whether the instruction file is correct; Output a target instruction stream file including the detection information and the instruction file.
[0006] On the other hand, an embodiment of the present invention discloses a device for generating an instruction stream file, the device comprising: An acquisition module, used for acquiring an instruction file of an initial instruction stream file; the initial instruction stream file is generated based on an instruction generator; A first generating module, for generating corresponding instruction information for the instruction file as reference information based on a preset decoding tool and the instruction code in the instruction file; a comparison module, used to take the instruction information included in the instruction file as original information, and compare the original information with the reference information to obtain a comparison result; the comparison result is used to indicate whether the original information is consistent with the reference information; A second generating module, configured to generate detection information for the instruction file based on the comparison result; the detection information is used to indicate whether the instruction file is correct; The output module is used to output a target instruction stream file including the detection information and the instruction file.
[0007] On the other hand, an embodiment of the present invention discloses an electronic device, comprising: a processor, a memory, a communication interface and a communication bus, wherein the processor, the memory and the communication interface communicate with each other through the communication bus; the memory is used to store executable instructions, and the executable instructions enable the processor to execute the aforementioned method.
[0008] The embodiment of the present invention further discloses a readable medium on which executable instructions are stored. When executed by one or more processors, the processors are enabled to execute the method described above.
[0009] The embodiment of the present invention includes the following advantages: In the instruction stream file generation method provided in the embodiment of the present invention, an instruction file of an initial instruction stream file is obtained; the initial instruction stream file is generated based on an instruction generator. Based on a preset decoding tool and the instruction code in the instruction file, corresponding instruction information is generated for the instruction file as reference information. The instruction information included in the instruction file is used as original information, and the original information is compared with the reference information to obtain a comparison result; the comparison result is used to characterize whether the original information is consistent with the reference information. Based on the comparison result, detection information is generated for the instruction file; the detection information is used to indicate whether the instruction file is correct. A target instruction stream file including the detection information and the instruction file is output. In the embodiment of the present invention, by obtaining the reference information generated by the preset decoding tool in the generation link, and comparing based on the original information in the instruction file initially generated by the instruction generator, a target instruction stream file is generated based on the comparison result. Since the target instruction stream file finally generated includes detection information that can characterize whether the instruction file is correct. Therefore, there is no need to execute the instruction stream file, and the correctness of the instruction file can be directly known based on the generated target instruction stream file. Compared with the method of knowing whether there is a problem only by executing the instruction stream file, the cost of knowing the correctness of the instruction file can be reduced while obtaining the target instruction stream file. BRIEF DESCRIPTION OF THE DRAWINGS
[0010] In order to more clearly illustrate the technical solutions of the embodiments of the present invention, the accompanying drawings required for use in the description of the embodiments of the present invention will be briefly introduced below. Obviously, the accompanying drawings in the following description are only some embodiments of the present invention. For ordinary technicians in this field, other accompanying drawings can be obtained based on these accompanying drawings without paying creative labor.
[0011] Figure 1 It is a flowchart of a method for generating an instruction stream file provided by an embodiment of the present invention; Figure 2 It is a schematic diagram of the format of an initial instruction stream file provided by an embodiment of the present invention; Figure 3 is a schematic diagram of a type of format provided by an embodiment of the present invention; Figure 4 is a schematic diagram of a type of format and special instructions provided by an embodiment of the present invention; Figure 5 It is a block diagram of an instruction stream file generating device provided by an embodiment of the present invention; Figure 6 It is a structural schematic diagram of an electronic device provided by an embodiment of the present invention. DETAILED DESCRIPTION
[0012] 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.
[0013] Reference Figure 1 , shows a flowchart of a method for generating an instruction stream file provided by an embodiment of the present invention, such as Figure 1 As shown, the method may specifically include the following steps: Step 101, obtain an instruction file of an initial instruction stream file; the initial instruction stream file is generated based on an instruction generator.
[0014] Step 102: Based on a preset decoding tool and the instruction code in the instruction file, generate corresponding instruction information for the instruction file as reference information.
[0015] Step 103: Take the instruction information included in the instruction file as original information, and compare the original information with the reference information to obtain a comparison result; the comparison result is used to indicate whether the original information is consistent with the reference information.
[0016] Step 104: Generate detection information for the instruction file based on the comparison result; the detection information is used to indicate whether the instruction file is correct.
[0017] Step 105: Output a target instruction stream file including the detection information and the instruction file.
[0018] In an embodiment of the present invention, the initial instruction stream file may be an instruction stream file generated by an instruction generator, and each instruction file in the instruction stream file includes original information, namely, an instruction address, an instruction code, and instruction information of the instruction represented by the instruction code, all of which are generated by the instruction generator. Among them, the instruction address may be an address stored in an instruction counter (Program Counter, PC), and the instruction code may be a 32-bit instruction code in hexadecimal form. Figure 2 is a schematic diagram of the format of an initial instruction stream file provided by an embodiment of the present invention, such as Figure 2 As shown, each instruction file in the initial instruction stream file may include three parts: instruction address, instruction code and disassembly code, wherein the disassembly code is the disassembled form of the instruction, the disassembly code is the instruction information, and the disassembly code may include instruction name, register number, immediate value and other information.
[0019] Exemplarily, the instruction generator may generate an instruction code, an instruction address, and instruction information of the instruction represented by the instruction code based on pre-configuration information. Among them, the instruction information of the instruction represented by the instruction code may be generated by the instruction generator in the process of generating the instruction code. Specifically, the instruction generator randomly inserts, directionally inserts, or inserts with fixed values to the values of each bit field, and finally splices them to form a 32-bit instruction code. Among them, the information to each bit field includes the above-mentioned instruction information. The instruction generator may also be called an instruction sequence generator, which is a preset software or hardware tool that can be used to generate a series of instructions. The preset decoding tool is a tool for decoding according to the instruction code. Specifically, the preset decoding tool may be a decoding tool whose decoding result includes: the same type of information as the instruction information in the instruction file generated by the instruction generator. The decoding result may also include other information, such as the instruction type, the register name of the register operand, and comment information. In this way, it can be ensured that the reference information and the original information are of the same type of information, and the two can be compared. In an embodiment of the present invention, a preset decoding tool can be used to decode the instruction code in the instruction file generated by the instruction generator, and the obtained decoding result can be used as the corresponding instruction information generated for the instruction file, that is, as a reference file. Among them, the preset decoding tool can be selected as needed, and the embodiment of the present invention does not limit this. Exemplarily, the preset decoding tool can be a decoding tool specially developed to provide reference information required for instruction information comparison, or it can also be an existing general decoding tool, and the embodiment of the present invention does not limit this.
[0020] Furthermore, if there is a problem with the instruction file generated by the instruction generator, there will often be a difference between the instruction information included in the instruction file and the reference information obtained by decoding. Therefore, in an embodiment of the present invention, the original information can be compared with the reference information to determine whether the original information is consistent with the reference information, and then whether the instruction file is correct can be determined based on whether the original information is consistent with the reference information. Specifically, after the instruction information is compared, detection information for characterizing whether the instruction file is correct can be generated for the instruction file based on the comparison result. Finally, a target instruction stream file can be generated based on the generated detection information and the instruction file. Accordingly, the target instruction stream file can be used in subsequent scenarios where the instruction stream file needs to be used.
[0021] In the prior art, after the initial instruction stream file is generated, the initial instruction stream file is often directly used as the target instruction stream file and used in the subsequent verification link. In an embodiment of the present invention, when the target instruction file is generated, the correctness of the instruction file is checked by comparing the instruction information, and detection information that can characterize whether the instruction file is correct is generated for the instruction file. There is no need to execute the instruction stream file, and the correctness of the instruction file can be known directly based on the generated target instruction stream file, that is, whether there is a problem with the target instruction stream file. Compared with the method of only executing the instruction stream file to know whether there is a problem, the cost of knowing the correctness can be reduced. And the correctness of the instruction file can be known based on the target instruction stream file, which can avoid the problem that the verification progress is slowed down due to instruction file errors and the instruction verification is adversely affected.
[0022] For example, in actual application scenarios, verification engineers often perform analysis based on the original information of instruction files, but incorrect instruction files may mislead verification engineers. For example, there may be a situation in the instruction stream file where the instruction code is correct, but the instruction information generated by the instruction generator is not completely correct. For such incorrect instruction files, if the verification engineer directly uses the erroneous instruction information for analysis, it will mislead the verification engineer, thereby slowing down the verification progress and causing an adverse effect on CPU verification. In an embodiment of the present invention, the detection information in the generated target instruction stream file can intuitively indicate whether the instruction file is correct, so that the verification engineer can easily know whether the instruction file is correct, thereby avoiding the use of incorrect instruction files for analysis, misleading the analysis, slowing down the verification progress, and causing an adverse effect on CPU verification.
[0023] In summary, the instruction stream file generation method provided by the embodiment of the present invention obtains an instruction file of an initial instruction stream file; the initial instruction stream file is generated based on an instruction generator. Based on a preset decoding tool and the instruction code in the instruction file, corresponding instruction information is generated for the instruction file as reference information. The instruction information included in the instruction file is used as original information, and the original information is compared with the reference information to obtain a comparison result; the comparison result is used to characterize whether the original information is consistent with the reference information. Based on the comparison result, detection information is generated for the instruction file; the detection information is used to indicate whether the instruction file is correct. The target instruction stream file including the detection information and the instruction file is output.
[0024] In an embodiment of the present invention, by obtaining reference information generated by a preset decoding tool in the generation link, and comparing it based on the original information in the instruction file initially generated by the instruction generator, a target instruction stream file is generated based on the comparison result. Since the target instruction stream file finally generated includes detection information that can characterize whether the instruction file is correct. Therefore, there is no need to execute the instruction stream file, and the correctness of the instruction file can be known directly based on the generated target instruction stream file. Compared with the method of only executing the instruction stream file to know whether there is a problem, the cost of knowing the correctness of the instruction file can be reduced while obtaining the target instruction stream file.
[0025] In the embodiment of the present invention, the instruction generator generates original information in a different manner from the preset decoding tool generates reference information. That is, the two use different implementation mechanisms to obtain instruction information. In this way, the reference information can be more reliable, thereby increasing the credibility of the comparison result determined based on the reference information and the original information.
[0026] Optionally, in some embodiments, the reference information may include first reference information and second reference information. Accordingly, the above-mentioned generating corresponding instruction information for the instruction file based on the preset decoding tool and the instruction code in the instruction file may specifically include: Step 1021: use the instruction code as the input of the preset decoding tool, and call the preset decoding tool to generate the first reference information and the second reference information; wherein the first reference information and the second reference information are obtained by the preset decoding tool using different decoding logics to decode the instruction code.
[0027] In an embodiment of the present invention, the preset decoding tool may include a target program and an integrated standby decoding tool. The target program may be in the form of a target code. Specifically, the preset decoding tool may decode the instruction code input to the tool based on the target code, and accordingly, the obtained decoding result is used as the first reference information, and the instruction code is decoded based on the standby decoding tool, and accordingly, the obtained decoding result is used as the second reference information.
[0028] The backup decoding tool can be integrated into the above-mentioned preset decoding tool to facilitate calling. The decoding method of the backup decoding tool may be different from the decoding method of the target code, that is, the decoding logic of the two is different. Alternatively, they can be the same, that is, the backup decoding is used to decode again. In this way, occasional errors that occur in the operation of generating the first reference information can be identified based on the second reference information.
[0029] Exemplarily, the target code can match the binary code of the instruction code as a whole with the pattern matching code of each instruction to obtain a matching target matching code. Among them, the pattern matching code of the instruction is used to characterize the operation code and other fixed content of the instruction, and a pattern matching code can uniquely indicate an instruction. The pattern matching code of each instruction is pre-associated with the instruction-related information of each instruction. Then, the instruction name and instruction type in the instruction-related information associated with the target matching code are obtained. Then, based on the operand bit field defined in the type format of the instruction type, the operand indicator and operand content are determined, and then decoding is implemented. Specifically, for any operand bit field in the type format of the instruction type, the operand indicator of the operand bit field is obtained, and the content of the binary bit corresponding to the operand bit field in the instruction code is obtained. It should be noted that in actual application scenarios, other information can also be obtained when the target code is decoded, such as the operand type, etc., and the embodiment of the present invention does not limit this.
[0030] Exemplarily, the standby decoding tool may be a third-party decoding tool. In an embodiment of the present invention, the decoding method of the standby decoding tool may be: splitting the binary code of the instruction code to extract the operation code and function code therein, and then matching the instruction type and instruction name one by one based on the operation code and function code. Extract the identifier and operand content of each operand based on the instruction format, and finally, the instruction name, the identifier and the operand content of the operand can be used as the decoding result. Among them, the operand content is the value of the operand. Exemplarily, the standby decoding tool may be spike_dasm, and the preset decoding tool may call the disassembly file of spike_dasm to obtain the decoding result of the standby decoding tool. Among them, spike is a C language implemented simulator officially maintained by the fifth generation reduced instruction set computing (Five Reduced Instruction Set Compute, RISC-V) instruction architecture. The tool is a full-function simulator that can simulate the instruction flow of the CPU. In an embodiment of the present invention, the decoding function therein may be called, and the decoding function of spike can decode the input instruction code more accurately. Among them, the preset decoding tool can be a new type of instruction decoding tool, and the preset decoding tool can be provided with a convenient interface to facilitate docking with various instruction sequence generators, thereby quickly realizing instruction decoding of instruction codes in instruction files.
[0031] In an embodiment of the present invention, the target code may be a source program code written in C language, and the instruction generator may be written in a preset hardware description language (SystemVerilog, SV for short). The instruction generator may pass the instruction code as a parameter to the target code in a preset decoding tool based on the Direct Programming Interface for C (DPI-C) technology, and decode the passed instruction code by calling the function in the target code to obtain the decoding result. Among them, DPI-C is a technology for simulation and emulation, which allows the code written in C language to interact directly with the simulation environment.
[0032] In the embodiment of the present invention, by generating the first reference information and the second reference information at the same time, the comparison link can compare the first reference information, the second reference information and the original information, perform multiple verifications, and thus ensure the accuracy of the detection information finally generated. Specifically, if the contents of the three are consistent, it can be determined that the credibility of the original information is high and the original information is correct. It should be noted that in the embodiment of the present invention, it is also possible to determine whether there is an error based on the first reference information, the second reference information and the original information, the positioning instruction generator, the target code or the standby decoding tool. For example, when the first reference information, the second reference information and the original information are inconsistent, the target instruction stream file will include an instruction file in which the detection information indicates that the instruction file is incorrect. That is, there is an error in the target instruction stream file, and ERROR is used to indicate the detection information that indicates that the instruction file is incorrect, then an ERROR error will be reported in the target instruction stream file. Of course, if there is no ERROR error in the target instruction stream file, it can be determined that all instruction files are generated correctly, and then the target instruction stream file can be used for subsequent use.
[0033] Accordingly, engineers can manually analyze the first reference information, the second reference information, and the original information of the incorrect instruction file to locate which tool has the error, and then quickly locate the error. For example, it is possible to determine which of the first reference information, the second reference information, and the original information is wrong through manual decoding, determine that the tool corresponding to the error information has an error, and feedback to the developer so that the developer can make modifications. In this way, maintenance costs can be reduced to a certain extent, and updates and maintenance can be performed in real time according to user needs. At the same time, in the event that there is an error in the instruction generator, the instruction generator can be optimized through modification so that the instruction generator can generate an instruction stream file without problems, ensuring the correctness of the instruction sequence in the instruction stream file.
[0034] It should be noted that, in specific implementation, the instruction code can also be directly decoded using an alternative decoding tool, and the decoding result can be used as reference information to be compared with the original information to reduce the amount of comparison calculation, and the embodiment of the present invention does not limit this.
[0035] Optionally, in some embodiments, the output includes the detection information and a target instruction stream file of the instruction file, which may specifically include: Step 1051: Generate a log file based on all the instruction files of the initial instruction stream file and the detection information of all the instruction files.
[0036] Step 1052: Use the log file as the target instruction stream file and output it.
[0037] In an embodiment of the present invention, after obtaining the detection information of an instruction file, the log information can be printed out. Correspondingly, after the detection information is generated for all instruction files of the initial instruction stream file, the printed out log information constitutes a log file. Among them, the log information may include instruction files, detection results, and comparison results. In this way, in the process of executing the generation of the initial instruction stream, each time an instruction file is generated, the comparison result can be viewed through the printed out log information. Alternatively, the printout operation can be performed after obtaining the detection information of all instruction files. That is, after the detection information is generated for all instruction files of the initial instruction stream file, all instruction files, the detection results of all instruction files, and the comparison results are printed out in the form of logs.
[0038] In the embodiment of the present invention, a log file is generated based on all instruction files of the initial instruction stream file and the detection information of all instruction files, and the log file is output as the target instruction stream file. Since the log format is easy to view, outputting the generated log file can facilitate the user to subsequently view whether the generated target instruction stream file is correct.
[0039] Optionally, in some embodiments, the initial instruction stream file is the instruction stream being generated by the instruction generator. Accordingly, the instruction file for obtaining the initial instruction stream file may include: running the instruction generator so that the instruction generator starts to perform the initial instruction stream file generation operation; after the instruction generator generates an instruction file, obtaining the generated instruction file. Accordingly, in an embodiment of the present invention, the instruction code in the instruction file may also be sent to the preset decoding tool. For example, the instruction code in the instruction file may be transferred to the preset decoding tool based on the DPI-C technology.
[0040] In this implementation, during the instruction generator generating instructions, each time the instruction generator generates an instruction file, the instruction code therein is sent to a preset decoding tool for decoding to obtain reference information. Accordingly, the preset decoding tool can return the reference information to the instruction generator. For example, the reference information is returned to the instruction generator based on the DPI-C technology. Among them, the returned reference information can be saved based on the structure for use in comparison. Accordingly, the above steps 103 to 105 can be executed by the instruction generator. Therefore, in this method, it is only necessary to send the instruction code in the instruction file to the preset decoding tool.
[0041] In the embodiment of the present invention, the instruction generator automatically checks the generated instruction file, thus realizing the self-checking of the instruction generation by the instruction generator. In the embodiment of the present invention, the instruction code in the instruction file is sent to the preset decoding tool while the instruction file is generated, so as to perform subsequent comparison, so that the correctness comparison can be realized for each instruction file generated.
[0042] Optionally, in some embodiments, the initial instruction stream file is an instruction stream that has been generated by the instruction generator; the instruction file of the initial instruction stream file may include: reading the initial instruction stream file generated by the instruction generator, and obtaining all instruction files included in the initial instruction stream file. Accordingly, in the embodiment of the present invention, all instruction files may also be sent to the preset decoding tool.
[0043] In this implementation, after the instruction generator generates all instruction files, that is, after the initial instruction stream is generated, it can be input as a whole into a preset decoding tool for decoding to obtain reference information of each instruction file. Among them, the initial instruction stream file can be a file in txt format or with a .S suffix. Correspondingly, after obtaining the reference information, the preset decoding tool can perform a comparison to output a target instruction stream file, that is, the steps of steps 103-105 above can be performed by the preset decoding tool, and only the text file (that is, the initial instruction stream file) needs to be used as the input of the preset decoding tool, and the preset decoding tool can read each instruction file line by line for information processing. Specifically, the instruction code can be extracted, and the reference information can be obtained by decoding based on the instruction code. Then the original information in the instruction file is extracted for comparison, and then the final target instruction stream file is generated. Therefore, in this way, all instruction files can be sent to the preset decoding tool. In an embodiment of the present invention, after obtaining the complete initial instruction stream, the initial instruction stream file is used as input, and the correctness comparison is performed for each instruction file to generate the final target instruction stream file. In this way, automatic checking of the instruction file of the instruction generator is achieved in the generation stage.
[0044] In an embodiment of the present invention, an instruction generator and a preset decoding tool are combined, the instruction generator generates an original instruction stream file of a specific instruction sequence, reference information is generated based on the preset decoding tool, the original information is compared with the reference information based on the instruction generator or the preset decoding tool, and detection information is generated for the instruction file based on the comparison result, and finally, the final target instruction stream file is output.
[0045] Optionally, in some embodiments, the instruction information may include an instruction name and operand information. That is, the original information includes the instruction name and operand information generated by the instruction generator for the instruction file, and the reference information includes the instruction name and operand information generated by the preset decoding tool for the instruction file. Accordingly, the above comparison of the original information with the reference information to obtain the comparison result may specifically include: Step 1031: perform a consistency comparison between the instruction name in the original information and the instruction name in the reference information, and perform a consistency comparison between the operand information in the original information and the operand information in the reference information.
[0046] Step 1032: When the instruction names of the original information and the reference information are consistent and the operand information is consistent, generate a first comparison result; the first comparison result is used to indicate that the original information is consistent with the reference information.
[0047] Step 1033: When the instruction names and / or operand information of the original information and the reference information are inconsistent, generate a second comparison result; the second comparison result is used to indicate that the original information and the reference information are inconsistent.
[0048] In the embodiment of the present invention, the first comparison result and the second comparison result may be identifiers in different representation forms. For example, the first comparison result may be represented as 1, and the second comparison result may be represented as 0. Alternatively, the first comparison result may be represented as true, and the second comparison result may be represented as false.
[0049] Comparing the instruction name in the original information with the instruction name in the reference information for consistency may refer to detecting whether the instruction name in the original information is consistent with the instruction name in the reference information. If the two are consistent, it can be determined that the instruction name of the original information is consistent with that of the reference information. Otherwise, it can be determined that the instruction name of the original information is inconsistent with that of the reference information. Comparing the operand information in the original information with the operand information in the reference information for consistency may refer to detecting whether the operand information in the original information is consistent with that of the reference information. If the two are consistent, it can be determined that the operand information of the original information is consistent with that of the reference information. Otherwise, it can be determined that the operand information of the original information is inconsistent with that of the reference information.
[0050] Furthermore, if the instruction name is consistent and the operand information is consistent, it can be determined that the original information is consistent with the reference information, and therefore the first comparison result can be marked for the instruction file. Otherwise, the second comparison result is marked for the instruction file. That is, if the instruction name is inconsistent, or the operand information is inconsistent, or the instruction name is inconsistent and the operand information is inconsistent, in these cases, the second comparison result is marked for the instruction file.
[0051] The marked comparison result may be stored in a cache, and the target instruction stream file finally output may include the comparison result or may not include the comparison result. Accordingly, when the comparison result is not included, the first comparison result and the second comparison result may be deleted after the detection information is generated based on the comparison result to save storage resources.
[0052] In an embodiment of the present invention, a consistency comparison is performed on the instruction name, and a consistency comparison is performed on the operand information. When the instruction name of the original information is consistent with that of the reference information and the operand information is consistent, a first comparison result is generated. When the instruction name of the original information is inconsistent with that of the reference information and / or the operand information is inconsistent, a second comparison result is generated. That is, when both the instruction and the operand information are consistent, a first comparison result indicating that the original information is consistent with the reference information is generated. Otherwise, a second comparison result is generated. In this way, it can be ensured that the generated comparison result can accurately characterize whether the original information is consistent with the reference information.
[0053] Optionally, in some embodiments, the generating detection information for the instruction file based on the comparison result may specifically include: Step 1041: When the comparison result is the first comparison result, generate a first detection result for the instruction file; the first detection result is used to indicate that the instruction file is correct.
[0054] Step 1042: When the comparison result is the second comparison result, generate a second detection result for the instruction file; the second detection result is used to indicate that an error exists in the instruction file.
[0055] In an embodiment of the present invention, the first test result and the second test result can be identifications in different representation forms. Exemplarily, the first test result can be expressed as PASS, and the second test result can be expressed as ERROR. Accordingly, if the original information is consistent with the reference information, it means that the instruction file is correct, and if the original information is inconsistent with the reference information, it means that there is an error in the instruction file. Therefore, the comparison result marked as the instruction file can be read, and if the comparison result is the first comparison result, the first test result is associated with the instruction file, and if the comparison result is the second comparison result, the second test result is associated with the instruction file. In one implementation, the first comparison result can also be directly determined as the first test result, and the second comparison result can be determined as the second test result. In this way, processing resources can be saved and the processing method can be simplified.
[0056] For an instruction file in the target instruction stream file, the instruction address, instruction code, instruction information (i.e., original information) of the instruction represented by the instruction code, reference information, and detection result of the instruction file may be included. For example, taking the instruction file whose detection result is the first detection result as an example, the partial content included in the instruction file may be expressed as: inst:282633b Asm: REMW x6,x4,x8 Decode_info: name=REMW, type=R, rd=6 (t1), rs1=4 (tp), rs2=8 (s0) PASS, decode_instname: REMW equal waterfall_inst: REMW, rd=6, rs1=4, rs2=8 Where inst represents the instruction code, Asm represents the disassembled form of the instruction, the content of Asm may represent the instruction information generated by the instruction sequencer, Decode_info represents the decoding result of the decoding tool, the content of Decode_info may represent the reference information obtained by the decoding tool, and PASS represents the detection result of the instruction file (the detection result of the instruction file in this example is the first detection result). In specific implementation, if the instruction file is correct, the instruction name and the assembly representation of the instruction may be printed out after the detection result.
[0057] Exemplarily, taking inst as 282633b as an example, Asm can be REMW x6, x4, x8, where REMW represents the instruction name, x6, x4, and x8 correspond to three operands respectively, and the x in these three operands represents that the operand type is an integer, and 6, 4, and 8 represent the values of these three operands respectively, that is, the register number. Taking the RISC-V architecture as an example, the number of logical registers specified in the architecture is 32 (that is, the register numbers are from 0 to 31), and accordingly, the register number can be a value with a 5-bit width (bit). Among them, the unsigned decimal number that 5bit can represent is 0 to 31. The data stored in the register can be read based on the register number. Among them, the data bit width of the register is determined according to different instruction architectures. For example, when implementing the RISC-V32 architecture, the bit width of the register is 32bit, for the RISC-V64 architecture, the bit width of the register is 64bit, and for the RISC-V128 architecture, the bit width of the register is 128bit.
[0058] Decode_info can be: name=REMW, type=R, rd=6(t1), rs1=4(tp), rs2=8(s0). Among them, name is used to indicate the instruction name in the reference information, type is used to indicate the instruction type in the reference information, type=R indicates that the instruction is a register type (R type), rd, rs1 and rs2 indicate three operands, rd indicates the destination register, rs1 and rs2 indicate the source registers. The destination register is used to store the operation result, and the source register is used to store the source operand for processing. Exemplarily, for the add instruction, if rs1=2, rs2=3, rd=5, it means that the values in the x2 register and the x3 register are added, and the result is stored in the x5 register. Specifically, corresponding to the above example, rd=6(t1) indicates that the register number of the rd register is 6 and the register name is t1. rs1=4(tp) indicates that the register number of the rs1 register is 4 and the register name is tp. Rs2=8(s0) indicates that the register number of the rs1 register is 8 and the register name is s0.
[0059] Furthermore, after the test result: PASS, the following may be printed: decode_instname: REMW equalwaterfall_inst: REMW, rd=6, rs1=4, rs2=8. Wherein, decode_instname and waterfall_inst are used to represent the instruction name decoded by the decoding tool and the instruction name generated by the instruction sequencer, respectively.
[0060] In an embodiment of the present invention, a first detection result and a second detection result are generated correspondingly for the first comparison result and the second comparison result. Since the first comparison result and the second comparison result can accurately represent whether the original information is consistent with the reference information, accordingly, a first detection result and a second detection result are generated correspondingly for the first comparison result and the second comparison result, thereby ensuring the accuracy of the detection result generated for the instruction file.
[0061] Optionally, in some embodiments, the embodiments of the present invention may further include: Step S21, determining an identifier of an operand specified for the instruction represented by the instruction file in a preset instruction architecture as a target identifier.
[0062] The operand information includes the operand identifier and the operand value. Accordingly, the consistency comparison between the operand information in the original information and the operand information in the reference information specifically includes: Step 1031a: Determine the operand information in the original information as original operand information, and determine the operand information in the reference information as reference operand information.
[0063] Step 1031b: If the identifier in the original operand information and the identifier in the reference operand information both match the target identifier, and the value in the original operand information is consistent with the value in the reference operand information, it is determined that the operand information is consistent.
[0064] Step 1031c: If the identifier in the original operand information does not match the target identifier, the identifier in the reference operand information does not match the target identifier, and / or the value in the original operand information is inconsistent with the value in the reference operand information, it is determined that the operand information is inconsistent.
[0065] Exemplarily, the operand may include a source register (src), a destination register (dest), and an immediate value. Accordingly, the value of the operand may be a register number or an immediate value. The number and type of operands included in different instructions are different. Therefore, in an embodiment of the present invention, the operand identifier specified for the instruction represented by the instruction file in the instruction architecture may be first determined as the target identifier. Among them, the preset instruction architecture may be set as needed. Exemplarily, the preset instruction architecture may be a RISC-V instruction architecture. Based on the architecture manual of the preset instruction architecture, the operand defined in the type format of the instruction type represented by the instruction file may be determined as the target operand. Among them, different instruction types may be pre-divided according to factors such as operating characteristics, operand type, addressing mode, and instruction length. The bit fields of the operands defined in the instructions of the same instruction type are the same. The same instruction type may include different types of instructions, that is, different types of instructions may conform to the same type format. Exemplarily, taking the ADDI instruction and the ADDIW instruction as examples, the instruction types of the two instructions may both be type I, and the bit fields of the operands in the two instructions may be the same. For example, the operands of these two instructions include: rd, rs1 and an immediate number, where rd is located at the 7th to 11th bit, rs1 is located at the 15th to 19th bit, and the immediate number is located at the 20th to 31st bit.
[0066] In the type format corresponding to any instruction type, operand indicators of each operand included in the instruction of the instruction type may be defined. The type format corresponding to the instruction type may be obtained from the architecture manual. The architecture manual may also be referred to as the instruction set manual. The operand indicator is used to distinguish different operands. For example, the operand indicator may include: rs1, rs2, rd, imm, vd, vs2, vs3, and so on.
[0067] Specifically, the instruction type of the instruction represented by the instruction file can be used as the target type. If the instruction represented by the instruction file is not a preset special instruction, the type format of the target type is determined as the target format. For any operand bit field in the target format, obtain the operand identifier of the operand bit field. The obtained operand identifier is determined as the target identifier. Among them, the instruction type of the instruction represented by the instruction file can be extracted from the reference information. Alternatively, call a preset type determination tool and obtain it based on instruction code identification, which is not limited in the embodiment of the present invention. For example, Figure 3 is a schematic diagram of a type of format provided by an embodiment of the present invention, such as Figure 3As shown, assuming that the instruction represented by the instruction file is an ADD instruction, and accordingly, the target type is R type, then the operand indicators: rd, rs1 and rs2 can be obtained. Accordingly, the three operands indicated by rd, rs1 and rs2 can be determined as target operands. Assuming that the target type is I type, then the target indicators: rd, rs1 and immediate number can be obtained. Among them, R type indicates register type, and I type indicates immediate number type.
[0068] Further, the special instruction name may be an instruction name of a special instruction, and the special instruction may include an instruction whose instruction format in each instruction type is different from the type format of the instruction type. Figure 4 is a schematic diagram of a type of format and special instructions provided by an embodiment of the present invention, such as Figure 4 As shown, for the R type, the R type type format defines three register operands, rd, rs1, and rs2, where rd represents the register used to store the result, i.e., the destination register, and rs1 and rs2 represent two registers used to provide operands, i.e., the source register. In other words, under normal circumstances, instructions of the R type instruction type will include rd, rs1, and rs2. However, in actual applications, there may be instructions in which rs2 is a fixed value, i.e., there is no rs2 bit field. For the I type, bits 31 to 20 in the I type type format are immediate values, and also include rs1 and rd.
[0069] However, for instruction a and instruction b of type R, the 24th to 20th bits of these two instructions are 00001 and 00000 respectively. Among them, rm represents the rounding mode, and instruction a and instruction b can be fcvt.wu.d instruction and fcvt.ws instruction respectively. Accordingly, for fcvt.wu.d instruction and fcvt.ws instruction, when performing operand information comparison, only the two operands rd and rs1 need to be compared. For non-special instructions of type R, when performing operand information comparison, the three operands rd, rs1 and rs2 need to be compared.
[0070] For instruction c and instruction d of type I, bits 31 to 20 of these two instructions are not immediate values. Instruction c and instruction d may be fence instructions and fence.i instructions respectively, and parameter 1 and parameter 2 may be two parameters in the fence instruction: pred and succ respectively. Therefore, special instructions of type R may include fcvt.wu.d instructions and fcvt.ws instructions, and special instructions of type I may include fence instructions and fence.i instructions, so as to facilitate subsequent decoding based on the decoding rules for separate instructions for special instructions.
[0071] Specifically, for each instruction type, all instructions belonging to the instruction type can be obtained from the architecture manual, and then the operands and bit fields defined in the instruction formats of these instructions are compared with the operands and bit fields defined in the type format of the instruction type. If there is inconsistency, the instruction can be determined as a special instruction, and the instruction type and the instruction name of the instruction are stored corresponding to each instruction type, and finally the special instruction name corresponding to each instruction type can be obtained. From the special instruction names corresponding to the target type, it can be found whether there is the instruction name of the instruction represented by the instruction file. If it exists, it can be determined that the instruction is a preset special instruction. If it does not exist, it can be determined that the instruction is not a preset special instruction.
[0072] Correspondingly, if it is a special instruction, the type format corresponding to the instruction name of the instruction can be loaded from the type format pre-set for the special instruction as the target format. Among them, the type format set for each special instruction can define: the operand bit field of each operand included in each special instruction, and the operand identifier is defined in the operand bit field. Setting the type format for the special instruction can facilitate the corresponding processing of the special instruction to ensure accuracy.
[0073] Further, when performing consistency comparison on the operand information, it can be determined whether the indicator in the original operand information matches the target indicator, and whether the indicator in the reference operand information matches the target indicator. It should be noted that, in the case of including the first reference information and the second reference information, it can be determined whether the indicator in the reference operand information in the first reference information (recorded as the first reference operand information) matches the target indicator, and it can be determined whether the indicator in the reference operand information in the second reference information (recorded as the second reference operand information) matches the target indicator.
[0074] For any operand information among the original operand information, the first reference operand information, and the second reference operand information, when the operand identifier included in the operand information is the same as the target identifier, it is determined that the operand information matches the target identifier. Exemplarily, assuming that the target identifier includes rd, rs1, and rs2, when the operand identifier in the operand information is rd, rs1, and rs2, it is determined that the identifier in the operand information matches the target identifier. Otherwise, it is determined that the identifier in the operand information does not match the target identifier.
[0075] Further, if the indicator in the original operand information and the indicator in the reference operand information both match the target indicator, it can be detected that the numerical value in the original operand information is consistent with the numerical value in the reference operand information. If consistent, it can be determined that the operand information is consistent. Otherwise, if there are one or more of the following operand comparison situations, it is determined that the operand information is inconsistent. The operand comparison situation includes: the indicator in the original operand information does not match the target indicator, the indicator in the reference operand information does not match the target indicator, and the numerical value in the original operand information is inconsistent with the numerical value in the reference operand information.
[0076] In the embodiment of the present invention, the operand identifier specified for the instruction represented by the instruction file in the instruction architecture is first determined as the target identifier. When the operand information is compared for consistency, the operand information is determined to be consistent only when the identifier in the original operand information and the identifier in the reference operand information both match the target identifier and the value in the original operand information is consistent with the value in the reference operand information. In this way, the accuracy of the operand information comparison can be ensured to a large extent.
[0077] In the prior art, there is no corresponding mechanism to check whether the instruction stream generated by the instruction generator is correct, whether the disassembled code (i.e., instruction information) is correct, and so on. It can only be executed directly through the register transfer level (RTL) execution process or the simulator after the instruction stream file is generated. If an error occurs, a reverse check is performed. In this way, it is impossible to perform a forward check in time during generation, resulting in a high verification cost, and sometimes there will be situations where the instruction information is wrong but the execution does not report an error, and the erroneous instruction information misleads the verification engineer, resulting in the problem of slowing down the verification progress. In an embodiment of the present invention, self-checking is performed in time during the generation process to move the verification operation forward, which can reduce the verification cost to a certain extent, and avoid the problem of slowing down the verification progress due to erroneous instruction information.
[0078] Reference Figure 5 , shows a block diagram of an instruction stream file generating device provided by an embodiment of the present invention, such as Figure 5 As shown, the device may specifically include: An acquisition module 201 is used to acquire an instruction file of an initial instruction stream file; the initial instruction stream file is generated based on an instruction generator; A first generating module 202, for generating corresponding instruction information for the instruction file as reference information based on a preset decoding tool and the instruction code in the instruction file; The comparison module 203 is used to take the instruction information included in the instruction file as original information, and compare the original information with the reference information to obtain a comparison result; the comparison result is used to indicate whether the original information is consistent with the reference information; A second generating module 204 is used to generate detection information for the instruction file based on the comparison result; the detection information is used to indicate whether the instruction file is correct; The output module 205 is used to output a target instruction stream file including the detection information and the instruction file.
[0079] Optionally, the instruction information includes an instruction name and operand information; the comparison module 203 is specifically used to: Performing consistency comparison between the instruction name in the original information and the instruction name in the reference information, and performing consistency comparison between the operand information in the original information and the operand information in the reference information; When the instruction names of the original information and the reference information are consistent and the operand information is consistent, a first comparison result is generated; the first comparison result is used to indicate that the original information is consistent with the reference information; In the case where the instruction names and / or operand information of the original information and the reference information are inconsistent, a second comparison result is generated; the second comparison result is used to indicate that the original information and the reference information are inconsistent.
[0080] Optionally, the device further comprises: a determination module, configured to determine, in a preset instruction architecture, an identifier of an operand specified for the instruction represented by the instruction file as a target identifier; The operand information includes an operand identifier and an operand value; the comparison module 203 is further used for: Determine the operand information in the original information as original operand information, and determine the operand information in the reference information as reference operand information; If both the indicator in the original operand information and the indicator in the reference operand information match the target indicator, and the value in the original operand information is consistent with the value in the reference operand information, then determining that the operand information is consistent; If the identifier in the original operand information does not match the target identifier, the identifier in the reference operand information does not match the target identifier, and / or the value in the original operand information does not match the value in the reference operand information, then it is determined that the operand information is inconsistent.
[0081] Optionally, the second generating module 204 is specifically configured to: In the case where the comparison result is the first comparison result, generating a first detection result for the instruction file; the first detection result is used to indicate that the instruction file is correct; When the comparison result is the second comparison result, a second detection result is generated for the instruction file; the second detection result is used to indicate that an error exists in the instruction file.
[0082] Optionally, the output module 205 is specifically used to: Generate a log file based on all the instruction files of the initial instruction stream file and the detection information of all the instruction files; The log file is used as the target instruction stream file and is output.
[0083] Optionally, the reference information includes first reference information and second reference information; The first generating module 202 is specifically used for: Using the instruction code as input of the preset decoding tool, and calling the preset decoding tool to generate the first reference information and the second reference information; The first reference information and the second reference information are obtained by decoding the instruction code by the preset decoding tool using different decoding logics.
[0084] Optionally, the initial instruction stream file is an instruction stream being generated by the instruction generator; the acquisition module 201 is specifically used to: run the instruction generator so that the instruction generator starts to perform an initial instruction stream file generation operation; after the instruction generator generates an instruction file, acquire the generated instruction file; Alternatively, the initial instruction stream file is an instruction stream that has been generated by the instruction generator; the acquisition module 201 is specifically used to: read the initial instruction stream file generated by the instruction generator, and acquire all instruction files included in the initial instruction stream file.
[0085] Optionally, the instruction generator generates the original information in a manner that is different from the preset decoding tool generating the reference information.
[0086] In summary, in the instruction stream file generating device provided by the embodiment of the present invention, an instruction file of an initial instruction stream file is obtained; the initial instruction stream file is generated based on an instruction generator. Based on a preset decoding tool and the instruction code in the instruction file, corresponding instruction information is generated for the instruction file as reference information. The instruction information included in the instruction file is used as original information, and the original information is compared with the reference information to obtain a comparison result; the comparison result is used to characterize whether the original information is consistent with the reference information. Based on the comparison result, detection information is generated for the instruction file; the detection information is used to indicate whether the instruction file is correct. Output includes detection information and a target instruction stream file of the instruction file.
[0087] In an embodiment of the present invention, by obtaining reference information generated by a preset decoding tool in the generation link, and comparing it based on the original information in the instruction file initially generated by the instruction generator, a target instruction stream file is generated based on the comparison result. Since the target instruction stream file finally generated includes detection information that can characterize whether the instruction file is correct. Therefore, there is no need to execute the instruction stream file, and the correctness of the instruction file can be known directly based on the generated target instruction stream file. Compared with the method of only executing the instruction stream file to know whether there is a problem, the cost of knowing the correctness of the instruction file can be reduced while obtaining the target instruction stream file.
[0088] Reference Figure 6 , is a schematic diagram of the structure of an electronic device provided by an embodiment of the present invention. Figure 6 As shown, the electronic device includes: a processor, a memory, a communication interface and a communication bus, wherein the processor, the memory and the communication interface communicate with each other through the communication bus; the memory is used to store executable instructions, and the executable instructions enable the processor to execute the instruction stream file generation method of the above embodiment. Executable instructions can form a program.
[0089] An embodiment of the present invention provides a readable medium having executable instructions stored thereon, which, when executed by one or more processors, enables the processors to execute the instruction stream file generation method of the aforementioned embodiment.
[0090] 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.
[0091] 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 take the form of a complete hardware embodiment, a complete software embodiment, or an embodiment combining software and hardware. Moreover, the embodiments of the present invention can take the form of a computer program product implemented on one or more computer-usable storage media (including but not limited to disk storage, CD-ROM, optical storage, etc.) containing computer-usable program codes. It should be noted that all actions of acquiring signals, information or data in this application are carried out under the premise of complying with the corresponding data protection laws and policies of the country of residence and with the authorization given by the owner of the corresponding device. 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 box in the flowchart and / or block diagram, as well as the combination of the processes and / or boxes 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 process 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.
[0092] 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.
[0093] 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.
[0094] 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.
[0095] 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.
[0096] The above describes in detail an instruction stream file generation method, an instruction stream file generation device, an electronic device and a readable medium provided by the present invention. Specific examples are used herein 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 methods and application scopes. In summary, the content of this specification should not be understood as a limitation on the present invention.
Claims
1. A method for generating an instruction stream file, characterized in that: The method comprises: Obtaining an instruction file of an initial instruction stream file; the initial instruction stream file is generated based on an instruction generator; Based on a preset decoding tool and the instruction code in the instruction file, generating corresponding instruction information for the instruction file as reference information; Taking the instruction information included in the instruction file as original information, and comparing the original information with the reference information to obtain a comparison result; the comparison result is used to indicate whether the original information is consistent with the reference information; Generate detection information for the instruction file based on the comparison result; the detection information is used to indicate whether the instruction file is correct; Output a target instruction stream file including the detection information and the instruction file.
2. The method according to claim 1, characterized in that The instruction information includes an instruction name and operand information; the original information is compared with the reference information to obtain a comparison result, including: Performing consistency comparison between the instruction name in the original information and the instruction name in the reference information, and performing consistency comparison between the operand information in the original information and the operand information in the reference information; When the instruction names of the original information and the reference information are consistent and the operand information is consistent, a first comparison result is generated; the first comparison result is used to indicate that the original information is consistent with the reference information; In the case where the instruction names and / or operand information of the original information and the reference information are inconsistent, a second comparison result is generated; the second comparison result is used to indicate that the original information and the reference information are inconsistent.
3. The method according to claim 2, characterized in that The method further comprises: Determine, as the target identifier, an identifier of an operand specified for the instruction represented by the instruction file in a preset instruction architecture; The operand information includes an operand identifier and a value of the operand; and the consistency comparison between the operand information in the original information and the operand information in the reference information includes: Determine the operand information in the original information as original operand information, and determine the operand information in the reference information as reference operand information; If both the indicator in the original operand information and the indicator in the reference operand information match the target indicator, and the value in the original operand information is consistent with the value in the reference operand information, then determining that the operand information is consistent; If the identifier in the original operand information does not match the target identifier, the identifier in the reference operand information does not match the target identifier, and / or the value in the original operand information does not match the value in the reference operand information, then it is determined that the operand information is inconsistent.
4. The method according to claim 2, characterized in that: The generating detection information for the instruction file based on the comparison result includes: In the case where the comparison result is the first comparison result, generating a first detection result for the instruction file; the first detection result is used to indicate that the instruction file is correct; When the comparison result is the second comparison result, a second detection result is generated for the instruction file; the second detection result is used to indicate that an error exists in the instruction file.
5. The method according to claim 1, characterized in that The output includes the detection information and a target instruction stream file of the instruction file, including: Generate a log file based on all the instruction files of the initial instruction stream file and the detection information of all the instruction files; The log file is used as the target instruction stream file and outputted.
6. The method according to claim 1, characterized in that The reference information includes first reference information and second reference information; The generating corresponding instruction information for the instruction file based on the preset decoding tool and the instruction code in the instruction file as reference information includes: Using the instruction code as input of the preset decoding tool, and calling the preset decoding tool to generate the first reference information and the second reference information; The first reference information and the second reference information are obtained by decoding the instruction code by the preset decoding tool using different decoding logics.
7. The method according to claim 1, characterized in that The initial instruction stream file is the instruction stream being generated by the instruction generator; the step of obtaining the instruction file of the initial instruction stream file includes: running the instruction generator so that the instruction generator starts to perform the initial instruction stream file generation operation; after the instruction generator generates an instruction file, obtaining the generated instruction file; Alternatively, the initial instruction stream file is an instruction stream that has been generated by the instruction generator; the instruction file for obtaining the initial instruction stream file includes: reading the initial instruction stream file generated by the instruction generator, and obtaining all instruction files included in the initial instruction stream file.
8. The method according to any one of claims 1 to 7, characterized in that: The way the instruction generator generates the original information is different from the way the preset decoding tool generates the reference information.
9. A device for generating an instruction stream file, characterized in that: The device comprises: An acquisition module, used for acquiring an instruction file of an initial instruction stream file; the initial instruction stream file is generated based on an instruction generator; A first generating module, for generating corresponding instruction information for the instruction file as reference information based on a preset decoding tool and the instruction code in the instruction file; a comparison module, used to take the instruction information included in the instruction file as original information, and compare the original information with the reference information to obtain a comparison result; the comparison result is used to indicate whether the original information is consistent with the reference information; A second generating module, configured to generate detection information for the instruction file based on the comparison result; the detection information is used to indicate whether the instruction file is correct; The output module is used to output a target instruction stream file including the detection information and the instruction file.
10. An electronic device, characterized in that: include: A processor, a memory, a communication interface and a communication bus, wherein the processor, the memory and the communication interface communicate with each other via the communication bus; The memory is used to store executable instructions, and the executable instructions enable the processor to execute the method according to any one of claims 1 to 8.
11. A readable medium, characterized in that: Executable instructions are stored thereon, which, when executed by one or more processors, cause the processors to perform the method according to any one of claims 1 to 8.
Citation Information
Patent Citations
Decoding method for safety control commands of safety command receiver
CN103095409A
LDPC decoder, LDPC decoding method, storage medium and electronic equipment
CN111525931A
Processor instruction set decoding method, system and equipment and storage medium
CN116610362A
Method for verifying decoding unit in NPU and related device and equipment
CN116629175A
Techniques for identifying instructions for decode-time instruction optimization grouping in view of cache boundaries
US20160139925A1
