Processor testing method, device, equipment and storage medium

By obtaining the target instruction attributes and instruction set, executing a fixed loop operation to generate an instruction sequence and conducting processor testing, it solves the time-consuming and uncontrollable problems in the existing technology and achieves completeness test coverage of instructions.

CN118626323BActive Publication Date: 2024-10-11BEIJING INSTITUTE OF OPEN SOURCE CHIP
View PDF 7 Cites 0 Cited by

Patent Information

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

AI Technical Summary

Technical Problem

In the existing technology, the completeness test of processor instructions is time-consuming and uncontrollable, and it is difficult to 100% guarantee coverage of all instructions.

Method used

By obtaining the target instruction attributes and the corresponding instruction set, executing a known and fixed number of loop operations to generate an instruction sequence, and executing the instruction sequence through the preset processor to complete the completeness test.

Benefits of technology

It realizes the instruction sequence that ensures the generation of all instructions after the number of instruction loop operations, solves the problem of uncontrollable time-consuming, and ensures the completeness test coverage of instructions.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN118626323B_ABST
    Figure CN118626323B_ABST
Patent Text Reader

Abstract

The present application provides a test method, device, electronic device and computer-readable storage medium for a processor, including: obtaining a configuration file, and determining a target instruction attribute recorded in the configuration file, the target instruction attribute is used to characterize the need to traverse and generate all instructions under the target instruction attribute; obtaining an instruction set corresponding to the target instruction attribute, and the number of instructions included in the instruction set, the instruction set including all instructions associated with the target instruction attribute; according to the instruction set, executing the instruction number of loop operations to generate an instruction sequence including all instructions under the target instruction attribute; executing the instruction sequence through a preset processor to obtain the test result of the processor. After executing the instruction number of loop operations, the present application can ensure that an instruction sequence including all instructions under the target instruction attribute is generated, achieving the purpose of completeness test coverage of all instructions.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present application relates to the field of computer technology, and in particular to a processor testing method, device, electronic device and computer-readable storage medium. Background Art

[0002] The integrity test of an instruction refers to testing all instructions associated with a certain instruction attribute.

[0003] Currently, instructions under the instruction attribute to be tested can be generated by random generation. If all instructions under the instruction attribute to be tested are to be generated, full coverage of the instructions can be achieved through a large number of random operations.

[0004] However, in the current solution, a large number of random operations are time-consuming and uncontrollable, and it is difficult to guarantee 100% coverage of all instructions. Summary of the invention

[0005] The embodiments of the present application provide a processor testing method, device, electronic device and computer-readable storage medium to solve the problems in the related art.

[0006] In a first aspect, an embodiment of the present application provides a method for testing a processor, the method comprising:

[0007] Obtain a configuration file, and determine a target instruction attribute recorded in the configuration file, wherein the target instruction attribute is used to represent all instructions under the target instruction attribute that need to be traversed and generated;

[0008] Acquire an instruction set corresponding to the target instruction attribute and the number of instructions included in the instruction set, wherein the instruction set includes all instructions associated with the target instruction attribute;

[0009] According to the instruction set, executing the instruction number of loop operations to generate an instruction sequence including all instructions under the target instruction attribute;

[0010] The instruction sequence is executed by a preset processor to obtain a test result of the processor.

[0011] In a second aspect, an embodiment of the present application provides a processor testing device, the device comprising:

[0012] An acquisition module, used for acquiring a configuration file and determining a target instruction attribute recorded in the configuration file, wherein the target instruction attribute is used for representing all instructions under the target instruction attribute that need to be traversed and generated;

[0013] An instruction set module, used to obtain an instruction set corresponding to the target instruction attribute and the number of instructions included in the instruction set, wherein the instruction set includes all instructions associated with the target instruction attribute;

[0014] A generating module, configured to execute the instruction number loop operations according to the instruction set, and generate an instruction sequence including all instructions under the target instruction attribute;

[0015] The test module is used to execute the instruction sequence through a preset processor to obtain the test result of the processor.

[0016] In a third aspect, an embodiment of the present application further provides an electronic device, including a processor;

[0017] a memory for storing instructions executable by the processor;

[0018] The processor is configured to execute the instructions to implement the method of the first aspect.

[0019] In a fourth aspect, an embodiment of the present application further provides a computer-readable storage medium, which, when instructions in the computer-readable storage medium are executed by a processor of an electronic device, enables the electronic device to execute the method of the first aspect.

[0020] In the embodiment of the present application, after obtaining the instruction set corresponding to the target instruction attribute and the number of instructions included in the instruction set, an instruction sequence including all instructions under the target instruction attribute is generated by executing the instruction number loop operation, and then the instruction sequence is executed by a preset processor to obtain the test result of the processor to complete the completeness test of the target instruction attribute. In the embodiment of the present application, the number of executions of the loop operation is known and fixed, which solves the problem of uncontrollable and long time-consuming caused by a large number of random operations in the related art. And after executing the instruction number loop operation, it can be ensured that the instruction sequence including all instructions under the target instruction attribute is generated, and the purpose of the completeness test covering all instructions is achieved.

[0021] The above description is only an overview of the technical solution of the present application. In order to more clearly understand the technical means of the present application, it can be implemented in accordance with the contents of the specification. In order to make the above and other purposes, features and advantages of the present application more obvious and easy to understand, the specific implementation methods of the present application are listed below. BRIEF DESCRIPTION OF THE DRAWINGS

