Random instruction verification method, device and system of processor, equipment and medium
By obtaining and comparing verification use cases of random instruction fragments, initial memory data and result memory data, the processor's inefficiency in random instruction verification is solved, and a fast and automated verification process is realized, reducing the verification time cost.
Patent Information
- Application Number
- CN202411182750.5
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2024-08-27
- Publication Date
- 2024-12-03
AI Technical Summary
Existing processors are inefficient in random instruction verification, making it difficult to quickly, automatically and accurately verify instruction execution results, resulting in high verification time cost.
By obtaining verification use cases of random instruction fragments, initial memory data and result memory data, it is sent to the processor to be tested for running, and the result comparison is performed to ensure the correctness of instruction execution and improve verification efficiency.
It realizes the rapid, automation and accuracy of processor random instruction verification, reduces verification time cost, and improves processor verification efficiency.
Smart Images

Figure CN119065905A_ABST
Abstract
Description
Technical Field
[0001] The present application belongs to the field of computers, and specifically relates to a random instruction verification method, device, system, electronic device and computer-readable storage medium for a processor. Background Art
[0002] In order to meet various requirements, such as accuracy and performance requirements, today's processors are designed to be more and more complex. They need to be verified during the design process. The system-level verification of most processors involves the verification of random instructions, and the system verification of random instructions plays an important role in modern processor verification. The existing technologies and methods for generating random instructions have also become increasingly mature. The generated random instructions have the following specific characteristics: the number of instructions is huge, the execution results may be uncertain in the instructions, and the time cost of chip verification requires that the instruction verification must be highly efficient. Therefore, based on the above three characteristics of randomly generated instructions, random instructions need to be fast, automated, and accurate in the system verification of processors. Therefore, it is particularly important to verify the correctness of the execution of random instructions. Summary of the invention
[0003] In view of this, the purpose of the present application is to provide a random instruction verification method, device, system, electronic device and computer-readable storage medium for a processor to improve the random instruction verification efficiency of the processor.
[0004] The embodiment of the present application is implemented as follows:
[0005] In a first aspect, an embodiment of the present application provides a random instruction verification method for a processor, comprising: obtaining a random instruction verification use case, the random instruction verification use case comprising: a random instruction fragment, initial memory data required for the execution of the random instruction fragment, and result memory data after the random instruction fragment is simulated and executed; sending the random instruction fragment and the initial memory data in the random instruction verification use case to a processor to be tested, so that the processor to be tested executes the random instruction fragment according to the initial memory data to obtain execution memory data; wherein the result memory data and the execution memory data are used for random instruction verification of the processor to be tested.
[0006] In the above embodiment, a random instruction verification case including: a random instruction fragment, initial memory data required for the random instruction fragment to run, and result memory data after the random instruction fragment is simulated and run is obtained to ensure that the executed instructions are all valid random verification instruction fragments, and then the random instruction fragment and the initial memory data in the random instruction verification case are sent to the processor to be tested, so that the processor to be tested runs the random instruction fragment according to the initial memory data to obtain the running memory data, and then the random instruction verification of the processor to be tested can be implemented according to the result memory data and the running memory data. For example, it is only necessary to compare the result memory data and the running memory data for consistency to obtain whether the random instruction is executed correctly, so as to verify the function of the processor to be tested. Since it is only necessary to compare the memory data, the random instruction verification efficiency of the processor is improved.
[0007] In combination with a possible implementation manner of the embodiment of the first aspect, before obtaining the random instruction verification use case, the method also includes: generating the random instruction fragment and the initial memory data required for the operation of the random instruction fragment according to instruction rules and constraints; inputting the random instruction fragment and the initial memory data into a reference machine or a simulator for operation to obtain the result memory data; and obtaining the random instruction verification use case based on the random instruction fragment, the initial memory data and the result memory data.
[0008] In the above embodiment, when generating random instruction fragments and initial memory data required for the operation of the random instruction fragments, they are generated according to instruction rules (configurable) and constraints (configurable). Since both the instruction rules and constraints are configurable, they can adapt to different scenarios. Then, the random instruction fragments and the initial memory data are input into a reference machine or a simulator for operation to obtain the result memory data. In this process, it can be ensured that the instruction itself can be executed correctly, so that the processor can be verified through random instruction verification use cases in the future, thereby improving the verification efficiency.
[0009] In combination with a possible implementation manner of the first aspect embodiment, the method also includes: obtaining the running memory data; performing a consistency comparison between the running memory data and the result memory data to obtain a comparison result; and determining a verification result of the random instruction of the processor to be tested based on the comparison result.
[0010] In the above embodiment, the running memory data and the result memory data are compared for consistency, and the verification result of the random instruction of the processor to be tested is determined according to the comparison result; since the processor itself is only used for calculation, all data comes only from the memory, and the data read and written back during the instruction execution process all come from the memory data. Therefore, by only comparing the running memory data and the result memory data, it can be obtained whether the random instruction is executed correctly.
[0011] In combination with a possible implementation manner of the first aspect, the running memory data and the result memory data both contain data from multiple memory addresses; the running memory data and the result memory data are compared for consistency, including: comparing the data from the same memory address in the running memory data and the result memory data.
[0012] In the above embodiment, when performing the comparison, the data from the same memory address in the running memory data and the result memory data are compared, that is, whether the data on the same memory address is the same is compared, so as to ensure whether the contents of the two are consistent. Only when the data on the same memory address is the same, it is considered consistent.
[0013] In combination with a possible implementation method of the first aspect, the running memory data and the result memory data are compared for consistency, including: running the running memory data and the result memory data using the same hash algorithm to obtain their respective corresponding strings; comparing the string corresponding to the running memory data with the string corresponding to the result memory data.
[0014] In the above embodiment, when performing consistency comparison, the running memory data and the result memory data are operated using the same hash algorithm, and the character strings obtained after the operation are compared to see whether they are the same, which can improve the comparison efficiency.
[0015] In combination with a possible implementation manner of the first aspect, if the processor to be tested is tested using multiple random instruction verification use cases, accordingly, the comparison result includes the comparison results of multiple random instruction verification use cases; the verification result of the random instruction of the processor to be tested is determined based on the comparison result, including: if there is at least one comparison result among the multiple comparison results that is inconsistent in representation, determining that the verification result of the random instruction of the processor to be tested fails.
[0016] In the above embodiment, if the comparison results of multiple random instruction verification use cases are included, as long as there is at least one comparison result representation inconsistency among the multiple comparison results, it is determined that the verification result of the random instruction of the processor to be tested has failed. Only when all the comparison results are consistent, it is determined that the verification result of the random instruction of the processor to be tested has passed, so as to ensure that the processor functions normally. Using multiple random instruction verification use cases to test the processor to be tested can improve the test efficiency.
[0017] In combination with a possible implementation method of the first aspect, the number of processors to be tested is multiple, and the random instruction fragments and initial memory data in the random instruction verification use case are sent to the processors to be tested, including: sending random instruction fragments and initial memory data in different random instruction verification use cases to the multiple processors to be tested, so that the multiple processors to be tested run different random instruction verification use cases at the same time.
[0018] In the above embodiment, by sending different random instruction verification cases to multiple processors to be tested, the multiple processors to be tested can run different random instruction verification cases at the same time, thereby improving the verification efficiency.
[0019] In a second aspect, an embodiment of the present application also provides a random instruction verification method for a processor, which is applied to a processor to be tested, and the method includes: receiving a random instruction fragment and initial memory data in a random instruction verification use case sent from a control machine; wherein the random instruction verification use case includes: a random instruction fragment, initial memory data required for the operation of the random instruction fragment, and result memory data after the random instruction fragment is simulated and run; running the random instruction fragment according to the initial memory data to obtain running memory data; wherein the result memory data and the running memory data are used for random instruction verification of the processor to be tested.
[0020] In the above embodiment, a random instruction verification case including: a random instruction fragment, initial memory data required for the random instruction fragment to run, and result memory data after the random instruction fragment is simulated and run is obtained to ensure that the executed instructions are all valid random verification instruction fragments, and then the random instruction fragment and the initial memory data in the random instruction verification case are sent to the processor to be tested, so that the processor to be tested runs the random instruction fragment according to the initial memory data to obtain the running memory data, and then the random instruction verification of the processor to be tested can be implemented according to the result memory data and the running memory data. For example, it is only necessary to compare the result memory data and the running memory data for consistency to obtain whether the random instruction is executed correctly, so as to verify the function of the processor to be tested. Since it is only necessary to compare the memory data, the random instruction verification efficiency of the processor is improved.
[0021] In combination with a possible implementation method of the second aspect embodiment, receiving a random instruction fragment and initial memory data in a random instruction verification use case sent from a control machine includes: writing the received random instruction fragment and initial memory data into a corresponding memory; running the random instruction fragment according to the initial memory data, and obtaining the running memory data includes: after receiving the information sent by the control machine indicating that the random instruction fragment and the initial memory data have been sent, jumping to a specific address, and running the random instruction fragment according to the initial memory data, wherein the specific address is a preset starting execution address in the memory; writing the cache data generated by running the random instruction fragment back to the memory to obtain the running memory data.
[0022] In the above embodiment, the received data (including random instruction fragments and initial memory data) are written into the corresponding memory, and only after receiving the information sent by the control machine indicating that the data transmission is completed, the random instruction fragment is jumped to a specific address and executed according to the initial memory data. This ensures that the executed random instruction fragment is complete data, thereby ensuring the accuracy of the random instruction test. At the same time, the cache data generated by the execution of the random instruction fragment is written back to the memory to obtain the execution memory data, so that the random instruction verification of the processor to be tested can be implemented based on the execution memory data and the result memory data.
[0023] In a third aspect, an embodiment of the present application also provides a random instruction verification system for a processor, comprising: a test machine, including a processor, and a control machine; the control machine is configured to obtain a random instruction verification use case, and send a random instruction fragment and initial memory data in the random instruction verification use case to the test machine, wherein the random instruction verification use case includes: a random instruction fragment, the initial memory data required for the operation of the random instruction fragment, and the result memory data after the random instruction fragment is simulated and run; the test machine is configured to run the random instruction fragment according to the initial memory data to obtain running memory data; wherein the result memory data and the running memory data are used for random instruction verification of the processor in the test machine.
[0024] In a fourth aspect, an embodiment of the present application also provides a random instruction verification device for a processor, comprising: an acquisition module and a sending module; the acquisition module is used to acquire a random instruction verification use case, and the random instruction verification use case includes: a random instruction fragment, initial memory data required for the operation of the random instruction fragment, and result memory data after the random instruction fragment is simulated and run; the sending module is used to send the random instruction fragment and initial memory data in the random instruction verification use case to a processor to be tested, so that the processor to be tested runs the random instruction fragment according to the initial memory data to obtain running memory data; wherein the result memory data and the running memory data are used for random instruction verification of the processor to be tested.
[0025] In the fifth aspect, an embodiment of the present application also provides an electronic device, comprising: a memory and a processor, the processor being connected to the memory; the memory being used to store programs; the processor being used to call the programs stored in the memory to execute the method provided by the above-mentioned first aspect embodiment and / or any possible implementation method in combination with the first aspect embodiment, or to execute the method provided by the above-mentioned second aspect embodiment.
[0026] In a sixth aspect, an embodiment of the present application further provides a computer-readable storage medium, characterized in that a computer program is stored thereon, and when the computer program is executed by a processor, it executes the method provided by the above-mentioned first aspect embodiment and / or any possible implementation method combined with the first aspect embodiment, or executes the method provided by the above-mentioned second aspect embodiment.
[0027] The beneficial effects of the above-mentioned third aspect embodiment to the sixth aspect embodiment are the same as the effective effects of the method provided by the above-mentioned first aspect embodiment and / or any possible implementation method combined with the first aspect embodiment.
[0028] Other features and advantages of the present application will be described in the following description. The purpose and other advantages of the present application can be realized and obtained through the structures specifically pointed out in the written description and the drawings. BRIEF DESCRIPTION OF THE DRAWINGS
[0029] In order to more clearly illustrate the embodiments of the present application or the technical solutions in the prior art, the drawings required for use in the embodiments are briefly introduced below. Obviously, the drawings described below are only some embodiments of the present application. For ordinary technicians in this field, other drawings can be obtained based on these drawings without creative work. The above and other purposes, features and advantages of the present application will be more clear as shown in the drawings.
[0030] Figure 1A schematic flow chart of a random instruction verification method for a processor provided in an embodiment of the present application is shown.
[0031] Figure 1a A flow chart of another random instruction verification method for a processor provided in an embodiment of the present application is shown.
[0032] Figure 2 A schematic structural diagram of a random instruction verification system for a processor provided in an embodiment of the present application is shown.
[0033] Figure 3 A schematic diagram of the interaction between a control machine and a test machine provided in an embodiment of the present application is shown.
[0034] Figure 4 A schematic diagram showing the principle of a random instruction verification method for a processor provided in an embodiment of the present application is shown.
[0035] Figure 5 A module schematic diagram of a random instruction verification device for a processor provided in an embodiment of the present application is shown.
[0036] Figure 6 A schematic structural diagram of an electronic device provided in an embodiment of the present application is shown. DETAILED DESCRIPTION
[0037] The technical solutions in the embodiments of the present application will be described below in conjunction with the accompanying drawings in the embodiments of the present application. Obviously, the described embodiments are only a part of the embodiments of the present application, rather than all of the embodiments. The following embodiments can be used as examples to more clearly illustrate the technical solutions of the present application, and cannot be used to limit the scope of protection of the present application. It will be appreciated by those skilled in the art that, in the absence of conflict, the features in the following embodiments and embodiments can be combined with each other.
[0038] It should be noted that similar numbers and letters represent similar items in the following figures, so once an item is defined in one figure, it does not need to be further defined and explained in subsequent figures. At the same time, in the description of this application, relational terms such as "first", "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 "comprise", "include" or any other variants thereof are intended to cover non-exclusive inclusion, so that a process, method, article or 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 device.
[0039] Furthermore, the term "and / or" in this application is merely a term used to describe the association relationship between associated objects, indicating that three relationships may exist. For example, A and / or B may represent three situations: A exists alone, A and B exist at the same time, and B exists alone.
[0040] In the description of the embodiments of the present application, unless otherwise clearly specified or limited, the technical term "connection" may refer to a direct connection or an indirect connection through an intermediate medium.
[0041] In order to improve the efficiency of random instruction verification of processors, this scheme proposes an efficient random instruction verification method for processors, which uses a random instruction verification case that includes a random instruction fragment, initial memory data required for the operation of the random instruction fragment, and result memory data after the random instruction fragment is simulated and run for verification. In the random instruction verification, it is only necessary to input the initial memory data and the random instruction fragment into a test machine (including a processor to be tested, which is the processor to be tested in the test machine). After running (or executing) the instruction fragment on the test machine, the running memory data and the result memory data of the processor to be tested are compared to confirm whether the execution result of the random instruction meets expectations, so as to realize the random instruction verification of the processor to be tested.
[0042] This method only needs to compare the data in the memory, which not only reduces the amount of data to be compared, but also effectively improves the random instruction verification efficiency of the processor. Because all the data of the processor itself comes from the memory, after the processor reads the memory data, it starts to execute the code. After the execution is completed, all the data is written back to the memory, so only the memory data needs to be compared to indirectly determine whether the instruction execution is correct. The memory data here only involves the code segment data and data segment data used by random instructions. At the same time, this method checks according to the instruction fragment, and does not need to check every instruction, which can also improve the verification efficiency.
[0043] Combine the following Figure 1 The random instruction verification method of the processor provided in the embodiment of the present application is described. The random instruction verification method provided in the embodiment of the present application can be executed by an electronic device, and the electronic device can be a PC (Personal Computer), a tablet computer, a server, etc., without any limitation here.
[0044] S1: Obtain a random instruction verification use case, wherein the random instruction verification use case includes: a random instruction fragment, initial memory data required for the execution of the random instruction fragment, and result memory data after the random instruction fragment is simulated and executed.
[0045] When random instruction verification of the processor is required, a random instruction verification case is obtained. A possible implementation method may be to randomly select a random instruction verification case from a random instruction verification case set. The random instruction verification case set includes multiple random instruction verification cases.
[0046] In one implementation, the random instruction verification case may only include the random instruction fragment, the initial memory data required for the random instruction fragment to run, and the result memory data after the random instruction fragment is simulated. Since the random instruction verification case includes the result memory data after the random instruction fragment is simulated, and the result memory data can only be generated if the random instruction fragment is correctly executed, it can be ensured that the instructions executed by the subsequent processor are all valid random verification instruction fragments.
[0047] The random instruction fragment can be a combination of a series of instructions used to perform a specific task or simulate a specific behavior. The initial memory data refers to the memory data required for the random instruction fragment to run. In order to run the generated instruction fragment, some initial memory data is required. This data can be randomly generated or generated according to a specific pattern or rule to ensure that the instruction fragment can be executed in a meaningful environment.
[0048] When obtaining the random instruction verification case, it can be obtained directly from the database. By storing the random instruction verification case required for random instruction verification in the database in advance for subsequent use, efficiency can be improved. In this implementation, the execution subject that generates the random instruction verification case can be different from the execution subject of the above-mentioned execution S1. In a possible implementation, the random instruction verification case can also be obtained in real time.
[0049] In a possible implementation, before S1, the method further includes: generating random instruction fragments and initial memory data required for the operation of random instruction fragments according to instruction rules (configurable) and constraints (configurable); inputting the random instruction fragments and initial memory data into a reference machine or simulator for operation (or execution) to obtain result memory data; obtaining a random instruction verification case according to the random instruction fragments, initial memory data, and result memory data. The random instruction fragments can be used as Instruction, the initial memory data can be used as Init Mem, the result memory data can be used as Result_Mem, and the random instruction fragments (Instruction), initial memory data (Init_Mem), and the result memory data after operation (Result_Mem) can form a random instruction verification case. Instruction and Init Mem can be input into a reference machine or simulator for operation. After the execution of the random instruction fragments is completed, all Caches in the reference machine or simulator are flushed (written back), and then the memory data of the reference machine or simulator is read as Result_Mem.
[0050] The generated random instruction fragments need to meet instruction rules and constraints. Instruction rules can refer to rules that define how instructions are generated and executed. These rules may be parameterized, allowing users to configure them according to different needs. For example, the rules stipulate that there cannot be instructions that generate random numbers, such as some instructions must appear in pairs. Constraints may include restrictions on instruction generation, such as instruction length, operand range, memory access restrictions, etc. These conditions can also be configured to adapt to different scenarios. For example, constraints can include test focus. For example, if the random instruction fragment wants to focus on testing floating-point instructions, the proportion of floating-point instructions can be adjusted to more than 90%.
[0051] S2: Sending the random instruction fragment and initial memory data in the random instruction verification case to the processor to be tested, so that the processor to be tested runs the random instruction fragment according to the initial memory data to obtain running memory data.
[0052] After obtaining the random instruction verification case, the random instruction fragment and initial memory data in the random instruction verification case can be sent to the processor to be tested, so that the processor to be tested runs the random instruction fragment according to the initial memory data to obtain the running memory data. In one implementation, the processor to be tested can be installed on a test machine. When obtaining the random instruction verification case, a verification case can be randomly selected from a random instruction verification case set (including multiple random instruction verification cases), and the random instruction fragment (Instruction) and initial memory data (Init_Mem) in the verification case are sent to the test machine (including the processor) through the network. After receiving all the data, the test machine starts to execute, and after the execution is completed, it notifies through an interrupt, and the result memory data after the test machine executes can be read.
[0053] In a possible implementation, there are multiple processors to be tested, and the process of S2 may include: sending random instruction fragments and initial memory data in different random instruction verification cases to multiple processors to be tested, so that multiple processors to be tested can run different random instruction verification cases at the same time. Instruction fragments and initial memory data in different random instruction verification cases can be sent to multiple processors to be tested at the same time, and multiple processors to be tested can run different random instruction verification cases at the same time to improve the efficiency of verification.
[0054] The result memory data and the running memory data are used for random instruction verification of the processor to be tested. For example, the result memory data and the running memory data can be compared for consistency to implement random instruction verification of the processor to be tested. In a possible implementation, the result memory data and the running memory data can also be compared for consistency by a third party, that is, the execution subject of the consistency comparison between the result memory data and the running memory data can be different from the execution subject of the above-mentioned execution S1 to S2.
[0055] In the embodiment of the present application, memory data is used as the basis for determining whether the random generated instruction is correctly executed. Since all the data for the Core operation and calculation in the processor are derived from the memory data, by comparing the result memory data and the operation memory data, it is possible to determine whether the random instruction is correctly executed on the processor.
[0056] In a possible implementation, after S2, the method further includes: obtaining running memory data; performing consistency comparison between the running memory data and the result memory data to obtain a comparison result; and determining the verification result of the random instruction of the processor to be tested according to the comparison result. It can be that if the comparison result represents the content consistent, it is determined that the verification result of the random instruction of the processor to be tested passes; if the comparison result represents the content inconsistent, it is determined that the verification result of the random instruction of the processor to be tested fails.
[0057] In one implementation, both the running memory data and the result memory data contain data from multiple memory addresses; when the running memory data and the result memory data are compared for consistency, the data from the same memory address in the running memory data and the result memory data can be compared, and the comparison result is obtained by comparing whether the data at the same memory address is the same. In this implementation, in addition to the data itself, the running memory data and the result memory data can also contain the memory address from which the data comes, so as to facilitate data comparison according to the same memory address.
[0058] In another implementation, when the running memory data and the result memory data are compared for consistency, the consistency can be achieved by comparing whether the character strings of the memory data files are the same. For example, the running memory data and the result memory data can be operated using the same hash algorithm, and the character strings obtained after the operation are compared to see whether they are the same, thereby obtaining a comparison result.
[0059] It can be understood that when verifying the random instructions of the processor, multiple different random instruction verification use cases can be sent to the processor to be tested for testing. Accordingly, multiple comparison results of the multiple random instruction verification use cases will be obtained. At this time, the process of determining the verification result of the random instruction of the processor to be tested based on the comparison results may include: if there is at least one comparison result among the multiple comparison results that is inconsistent in representation, it is determined that the verification result of the random instruction of the processor to be tested has failed.
[0060] The processor to be tested in the embodiments of the present application can be various processors that need to be tested, including but not limited to a central processing unit (CPU), an AI processor, a network processor (NP), a graphics processor (GPU), an accelerated processing unit (Accelerated Processing Unit), a multimedia application processor (MAP), a microprocessor, etc.
[0061] The embodiment of the present application also provides a random instruction verification method for a processor of a processor to be tested, which receives random instruction fragments and initial memory data in a random instruction verification case sent by a control machine, and runs the random instruction fragments according to the initial memory data to obtain running memory data, so that random instruction verification of the processor to be tested can be implemented according to the result memory data and the running memory data. Figure 1a The principle is explained.
[0062] S10: Receive the random instruction fragment and initial memory data in the random instruction verification use case sent by the control machine, and write the received data into the corresponding memory.
[0063] When the processor to be tested needs to be tested, the control machine can send the random instruction fragments and initial memory data in the random instruction verification case to the processor to be tested. After receiving the data, the processor to be tested writes the received data into the memory of the corresponding memory address.
[0064] Among them, the random instruction verification use case includes: random instruction fragments, initial memory data required for the random instruction fragment to run, and result memory data after the random instruction fragment is simulated and run.
[0065] S20: After receiving the information indicating that the data transmission is completed from the control machine, jump to a specific address and execute the random instruction fragment according to the initial memory data.
[0066] After sending the data (including the random instruction fragment and initial memory data in the random instruction verification case), the control machine will send a message indicating that the data sending is completed to the processor under test. After receiving the message, the processor under test jumps to a specific address and starts running the random instruction fragment according to the initial memory data. The specific address can be a preset starting execution address in the memory, that is, a certain address in the memory, which can be a fixed starting execution address of the random instruction verification case.
[0067] S30: writing the cache data generated by running the random instruction fragment back to the memory to obtain the running memory data.
[0068] After the processor to be tested runs the random instruction fragment, it will write all cache data generated by running the random instruction fragment back to the memory to obtain the running memory data.
[0069] In one implementation mode, after writing all cached data back to the memory, the processor to be tested will send a notification to the control machine so that the control machine can read the running memory data, compare the running memory data with the result memory data for consistency, obtain the comparison result, and determine the verification result of the random instruction of the processor to be tested based on the comparison result.
[0070] The method provided in this embodiment has the same implementation principle and technical effects as those in the aforementioned method embodiments. For the sake of brief description, for parts not mentioned in this embodiment, reference may be made to the corresponding contents in the aforementioned method embodiments.
[0071] The embodiment of the present application also provides a random instruction verification system for a processor, including a test machine including a processor and a control machine, wherein the control machine is connected to the test machine via a network, as shown in the schematic diagram. Figure 2 As shown. The number of test machines may be N, where N is an integer greater than or equal to 1. By connecting multiple test machines at the same time, random instruction fragments in random instruction verification cases can be sent to multiple test machines at the same time, and whether multiple test machines execute random instructions correctly can be tested at the same time.
[0072] The control machine is configured to obtain a random instruction verification case, and send the random instruction fragment and initial memory data in the random instruction verification case to the test machine, wherein the random instruction verification case includes: a random instruction fragment, initial memory data required for the random instruction fragment to run, and result memory data after the random instruction fragment is simulated and run.
[0073] The test machine is configured to run random instruction fragments according to initial memory data to obtain running memory data; wherein the result memory data and the running memory data are used for random instruction verification of the processor in the test machine.
[0074] In one implementation mode, the control machine is also configured to obtain running memory data from the test machine; compare the running memory data and the result memory data for consistency to obtain the comparison result; determine the verification result of the random instruction of the processor to be tested according to the comparison result. In this implementation mode, the control machine is responsible for sending the random instruction fragment data and the initial memory data to the test machine, notifying the test machine to start executing the code of the random instruction fragment after the sending is completed, reading the real running memory data in the test machine after the test machine is executed, and comparing it with the Result_Mem data in the random instruction verification case. After the test machine is powered on, it enters a specific program to wait for receiving data. If there is data sent, the data is written into the corresponding memory. After all the data is received, it jumps to a specific address (the address is generally the fixed starting execution address of the random instruction verification case, which is a certain address in the memory) to start executing the code of the random instruction fragment. After the execution is completed, the cache data is written back first, and the cache data is written back to the memory, and the control machine is notified to read the memory data of this machine, and then enters the state of waiting for receiving data.
[0075] In one embodiment, the running memory data and the result memory data both contain data from multiple memory addresses; when the running memory data and the result memory data are compared for consistency, the control machine is configured to compare the data from the same memory address in the running memory data and the result memory data. In another embodiment, the running memory data and the result memory data are compared for consistency, including: running the running memory data and the result memory data using the same hash algorithm to obtain their respective corresponding strings; comparing the string corresponding to the running memory data with the string corresponding to the result memory data.
[0076] In one implementation mode, if the control machine uses multiple random instruction verification use cases to test the processor to be tested, accordingly, the comparison result includes the comparison results of multiple random instruction verification use cases; then when determining the verification result of the random instruction of the processor to be tested based on the comparison result, the control machine is configured as follows: if there is at least one comparison result among the multiple comparison results that is inconsistent in representation, it is determined that the verification result of the random instruction of the processor to be tested has failed.
[0077] In one possible implementation, the control machine is also configured to generate random instruction fragments and initial memory data required for the operation of the random instruction fragments based on instruction rules and constraints; input the random instruction fragments and the initial memory data into a reference machine or a simulator for operation to obtain result memory data; and obtain a random instruction verification use case based on the random instruction fragments, the initial memory data and the result memory data.
[0078] In a possible implementation manner, the interaction diagram of the control machine and the test machine is as follows: Figure 3 shown.
[0079] For a better understanding, taking the random instruction verification of an x86 architecture processor (this method is not limited to x86 architecture processors) as an example, the entire verification process can be as follows: Figure 4 As shown, the entire verification process is as follows:
[0080] 1. Generate a random instruction fragment and initial memory data according to instruction rules and constraints. The memory data is the code segment and data segment data used by the random instruction fragment.
[0081] 2. Input the random instruction fragments and initial memory data into the reference machine and simulator for execution. After execution, write the cache back to the memory to obtain the result memory data.
[0082] 3. The random instruction fragment (Instruction), initial memory data (Init_Mem) and result memory data after running (Result_Mem) are combined into a random instruction verification use case.
[0083] 4. Obtain all the information of the machine to be tested (such as CPU signal, machine name, system IP, etc.) on the control machine, and execute a piece of boot loader code on the test machine (load network driver to configure system IP, and wait for network data packets in a loop). The control machine sends the instruction fragment (Instruction) and initial memory data (Init_Mem) in the random instruction verification case to the test machine.
[0084] 5. The test machine will write the received data to the corresponding memory. After the data transfer is completed, it will jump to a specific starting address and start executing random instruction fragments.
[0085] 6. After executing the random instruction fragment, the test machine writes all cached data back to the memory and notifies the control machine to read the running memory data on the test machine.
[0086] 7. The control machine reads the running memory data on the test machine and compares it with the Result_Mem data in the random instruction verification case. If the data at the same memory address are the same, it is considered that the random instruction verification case has passed the verification on the test machine, otherwise the verification has failed.
[0087] The above is an embodiment of random instruction correctness verification of x86 architecture processors, in which memory data is used as the basis for judging whether the randomly generated instructions are executed correctly. Because the Core itself in the x86 architecture processor is only for calculation, all data comes from memory data, so by comparing the memory data in the simulator with the memory data in the test machine, it is possible to determine whether the x86 instruction is executed correctly. If the memory data at the same address is equal, the random instruction correctness verification is passed, otherwise it is not passed.
[0088] The above-mentioned test machine and control machine can be a PC, a tablet computer, a server, etc., without any limitation here.
[0089] The solution provided by the random instruction verification system embodiment of the processor has the same implementation principle and technical effects as those of the aforementioned method embodiment. For the sake of brief description, for matters not mentioned in the system embodiment, reference can be made to the corresponding contents in the aforementioned method embodiment.
[0090] The present application also provides a random instruction verification device for a processor, which can be built into the above-mentioned control machine. Figure 5 As shown, the random instruction verification device 100 of the processor includes: an acquisition module 110 and a sending module 120.
[0091] The acquisition module 110 is used to acquire a random instruction verification case, wherein the random instruction verification case includes: a random instruction fragment, initial memory data required for the execution of the random instruction fragment, and result memory data after the random instruction fragment is simulated and executed.
[0092] The sending module 120 is used to send the random instruction fragment and initial memory data in the random instruction verification use case to the processor to be tested, so that the processor to be tested runs the random instruction fragment according to the initial memory data to obtain running memory data; wherein the result memory data and the running memory data are used for random instruction verification of the processor to be tested.
[0093] There are multiple processors to be tested, and the sending module 120 is used to send random instruction fragments and initial memory data in different random instruction verification use cases to the multiple processors to be tested, so that the multiple processors to be tested can run different random instruction verification use cases simultaneously.
[0094] In one embodiment, the device also includes a generation module, which is used to generate the random instruction fragment and the initial memory data required for the operation of the random instruction fragment according to instruction rules and constraints; input the random instruction fragment and the initial memory data into a reference machine or a simulator for operation to obtain the result memory data; and obtain the random instruction verification use case based on the random instruction fragment, the initial memory data and the result memory data.
[0095] In one embodiment, the device also includes a comparison module, which is used to obtain the running memory data; perform a consistency comparison between the running memory data and the result memory data to obtain a comparison result; and determine a verification result of the random instruction of the processor to be tested based on the comparison result.
[0096] The running memory data and the result memory data both contain data from multiple memory addresses; the comparison module is used to compare the data from the same memory address in the running memory data and the result memory data. In another embodiment, the comparison module is used to run the running memory data and the result memory data using the same hash algorithm to obtain the corresponding character strings; and compare the character string corresponding to the running memory data with the character string corresponding to the result memory data.
[0097] If the processor to be tested is tested using multiple random instruction verification use cases, the comparison result accordingly includes the comparison results of multiple random instruction verification use cases, and the comparison module is used to determine that the verification result of the random instruction of the processor to be tested fails if there is at least one comparison result representation inconsistency among the multiple comparison results.
[0098] The embodiment of the present application also provides a random instruction verification device for a processor, which can be built into the above-mentioned processor to be tested. The device includes: a receiving module, an execution module and a writing module.
[0099] Among them, the receiving module is used to receive the random instruction fragment and initial memory data in the random instruction verification use case sent from the control machine, and write the received data into the corresponding memory; wherein, the random instruction verification use case includes: the random instruction fragment, the initial memory data required for the operation of the random instruction fragment, and the result memory data after the simulation operation of the random instruction fragment.
[0100] The execution module is used to jump to a specific address after receiving the information indicating that the data transmission is completed sent by the control machine, and run the random instruction fragment according to the initial memory data, wherein the specific address is a starting execution address preset in the memory.
[0101] A writing module is used to write the cache data generated by running the random instruction fragment back to the memory to obtain running memory data, wherein the result memory data and the running memory data are used for random instruction verification of the processor to be tested.
[0102] The implementation principle and technical effects of the solution provided by the above-mentioned device embodiment are the same as those of the above-mentioned method embodiment. For the sake of brief description, for matters not mentioned in the system embodiment, reference can be made to the corresponding contents in the above-mentioned method embodiment.
[0103] like Figure 6 As shown, Figure 6 The electronic device 200 provided in the embodiment of the present application is shown in the structural block diagram. The electronic device 200 comprises: a transceiver 210, a memory 220, a communication bus 230 and a processor 240.
[0104] The transceiver 210, the memory 220, and the processor 240 are electrically connected to each other directly or indirectly to realize data transmission or interaction. For example, these elements can be electrically connected to each other through one or more communication buses 230 or signal lines. Among them, the transceiver 210 is used to send and receive data. The memory 220 is used to store computer programs, wherein the computer program includes at least one software function module that can be stored in the memory 220 in the form of software or firmware (Firmware) or solidified in the operating system (Operating System, OS) of the electronic device 200. The processor 240 is used to execute the executable module stored in the memory 220, such as the software function module or computer program included in the random instruction verification device 100 of the above-mentioned processor. For example, the processor 240 is used to execute the random instruction verification method of the above-mentioned processor.
[0105] Among them, the memory 220 can be, but is not limited to, random access memory (Random Access Memory, RAM), read only memory (Read Only Memory, ROM), programmable read-only memory (Programmable Read-Only Memory, PROM), erasable programmable read-only memory (Erasable Programmable Read-Only Memory, EPROM), electrically erasable read-only memory (Electric Erasable Programmable Read-Only Memory, EEPROM), etc.
[0106] The processor 240 may be an integrated circuit chip with signal processing capabilities. The above-mentioned processor may be a general-purpose processor, including a central processing unit (CPU), a network processor (NP), a graphics processor (GPU), an accelerated processing unit (Accelerated Processing Unit), a multimedia application processor (MAP), a microprocessor, etc.; it may also be a digital signal processor (DSP), an application specific integrated circuit (ASIC), a field programmable gate array (FPGA) or other programmable logic devices, discrete gates or transistor logic devices, discrete hardware components. The disclosed methods, steps and logic block diagrams in the embodiments of the present application may be implemented or executed. Alternatively, the processor 240 may also be any conventional processor, etc.
[0107] The electronic device 200 mentioned above includes but is not limited to a PC, a tablet computer, a server, etc.
[0108] An embodiment of the present application also provides a non-volatile computer-readable storage medium (hereinafter referred to as storage medium), on which a computer program is stored. When the computer program is run by a computer such as the above-mentioned electronic device 200, the random instruction verification method of the processor shown above is executed.
[0109] It should be noted that 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.
[0110] In several embodiments provided in the present application, it should be understood that the disclosed devices and methods can also be implemented in other ways. The device embodiments described above are merely schematic. For example, the flowcharts and block diagrams in the accompanying drawings show the possible architecture, functions and operations of the devices, methods and computer program products according to multiple embodiments of the present application. In this regard, each box in the flowchart or block diagram can represent a module, a program segment or a part of a code, and the module, a program segment or a part of a code contains one or more executable instructions for implementing the specified logical function. It should also be noted that in some alternative implementations, the functions marked in the box can also occur in a different order from the order marked in the accompanying drawings. For example, two consecutive boxes can actually be executed substantially in parallel, and they can sometimes be executed in the opposite order, depending on the functions involved. It should also be noted that each box in the block diagram and / or flowchart, and the combination of boxes in the block diagram and / or flowchart can be implemented with a dedicated hardware-based system that performs a specified function or action, or can be implemented with a combination of dedicated hardware and computer instructions.
[0111] In addition, the functional modules in the various embodiments of the present application may be integrated together to form an independent part, or each module may exist separately, or two or more modules may be integrated to form an independent part.
[0112] If the functions are implemented in the form of software function modules and sold or used as independent products, they can be stored in a computer-readable storage medium. Based on this understanding, the technical solution of the present application can be essentially or partly embodied in the form of a software product that contributes to the prior art. The computer software product is stored in a computer-readable storage medium, including several instructions for enabling a computer device (which can be a personal computer, a laptop, a server, or an electronic device, etc.) to perform all or part of the steps of the methods described in each embodiment of the present application. The aforementioned computer-readable storage medium includes: various media that can store program codes, such as a USB flash drive, a mobile hard disk, a read-only memory (ROM), a random access memory (RAM), a magnetic disk or an optical disk.
[0113] The above is only a specific implementation of the present application, but the protection scope of the present application is not limited thereto. Any technician familiar with the technical field can easily think of changes or substitutions within the technical scope disclosed in the present application, which should be included in the protection scope of the present application. Therefore, the protection scope of the present application should be based on the protection scope of the claims.
Claims
1. A random instruction verification method for a processor, characterized in that: include: Obtain a random instruction verification case, wherein the random instruction verification case includes: a random instruction fragment, initial memory data required for the random instruction fragment to run, and result memory data after the random instruction fragment is simulated and run; Sending the random instruction fragment and the initial memory data in the random instruction verification case to the processor to be tested, so that the processor to be tested runs the random instruction fragment according to the initial memory data to obtain the running memory data; The result memory data and the running memory data are used for random instruction verification of the processor to be tested.
2. The method according to claim 1, characterized in that Before obtaining the random instruction verification case, the method further includes: Generating the random instruction fragment and initial memory data required for the execution of the random instruction fragment according to instruction rules and constraints; Input the random instruction fragment and the initial memory data into a reference machine or a simulator for execution to obtain the result memory data; The random instruction verification use case is obtained according to the random instruction fragment, the initial memory data and the result memory data.
3. The method according to claim 1, characterized in that The method further comprises: Acquire the running memory data; Perform consistency comparison between the running memory data and the result memory data to obtain a comparison result; A verification result of the random instruction of the processor to be tested is determined according to the comparison result.
4. The method according to claim 3, characterized in that The running memory data and the result memory data both contain data from multiple memory addresses; The consistency comparison between the running memory data and the result memory data includes: Compare the data from the same memory address in the running memory data and the result memory data.
5. The method according to claim 3, characterized in that: The consistency comparison between the running memory data and the result memory data includes: The running memory data and the result memory data are run using the same hash algorithm to obtain respective corresponding character strings; The character string corresponding to the running memory data is compared with the character string corresponding to the result memory data.
6. The method according to claim 3, characterized in that If the processor to be tested is tested using multiple random instruction verification cases, correspondingly, the comparison result includes the comparison results of the multiple random instruction verification cases; determining the verification result of the random instruction of the processor to be tested according to the comparison result includes: If at least one comparison result among the multiple comparison results indicates inconsistency, it is determined that the verification result of the random instruction of the processor to be tested fails.
7. The method according to claim 1, characterized in that There are multiple processors to be tested, and sending the random instruction fragments and initial memory data in the random instruction verification case to the processors to be tested includes: Sending random instruction fragments and initial memory data in different random instruction verification use cases to the plurality of processors to be tested, so that the plurality of processors to be tested run different random instruction verification use cases simultaneously.
8. A random instruction verification method for a processor, characterized in that: Applied to a processor to be tested, the method comprises: Receive a random instruction fragment and initial memory data in a random instruction verification case sent from a control machine; wherein the random instruction verification case includes: a random instruction fragment, initial memory data required for the execution of the random instruction fragment, and result memory data after the simulated execution of the random instruction fragment; The random instruction fragment is run according to the initial memory data to obtain the running memory data; wherein the result memory data and the running memory data are used for random instruction verification of the processor to be tested.
9. The method according to claim 8, characterized in that Receive random instruction fragments and initial memory data in the random instruction verification use case sent by the control machine, including: Writing the received random instruction fragments and initial memory data into the corresponding memory; Running the random instruction fragment according to the initial memory data to obtain the running memory data includes: After receiving the information sent by the control machine indicating that the random instruction fragment and the initial memory data have been sent, jump to a specific address and execute the random instruction fragment according to the initial memory data; wherein the specific address is a start execution address preset in the memory; The cache data generated by running the random instruction fragment is written back to the memory to obtain the running memory data.
10. A random instruction verification system for a processor, comprising: a test machine, including a processor; The control machine is configured to obtain a random instruction verification case, and send a random instruction fragment and initial memory data in the random instruction verification case to the test machine, wherein the random instruction verification case includes: a random instruction fragment, initial memory data required for the random instruction fragment to run, and result memory data after the random instruction fragment is simulated and run; The test machine is configured to run the random instruction fragment according to the initial memory data to obtain running memory data; The result memory data and the running memory data are used for random instruction verification of the processor in the test machine.
11. A random instruction verification device for a processor, characterized in that: include: An acquisition module is used to acquire a random instruction verification case, wherein the random instruction verification case includes: a random instruction fragment, initial memory data required for the random instruction fragment to run, and result memory data after the random instruction fragment is simulated and run; A sending module, used to send the random instruction fragment and the initial memory data in the random instruction verification case to the processor to be tested, so that the processor to be tested runs the random instruction fragment according to the initial memory data to obtain the running memory data; The result memory data and the running memory data are used for random instruction verification of the processor to be tested.
12. An electronic device, characterized in that: include: A memory and a processor, wherein the processor is connected to the memory; The memory is used to store programs; The processor is used to call the program stored in the memory to execute the method according to any one of claims 1 to 7, or to execute the method according to claim 8 or 9.
13. A computer-readable storage medium, characterized in that: A computer program is stored thereon, and when the computer program is executed by a processor, the method according to any one of claims 1 to 7 is executed, or the method according to claim 8 or 9 is executed.