[0022] In order to more clearly illustrate the technical solutions in the embodiments of the present invention, the drawings required for use in the description of the embodiments will be briefly introduced below. Obviously, the drawings described below are only some embodiments of the present invention. For ordinary technicians in this field, other drawings can be obtained based on these drawings without creative work.

[0023] Figure 1is a flowchart of a method for testing a processor provided in an embodiment of the present application;

[0024] Figure 2 It is a flowchart of the specific steps of a processor testing method provided in an embodiment of the present application;

[0025] Figure 3 It is a block diagram of a processor testing device provided in an embodiment of the present application;

[0026] Figure 4 is a block diagram of an electronic device provided by an embodiment of the present invention;

[0027] Figure 5 is a block diagram of another electronic device according to another embodiment of the present invention. DETAILED DESCRIPTION

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

[0029] The terms "first", "second", etc. in the specification and claims of the present application 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 under appropriate circumstances, so that the embodiments of the present application can be implemented in an order other than those illustrated or described here, and the objects distinguished by "first", "second", etc. are generally a class, 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 kinds of relationships can exist, for example, A and / or B can be represented: A exists alone, A and B exist at the same time, and B exists alone. The character " / " generally indicates that the front and back associated objects are a kind of "or" relationship. In the embodiment of the present application, the term "multiple" refers to two or more, and other quantifiers are similar.

[0030] Figure 1 , is a flowchart of a method for testing a processor provided in an embodiment of the present application, such as Figure 1 As shown, the method may include:

[0031] Step 101: Obtain a configuration file, and determine a target instruction attribute recorded in the configuration file, wherein the target instruction attribute is used to represent all instructions under the target instruction attribute that need to be traversed and generated.

[0032] In the embodiment of the present application, the configuration information in the configuration file is used to indicate the generation of an instruction sequence, and the instruction sequence is used to test the processor (Central Processing Unit, CPU). The embodiment of the present application can generate an instruction sequence corresponding to the configuration information in the configuration file through an instruction generator.

[0033] Specifically, the embodiment of the present application aims to perform a completeness test on all instructions associated with an instruction attribute, that is, to generate an instruction sequence including all instructions under the instruction attribute to be tested through an instruction generator, and then the processor executes the instruction sequence, and determines whether the instruction attribute to be tested passes the completeness test based on the execution result. Among them, instruction attributes can limit the data type, execution mode and other attributes of the instruction. Instruction attributes include but are not limited to integer type (referring to instructions for processing fixed-point numbers, mainly including integer addition instructions, integer subtraction instructions, etc.), floating-point type (referring to instructions for processing floating-point numbers (i.e., real numbers), these instructions usually include floating-point addition, subtraction, multiplication, division and other operations), vector type (referring to instructions for processing vector data. In modern processors, these instructions are used to perform vector operations, such as vector addition, vector multiplication, etc., which are usually used for graphics processing and scientific computing), jump type (including unconditional jump instructions and conditional jump instructions, which are used to change the execution order of the program and directly jump to the specified address to continue execution), loop type, shift type (instructions used to perform bit shift operations on data, including logical left shift, logical right shift, arithmetic right shift, etc. These operations can be used for data format conversion, numerical multiplication and division simplification, etc.).

[0034] Therefore, based on the above-mentioned completeness test requirements, the configuration file may include a target instruction attribute, and the target instruction attribute is used to represent all instructions under the target instruction attribute that need to be traversed and generated.

[0035] Step 102: Acquire an instruction set corresponding to the target instruction attribute and the number of instructions included in the instruction set, wherein the instruction set includes all instructions associated with the target instruction attribute.

[0036] In the embodiment of the present application, each instruction attribute has a corresponding instruction set, and the instruction set includes all instructions associated with the target instruction attribute. The instruction set can be obtained from the development document of the instruction architecture, the Internet, or a database. For example, a database records the instruction sets corresponding to each instruction attribute. For the target instruction attribute in the configuration file, the instruction set corresponding to the target instruction attribute can be obtained in the database.

[0037] In addition, by counting the instructions in the instruction set, the number of instructions can be obtained, and the number of instructions represents the total number of instructions in the instruction set. For example, assuming that an instruction set corresponding to an instruction attribute to be tested includes 100 instructions, the completeness test requires the instruction generator to generate an instruction sequence including these 100 instructions.

[0038] Step 103: According to the instruction set, execute the instruction number loop operation times to generate an instruction sequence including all instructions under the target instruction attribute.

[0039] In the embodiment of the present application, based on the requirements of the completeness test, the instruction generator is required to generate an instruction sequence including all instructions under the target instruction attribute to be tested. Specifically, after determining the number of instructions in the instruction set corresponding to the target instruction attribute to be tested, the instruction number of loop operations can be performed, and each loop operation can select an instruction from the instruction set to add to the instruction sequence, and ensure that the selected instruction does not repeat the existing instructions in the instruction sequence, so that after the instruction number of loop operations, an instruction sequence including all instructions under the target instruction attribute can be generated.

[0040] For example, assuming that an instruction set corresponding to an instruction attribute to be tested includes 100 instructions, then 100 loop operations are executed, and each loop operation can select an instruction from the instruction set to add to the instruction sequence. For example, for the 50th loop operation, if the instruction selected for the first time in the 50th loop operation repeats the instructions added to the instruction sequence for the first 49 loop operations, the second selection in the 50th loop operation is performed; if the instruction selected for the second time in the 50th loop operation repeats the instructions added to the instruction sequence for the first 49 loop operations, the third selection in the 50th loop operation is performed... and so on, until the instruction selected in the 50th loop operation does not repeat the instructions added to the instruction sequence for the first 49 loop operations. For example, if the instruction selected for the eighth time in the 50th loop operation does not repeat the instructions added to the instruction sequence for the first 49 loop operations, the instruction selected for the eighth time in the 50th loop operation is added to the instruction sequence, and then the next loop operation is performed.

[0041] Step 104: Execute the instruction sequence through a preset processor to obtain a test result of the processor.

[0042] In an embodiment of the present application, a processor can be configured to execute an instruction sequence and obtain a test result of the processor to complete a completeness test of the target instruction attribute. If the test result indicates that all instructions in the instruction sequence are successfully executed, the target instruction attribute currently passes the completeness test; otherwise, the target instruction attribute currently fails the completeness test.

[0043] The processor may be a virtual processor, and the virtual processor may be a program for simulating the processor generated according to a preset code, and the preset code is used to describe the working mechanism of the processor. Specifically, the preset code may be a register transfer level code in a Verilog (a hardware description language) code; the virtual processor is a program for simulating the processor compiled and generated by a simulator according to the preset code; and the test result is information of a signal generated by executing an instruction stream by the virtual processor.

[0044] In summary, in the embodiment of the present application, after obtaining the instruction set corresponding to the target instruction attribute and the number of instructions included in the instruction set, the instruction sequence including all instructions under the target instruction attribute can be generated by executing the instruction number loop operation, and then the instruction sequence is executed by the preset processor to obtain the test result of the processor to complete the completeness test of the target instruction attribute. In the embodiment of the present application, the number of executions of the loop operation is known and fixed, which solves the problem of uncontrollable and long time-consuming caused by a large number of random operations in the related art. And after executing the instruction number loop operation, it can be ensured that the instruction sequence including all instructions under the target instruction attribute is generated, and the purpose of the completeness test covering all instructions is achieved.

[0045] Figure 2 , is a flowchart of the specific steps of a processor testing method provided in an embodiment of the present application, such as Figure 2 As shown, the method may include:

[0046] Step 201: Obtain a configuration file, and determine a target instruction attribute recorded in the configuration file, wherein the target instruction attribute is used to represent all instructions under the target instruction attribute that need to be traversed and generated.

[0047] This step may specifically refer to the above step 101, which will not be described in detail here.

[0048] Step 202: Acquire an instruction set corresponding to the target instruction attribute and the number of instructions included in the instruction set, wherein the instruction set includes all instructions associated with the target instruction attribute.

[0049] This step may specifically refer to the above step 102, which will not be described in detail here.

[0050] Step 203: Add the corresponding relationship between the instruction quantity and the target instruction attribute to a preset associative array, wherein the associative array records the corresponding relationship between the instruction quantity and the instruction attribute.

[0051] In an embodiment of the present application, an associative array can be constructed, and the associative array is used to record various corresponding relationships, each corresponding relationship records the corresponding relationship between a number of instructions and an instruction attribute. When a plurality of instruction attributes are tested for completeness, the number of instructions corresponding to each instruction attribute can be recorded in the associative array. This allows the associative array to be used as a carrier of information, and the number of instructions corresponding to the target instruction attribute to be tested can be obtained from the associative array later. Among them, the associative array has the advantages of compact data structure and faster query response. The associative array maintains the corresponding relationship between the number of instructions and the instruction attribute, which can improve the overall performance of the test system. Of course, the embodiment of the present application can also carry the corresponding relationship between the number of instructions and the instruction attribute through other data structures, and the embodiment of the present application is not limited to this.

[0052] Step 204: Obtain the number of instructions corresponding to the target instruction attribute from the associative array, and execute the instruction number of loop operations according to the instruction set to generate an instruction sequence including all instructions under the target instruction attribute.

[0053] In the embodiment of the present application, since the associative array maintains the correspondence between the number of instructions and the instruction attributes, this step can obtain the number of instructions corresponding to the target instruction attribute from the associative array, and execute the instruction number loop operation according to the instruction set to generate an instruction sequence including all instructions under the target instruction attribute. Among them, the associative array has the advantages of compact data structure and fast query response, which greatly improves the performance of the test system.

[0054] Optionally, each of the loop operations includes:

[0055] Sub-step 2041: select an instruction from the instruction set and add it to the instruction sequence, and the instruction selected in each loop operation does not overlap with the existing instructions in the instruction sequence.

[0056] In the embodiment of the present application, the purpose of each loop operation is to select an instruction that does not repeat the existing instructions in the instruction sequence and add it to the instruction sequence. In this way, after the instruction number of loop operations, it can be ensured that an instruction sequence including all instructions under the target instruction attributes is generated, thereby achieving the purpose of completeness test coverage of all instructions.

[0057] Optionally, sub-step 2041 may specifically include:

[0058] Sub-step 20411: select an instruction from the instruction set, and obtain a comparison result between the selected instruction and the existing instructions in the instruction sequence.

[0059] Sub-step 20412: when the comparison result is that the selected instruction is different from all existing instructions in the instruction sequence, add the selected instruction to the instruction sequence and perform the next loop operation.

[0060] Sub-step 20413: When the comparison result is that the selected instruction is the same as an existing instruction in the instruction sequence, enter sub-step 20411.

[0061] In an embodiment of the present application, for sub-steps 20411-20413, each loop operation can randomly select an instruction from the instruction set, and obtain a comparison result between the selected instruction and the existing instructions in the instruction sequence. If the comparison results are inconsistent, the selected instruction can be added to the instruction sequence and the next loop operation is performed; if the comparison results are consistent, another instruction is randomly selected from the instruction set and the above judgment is repeated until the comparison result is that the selected instruction is different from all instructions in the instruction sequence, then the selected instruction is added to the instruction sequence and the next loop operation is performed.

[0062] By such a loop operation, it can be ensured that each loop operation selects an instruction that is not repeated with the existing instructions in the instruction sequence and adds it to the instruction sequence. In this way, after the instruction number of loop operations, it can be ensured that an instruction sequence including all instructions under the target instruction attribute is generated.

[0063] Step 205: Execute the instruction sequence through a preset processor to obtain a test result of the processor.

[0064] This step may refer to the above step 104 and will not be described in detail here.

[0065] Optionally, step 204 may specifically include:

[0066] Sub-step 2042, execute multiple generation operations to obtain multiple instruction sequences, each generation operation executes the instruction number loop operation according to the instruction set to generate an instruction sequence including all instructions under the target instruction attribute; the order of instructions in the instruction sequences generated by different generation operations is different.

[0067] Based on sub-step 2042, step 205 may specifically include:

[0068] Sub-step 2051: Execute the plurality of instruction sequences respectively by the processor to obtain a test result of the processor.

[0069] In an embodiment of the present application, for sub-step 2042 and sub-step 2051, the embodiment of the present application can perform multiple generation operations, and each generation operation executes the instruction number loop operation according to the instruction set to generate an instruction sequence including all instructions under the target instruction attribute. In this way, multiple instruction sequences can be obtained. Although these instruction sequences all include all instructions under the target instruction attribute, the order of these instructions in the instruction sequence is different, which makes the instruction sequences different from each other. By having the processor execute multiple instruction sequences separately to obtain the test results of the processor, the test quality can be improved by increasing the test samples.

[0070] For example, assuming that the target instruction attribute A includes instruction 1, instruction 2, instruction 3, instruction 4, and instruction 5, three generation operations can be performed to generate the instruction sequences [instruction 1, instruction 2, instruction 3, instruction 4, instruction 5]; [instruction 2, instruction 3, instruction 1, instruction 4, instruction 5]; and [instruction 4, instruction 1, instruction 2, instruction 5, instruction 3] respectively.

[0071] Optionally, the instruction has an associated object to be traversed, and the configuration file further includes: an identifier of the target object to be traversed, and the identifier of the target register is used to indicate that the target object to be traversed of the instruction is to be traversed; step 204 may specifically include:

[0072] Sub-step 2043: according to the instruction set, execute the instruction number loop operation times to generate an instruction sequence including all instructions under the target instruction attribute and the correspondence between the instructions and the target object to be traversed.

[0073] In the embodiment of the present application, the instruction may be associated with related objects, which may assist the execution of the instruction, including but not limited to the register of the instruction and the immediate value corresponding to the instruction. In the process of performing the completeness test of the target instruction attribute, the objects of the instruction under the target instruction attribute may be further traversed to improve the test quality.

[0074] Specifically, the configuration file may also include an identifier for indicating the object to be traversed. In the process of executing each loop operation according to the instruction set, when the instruction to be added to the instruction sequence is selected in each loop operation, the object to be traversed of the instruction can be further traversed, that is, a correspondence between the instruction and the object to be traversed is generated in the instruction sequence.

[0075] For example, if a loop operation selects instruction a to be added to the instruction sequence, and instruction a supports the object b to be traversed, and assuming that the object b to be traversed has three values ​​1, 2, and 3, then for instruction a, three instructions a-b1, a-b2, and a-b3 can be generated in the instruction sequence. a-b1 means traversing the value 1 of the object b to be traversed of instruction a, a-b2 means traversing the value 2 of the object b to be traversed of instruction a, and a-b3 means traversing the value 3 of the object b to be traversed of instruction a.

[0076] Optionally, in one implementation, the object to be traversed includes a register; each loop operation includes:

[0077] Sub-step 20431, select an instruction from the instruction set, and if the instruction has a target register, construct a correspondence between the instruction and each register number of the target register; the instruction selected for each loop operation does not repeat the existing instructions in the instruction sequence; the register number is 0-31.

[0078] Sub-step 20432: construct each of the corresponding relationships into an instruction in the instruction sequence.

[0079] In the embodiment of the present application, for sub-steps 20431-20432, the objects to be traversed may include registers, which may be used to transmit and temporarily store data, participate in arithmetic and logical operations, and save operation results. Registers have corresponding register numbers, which are 0-31. Traversing the registers of an instruction means traversing all register numbers of the registers of the instruction.

[0080] Specifically, in the process of executing each loop operation according to the instruction set, when selecting the instruction to be added to the instruction sequence in each loop operation, the register numbers of the registers of the instruction can be further traversed, that is, the correspondence between the instructions and the register numbers of the registers can be generated in the instruction sequence.

[0081] For example, the configuration file indicates that the target register rd of the instruction is traversed. If an instruction m to be added to the instruction sequence is selected in a loop operation, and the instruction m supports the target register rd, then for instruction m, 32 instructions m-rd0, m-rd1, m-rd2, m-rd3...m-rd31 can be generated in the instruction sequence. m-rd0 indicates that the target register rd of instruction m is assigned to 0, m-rd1 indicates that the target register rd of instruction m is assigned to 1, and m-rd2 indicates that the target register rd of instruction m is assigned to 2...

[0082] In addition, if another loop operation selects instruction n to be added to the instruction sequence, and the instruction n does not support the target register rd, then for the instruction n, the instruction n can be directly generated in the instruction sequence by a method of randomly generating operands.

[0083] Optionally, in another implementation, the object to be traversed includes an immediate value; each loop operation includes:

[0084] Sub-step 20433: selecting an instruction from the instruction set, and if the instruction supports the target immediate number, constructing a correspondence between the instruction and each bit of the target immediate number; the instruction selected in each loop operation does not overlap with the existing instructions in the instruction sequence;

[0085] Sub-step 20434: construct each of the corresponding relationships into an instruction in the instruction sequence.

[0086] In the embodiment of the present application, for sub-steps 20433-20434, the object to be traversed may include an immediate number, which is an operand that can be directly obtained by parsing the relevant bit field of the instruction code, which can be 5 bits, 8 bits or 11 bits. The immediate number follows the operation code. The uses of the immediate number include immediate addressing, operands in arithmetic operations, offsets in jump instructions, etc. If the number of bits of the immediate number is x, then when traversing, the immediate number is traversed from the number of bits: 0 to the number of bits: 2 x -1.

[0087] Specifically, in the process of executing each loop operation according to the instruction set, when selecting the instruction to be added to the instruction sequence in each loop operation, the number of bits of the instruction's immediate number can be further traversed, that is, a correspondence between the instruction and the number of bits of the immediate number is generated in the instruction sequence.

[0088] For example, the configuration file indicates that the target immediate number k of the instruction is traversed, and the bit field of k is 6. If an instruction p to be added to the instruction sequence is selected in a loop operation, and the instruction p supports the target immediate number k, then for instruction p, p-k0, p-k1, p-k2, p-k3...p-k2 can be generated in the instruction sequence. 6 -1, p-k0 means assigning the target immediate value k of instruction p to 0, p-k1 means assigning the target immediate value k of instruction p to 1, p-k2 means assigning the target immediate value k of instruction p to 2... For example, in a 6-bit bit field, the binary 000000 means 0; 000001 means 1, 00010 means 2; 000011 means 3...

[0089] In addition, if another loop operation selects instruction q to be added to the instruction sequence, and the instruction q does not support the target immediate number k, then for instruction q, instruction q can be directly generated in the instruction sequence.

[0090] In summary, in the embodiment of the present application, after obtaining the instruction set corresponding to the target instruction attribute and the number of instructions included in the instruction set, the instruction sequence including all instructions under the target instruction attribute can be generated by executing the instruction number loop operation, and then the instruction sequence is executed by the preset processor to obtain the test result of the processor to complete the completeness test of the target instruction attribute. In the embodiment of the present application, the number of executions of the loop operation is known and fixed, which solves the problem of uncontrollable and long time-consuming caused by a large number of random operations in the related art. And after executing the instruction number loop operation, it can be ensured that the instruction sequence including all instructions under the target instruction attribute is generated, and the purpose of the completeness test covering all instructions is achieved.

[0091] Figure 3 : is a block diagram of a processor testing device provided in an embodiment of the present application, the device comprising:

[0092] The acquisition module 301 is used to acquire a configuration file and determine a target instruction attribute recorded in the configuration file, wherein the target instruction attribute is used to represent all instructions under the target instruction attribute that need to be traversed and generated;

[0093] An instruction set module 302, configured to obtain an instruction set corresponding to the target instruction attribute and the number of instructions included in the instruction set, wherein the instruction set includes all instructions associated with the target instruction attribute;

[0094] A generating module 303 is used to execute the instruction number loop operation according to the instruction set to generate an instruction sequence including all instructions under the target instruction attribute;

[0095] The testing module 304 is used to execute the instruction sequence through a preset processor to obtain a test result of the processor.

[0096] Optionally, each of the loop operations includes:

[0097] An instruction is selected from the instruction set and added to the instruction sequence, and the instruction selected in each loop operation does not overlap with the existing instructions in the instruction sequence.

[0098] Optionally, selecting an instruction from the instruction set and adding it to the instruction sequence includes:

[0099] Selecting an instruction from the instruction set, and obtaining a comparison result between the selected instruction and the existing instructions in the instruction sequence;

[0100] When the comparison result is that the selected instruction is different from all existing instructions in the instruction sequence, adding the selected instruction to the instruction sequence and performing the next cycle operation;

[0101] When the comparison result is that the selected instruction is the same as an existing instruction in the instruction sequence, the step of selecting an instruction from the instruction set is entered.

[0102] Optionally, the device further comprises:

[0103] An array module, used for adding the correspondence between the instruction quantity and the target instruction attribute into a preset associative array, wherein the associative array records the correspondence between the instruction quantity and the instruction attribute;

[0104] The generating module 303 includes:

[0105] A generating submodule is used to obtain the instruction quantity corresponding to the target instruction attribute from the associative array, and execute the instruction quantity cycle operation according to the instruction set.

[0106] Optionally, the generating module 303 includes:

[0107] A multiple generation submodule is used to perform multiple generation operations to obtain multiple instruction sequences, each of which is performed according to the instruction set, and the instruction number is looped to generate an instruction sequence including all instructions under the target instruction attribute; the order of instructions in the instruction sequences generated by different generation operations is different;

[0108] The testing module 304 includes:

[0109] The testing submodule is used to execute the plurality of instruction sequences respectively through the processor to obtain the testing result of the processor.

[0110] Optionally, the instruction has an associated object to be traversed, and the configuration file further includes: an identifier of a target object to be traversed, the identifier of the target object to be traversed being used to indicate that the target object to be traversed of the instruction is to be traversed;

[0111] The generating module 303 includes:

[0112] The traversal generation submodule is used to execute the instruction number loop operation according to the instruction set, and generate an instruction sequence including all instructions under the target instruction attribute and the corresponding relationship between the instructions and the target object to be traversed.

[0113] Optionally, the object to be traversed includes a register;

[0114] Each cycle operation includes:

[0115] An instruction is selected from the instruction set, and when the instruction has a target register, a corresponding relationship between the instruction and each register number of the target register is established; the instruction selected by each loop operation does not repeat the existing instruction in the instruction sequence; the register number is 0-31;

[0116] Each of the corresponding relationships is constructed as an instruction in the instruction sequence.

[0117] Optionally, the object to be traversed includes an immediate value;

[0118] Each cycle operation includes:

[0119] An instruction is selected from the instruction set, and when the instruction supports the target immediate number, a corresponding relationship between the instruction and each bit of the target immediate number is established; the instruction selected by the loop operation each time does not repeat the existing instruction in the instruction sequence;

[0120] Each of the corresponding relationships is constructed as an instruction in the instruction sequence.

[0121] In summary, in the embodiment of the present application, after obtaining the instruction set corresponding to the target instruction attribute and the number of instructions included in the instruction set, the instruction sequence including all instructions under the target instruction attribute can be generated by executing the instruction number loop operation, and then the instruction sequence is executed by the preset processor to obtain the test result of the processor to complete the completeness test of the target instruction attribute. In the embodiment of the present application, the number of executions of the loop operation is known and fixed, which solves the problem of uncontrollable and long time-consuming caused by a large number of random operations in the related art. And after executing the instruction number loop operation, it can be ensured that the instruction sequence including all instructions under the target instruction attribute is generated, and the purpose of the completeness test covering all instructions is achieved.

[0122] 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.

[0123] 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.

[0124] Regarding the 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.

[0125] An embodiment of the present application provides a testing device for a processor, comprising a memory and one or more programs, wherein the one or more programs are stored in the memory and are configured to be executed by one or more processors to include methods for performing one or more of the above-mentioned embodiments.

[0126] Figure 4 is a block diagram of an electronic device 600 according to an exemplary embodiment. For example, the electronic device 600 may be a mobile phone, a computer, a digital broadcast terminal, a messaging device, a game console, a tablet device, a medical device, a fitness device, a personal digital assistant, etc.

[0127] Reference Figure 4 , the electronic device 600 may include one or more of the following components: a processing component 602 , a memory 604 , a power component 606 , a multimedia component 608 , an audio component 610 , an input / output (I / O) interface 612 , a sensor component 614 , and a communication component 616 .

[0128] The processing component 602 generally controls the overall operation of the electronic device 600, such as operations associated with display, phone calls, data communications, camera operations, and recording operations. The processing component 602 may include one or more processors 620 to execute instructions to complete all or part of the steps of the above-mentioned method. In addition, the processing component 602 may include one or more modules to facilitate the interaction between the processing component 602 and other components. For example, the processing component 602 may include a multimedia module to facilitate the interaction between the multimedia component 608 and the processing component 602.

[0129] The memory 604 is used to store various types of data to support the operation of the electronic device 600. Examples of such data include instructions for any application or method operating on the electronic device 600, contact data, phone book data, messages, pictures, multimedia, etc. The memory 604 can be implemented by any type of volatile or non-volatile storage device or a combination thereof, such as static random access memory (SRAM), electrically erasable programmable read-only memory (EEPROM), erasable programmable read-only memory (EPROM), programmable read-only memory (PROM), read-only memory (ROM), magnetic memory, flash memory, magnetic disk or optical disk.

[0130] The power supply component 606 provides power to the various components of the electronic device 600. The power supply component 606 may include a power management system, one or more power supplies, and other components associated with generating, managing, and distributing power to the electronic device 600.

[0131] The multimedia component 608 includes a screen that provides an output interface between the electronic device 600 and the user. In some embodiments, the screen may include a liquid crystal display (LCD) and a touch panel (TP). If the screen includes a touch panel, the screen may be implemented as a touch screen to receive input signals from the user. The touch panel includes one or more touch sensors to sense touch, slide, and gestures on the touch panel. The touch sensor may not only sense the boundaries of the touch or slide action, but also detect the duration and pressure associated with the touch or slide operation. In some embodiments, the multimedia component 608 includes a front camera and / or a rear camera. When the electronic device 600 is in an operating mode, such as a shooting mode or a multimedia mode, the front camera and / or the rear camera may receive external multimedia data. Each front camera and rear camera may be a fixed optical lens system or have a focal length and optical zoom capability.

[0132] The audio component 610 is used to output and / or input audio signals. For example, the audio component 610 includes a microphone (MIC), and when the electronic device 600 is in an operation mode, such as a call mode, a recording mode, and a voice recognition mode, the microphone is used to receive an external audio signal. The received audio signal can be further stored in the memory 604 or sent via the communication component 616. In some embodiments, the audio component 610 also includes a speaker for outputting audio signals.

[0133] I / O interface 612 provides an interface between processing component 602 and peripheral interface modules, such as keyboards, click wheels, buttons, etc. These buttons may include but are not limited to: a home button, a volume button, a start button, and a lock button.

[0134] The sensor assembly 614 includes one or more sensors for providing various aspects of status assessment for the electronic device 600. For example, the sensor assembly 614 can detect the open / closed state of the electronic device 600, the relative positioning of the components, such as the display and keypad of the electronic device 600, and the sensor assembly 614 can also detect the position change of the electronic device 600 or a component of the electronic device 600, the presence or absence of contact between the user and the electronic device 600, the orientation or acceleration / deceleration of the electronic device 600, and the temperature change of the electronic device 600. The sensor assembly 614 may include a proximity sensor configured to detect the presence of a nearby object without any physical contact. The sensor assembly 614 may also include an optical sensor, such as a CMOS or CCD image sensor, for use in imaging applications. In some embodiments, the sensor assembly 614 may also include an acceleration sensor, a gyroscope sensor, a magnetic sensor, a pressure sensor, or a temperature sensor.

[0135] The communication component 616 is used to facilitate wired or wireless communication between the electronic device 600 and other devices. The electronic device 600 can access a wireless network based on a communication standard, such as WiFi, a carrier network (such as 2G, 3G, 4G or 5G), or a combination thereof. In an exemplary embodiment, the communication component 616 receives a broadcast signal or broadcast-related information from an external broadcast management system via a broadcast channel. In an exemplary embodiment, the communication component 616 also includes a near field communication (NFC) module to facilitate short-range communication. For example, the NFC module can be implemented based on radio frequency identification (RFID) technology, infrared data association (IrDA) technology, ultra-wideband (UWB) technology, Bluetooth (BT) technology and other technologies.

[0136] In an exemplary embodiment, the electronic device 600 may be implemented by one or more application-specific integrated circuits (ASICs), digital signal processors (DSPs), digital signal processing devices (DSPDs), programmable logic devices (PLDs), field programmable gate arrays (FPGAs), controllers, microcontrollers, microprocessors, or other electronic components to implement the methods provided in the embodiments of the present application.

[0137] In an exemplary embodiment, a non-transitory computer-readable storage medium including instructions is also provided, such as a memory 604 including instructions, and the instructions can be executed by a processor 620 of an electronic device 600 to perform the above method. For example, the non-transitory storage medium can be a ROM, a random access memory (RAM), a CD-ROM, a magnetic tape, a floppy disk, an optical data storage device, etc.

[0138] Figure 5 is a block diagram of an electronic device 700 according to an exemplary embodiment. For example, the electronic device 700 may be provided as a server. Figure 5 The electronic device 700 includes a processing component 722, which further includes one or more processors, and a memory resource represented by a memory 732 for storing instructions that can be executed by the processing component 722, such as an application. The application stored in the memory 732 may include one or more modules, each corresponding to a set of instructions. In addition, the processing component 722 is configured to execute instructions to perform the method provided in the embodiment of the present application.

[0139] The electronic device 700 may also include a power supply component 726 configured to perform power management of the electronic device 700, a wired or wireless network interface 750 configured to connect the electronic device 700 to a network, and an input / output (I / O) interface 758. The electronic device 700 may operate based on an operating system stored in the memory 732, such as Windows Server TM, Mac OS X TM, Unix TM, Linux TM, FreeBSD TM or the like.

[0140] An embodiment of the present application further provides a computer program product, including a computer program, which implements the method described in the above embodiment when executed by a processor.

[0141] Those skilled in the art will readily appreciate other embodiments of the present application after considering the specification and practicing the application disclosed herein. The present application is intended to cover any modification, use or adaptation of the present application, which follows the general principles of the present application and includes common knowledge or customary techniques in the art that are not disclosed in the present disclosure. The specification and examples are intended to be exemplary only, and the true scope and spirit of the present application are indicated by the following claims.

[0142] It should be understood that the present application is not limited to the precise structures that have been described above and shown in the drawings, and that various modifications and changes may be made without departing from the scope thereof. The scope of the present application is limited only by the appended claims.

Claims

1. A method for testing a processor, characterized in that: The method comprises: Obtain a configuration file, and determine a target instruction attribute recorded in the configuration file, wherein the target instruction attribute is used to represent all instructions under the target instruction attribute that need to be traversed and generated; Acquire an instruction set corresponding to the target instruction attribute and the number of instructions included in the instruction set, wherein the instruction set includes all instructions associated with the target instruction attribute; According to the instruction set, executing the instruction number of loop operations to generate an instruction sequence including all instructions under the target instruction attribute; The instruction sequence is executed by a preset processor to obtain a test result of the processor; the instruction has an associated object to be traversed, and the configuration file further includes: an identifier of a target object to be traversed, and the identifier of the target object to be traversed is used to indicate that the target object to be traversed of the instruction is traversed; The step of executing the instruction number loop operations according to the instruction set to generate an instruction sequence including all instructions under the target instruction attribute includes: According to the instruction set, the instruction number of loop operations are executed to generate an instruction sequence including all instructions under the target instruction attribute and the corresponding relationship between the instructions and the target object to be traversed.

2. The processor testing method according to claim 1, characterized in that: Each cycle operation includes: An instruction is selected from the instruction set and added to the instruction sequence, and the instruction selected in each loop operation does not overlap with the existing instructions in the instruction sequence.

3. The processor testing method according to claim 2, characterized in that: The step of selecting an instruction from the instruction set and adding it to the instruction sequence comprises: Selecting an instruction from the instruction set, and obtaining a comparison result between the selected instruction and the existing instructions in the instruction sequence; When the comparison result is that the selected instruction is different from all existing instructions in the instruction sequence, adding the selected instruction to the instruction sequence and performing the next cycle operation; When the comparison result is that the selected instruction is the same as an existing instruction in the instruction sequence, the step of selecting an instruction from the instruction set is entered.

4. The processor testing method according to claim 1, characterized in that: After acquiring the instruction set corresponding to the target instruction attribute and the number of instructions included in the instruction set, the method further includes: Adding the correspondence between the instruction quantity and the target instruction attribute into a preset associative array, wherein the associative array records the correspondence between the instruction quantity and the instruction attribute; The step of executing the instruction number loop operations according to the instruction set includes: The number of instructions corresponding to the target instruction attribute is obtained from the associative array, and the number of loop operations of the instructions is executed according to the instruction set.

5. The processor testing method according to claim 4, characterized in that: The step of executing the instruction number loop operations according to the instruction set to generate an instruction sequence including all instructions under the target instruction attribute includes: Perform multiple generation operations to obtain multiple instruction sequences, each of which performs the instruction number loop operation according to the instruction set to generate an instruction sequence including all instructions under the target instruction attribute; the order of instructions in the instruction sequences generated by different generation operations is different; The step of executing the instruction sequence by a preset processor to obtain a test result of the processor includes: The processor executes the plurality of instruction sequences respectively to obtain a test result of the processor.

6. The processor testing method according to claim 1, characterized in that: The objects to be traversed include registers; Each cycle operation includes: An instruction is selected from the instruction set, and when the instruction has a target register, a corresponding relationship between the instruction and each register number of the target register is established; the instruction selected by each loop operation does not repeat the existing instruction in the instruction sequence; the register number is 0-31; Each of the corresponding relationships is constructed as an instruction in the instruction sequence.

7. The processor testing method according to claim 1, characterized in that: The object to be traversed includes an immediate number; Each cycle operation includes: An instruction is selected from the instruction set, and when the instruction supports the target immediate number, a corresponding relationship between the instruction and each bit of the target immediate number is established; the instruction selected by the loop operation each time does not repeat the existing instruction in the instruction sequence; Each of the corresponding relationships is constructed as an instruction in the instruction sequence.

8. A processor testing device, characterized in that: The device comprises: An acquisition module, used for acquiring a configuration file and determining a target instruction attribute recorded in the configuration file, wherein the target instruction attribute is used for representing all instructions under the target instruction attribute that need to be traversed and generated; An instruction set module, used to obtain an instruction set corresponding to the target instruction attribute and the number of instructions included in the instruction set, wherein the instruction set includes all instructions associated with the target instruction attribute; A generating module, configured to execute the instruction number loop operations according to the instruction set, and generate an instruction sequence including all instructions under the target instruction attribute; A test module, used for executing the instruction sequence through a preset processor to obtain a test result of the processor; The instruction has an associated object to be traversed, and the configuration file further includes: an identifier of a target object to be traversed, the identifier of the target object to be traversed is used to indicate that the target object to be traversed of the instruction is to be traversed; The step of executing the instruction number loop operations according to the instruction set to generate an instruction sequence including all instructions under the target instruction attribute includes: According to the instruction set, the instruction number of loop operations are executed to generate an instruction sequence including all instructions under the target instruction attribute and the corresponding relationship between the instructions and the target object to be traversed.

9. An electronic device, characterized in that: include: processor; a memory for storing instructions executable by the processor; The processor is configured to execute the instructions to implement the method according to any one of claims 1 to 7.

10. A computer-readable storage medium, characterized in that: When the instructions in the computer-readable storage medium are executed by a processor of an electronic device, the electronic device is enabled to perform the method as claimed in any one of claims 1 to 7.

Citation Information

Patent Citations

  • Instruction information query and execution debugging method based on instruction set simulator

    CN110673878A

  • Ground station instruction verification system

    CN114500350A

  • Instruction generation system and method, electronic equipment and storage medium

    CN118363663A

  • Providing loop-invariant value prediction using a predicted values table, and related apparatuses, methods, and computer-readable media

    US20160139933A1

  • Methods, devices, and media for processing loop instruction set

    US20200409703A1