Efficient instruction test sequence generation method and device based on neural network

Through the instruction test sequence generation method based on neural networks, the relationship between the instruction generator probability parameters and the processor module coverage is established, which solves the problem of slow coverage improvement in processor verification and achieves faster coverage improvement and verification efficiency. improve.

CN111858221BActive Publication Date: 2024-09-27INST OF MICROELECTRONICS CHINESE ACAD OF SCI LTD
View PDF 4 Cites 0 Cited by

Patent Information

Application Number
CN202010740929.3
Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
Filing Date
2020-07-28
Publication Date
2024-09-27
Estimated Expiration
2040-07-28

AI Technical Summary

Technical Problem

During the processor verification process, the coverage rate increases slowly, resulting in long verification time. It is difficult to quickly improve the completeness of simulation verification with existing technology.

Method used

An instruction test sequence generation method based on neural networks is used to randomly generate probability vectors and train the neural network to establish the relationship between the probability parameters of the instruction generator and the processor module coverage, and generate targeted instructions to improve coverage.

Benefits of technology

Targeted probability parameters can be quickly identified through neural networks, saving simulation time, reaching higher coverage levels faster, and improving verification efficiency.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN111858221B
    Figure CN111858221B
Patent Text Reader

Abstract

A method for generating an instruction test sequence based on a neural network includes the following steps: randomly generating a probability vector; generating M kinds of instructions through an instruction generator according to the probability vector; sending the instruction into a processor hardware code to obtain processor module coverage; using the multiple probability vectors as input and the processor module coverage as output to train a neural network; after the neural network is trained, a fixed parameter neural network is obtained, the randomly generated probability vector is input into the fixed parameter neural network, and it is determined whether the output of the fixed parameter neural network exceeds a threshold; when the corresponding outputs of the processor modules concerned all exceed the threshold, the corresponding probability vector is selected to generate a test sequence. The present invention also provides an instruction test sequence generation device based on a neural network.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present invention relates to the field of processor testing and verification technology, and in particular to a method and device for generating an efficient instruction test sequence based on a neural network. Background Art

[0002] At present, processor verification is becoming more and more complicated and has become a bottleneck in the design cycle. About 70% of the time is spent on verification. Coverage is an important indicator of the completeness of simulation verification, ranging from 0 to 100%. It includes line coverage (line), which indicates the proportion of hardware code lines executed. Condition coverage (conditions), which indicates the proportion of true and false conditional statements covered, branch coverage, which indicates the proportion of if else and other branch combinations that are tested, and state machine coverage, which indicates how many states of the state machine are reached. The total coverage can be obtained by weighting, and the higher the coverage, the more complete the verification. Improving the coverage level has become a key factor in verification work, but the higher the coverage, the slower the convergence, and it takes a long time to achieve a higher coverage. How to quickly improve the verification coverage has become a key issue. Summary of the invention

[0003] In view of this, the main purpose of the present invention is to provide a method for generating an instruction test sequence based on a neural network, in order to partially solve at least one of the above technical problems.

[0004] In order to achieve the above object, as one aspect of the present invention, a method for generating an instruction test sequence based on a neural network is provided, comprising the following steps:

[0005] Randomly generate probability vectors;

[0006] Generate M kinds of instructions through an instruction generator according to the probability vector;

[0007] Sending the instructions into processor hardware code to obtain processor module coverage;

[0008] Training a neural network using the plurality of probability vectors as input and the processor module coverage as output;

[0009] After the neural network is trained, a fixed parameter neural network is obtained, and the randomly generated probability vector is input into the fixed parameter neural network to determine whether the output of the fixed parameter neural network exceeds a threshold;

[0010] When the corresponding outputs of the processor modules concerned all exceed the threshold, the corresponding probability vector is selected to generate a test sequence.

[0011] The specific process of the instruction generator generating an instruction includes:

[0012] Each bit probability of the high ceil(log2M) bit probability vector generates 1 of the corresponding binary bit, and the generated ceil(log2M) bit binary numbers represent different instructions, where M represents the number of instruction types, and ceil(A) represents the smallest integer greater than or equal to A;

[0013] Read the corresponding actual MIPS opcode and function code from the C++ container storing integer elements;

[0014] The lower 26-bit probability value of the probability vector generates a binary 1 for the corresponding instruction bit.

[0015] The process of training the neural network includes:

[0016]

[0017] in, is the expected coverage value, is the output value of the neural network, N modules;

[0018] Use the gradient descent method to train the neural network and update the network parameters.

[0019] The probability vector is defined in such a way that each bit of the probability vector represents the probability of generating 1, which is 0, 0.1, 0.2, ..., 1.0.

[0020] As another aspect of the present invention, a device for generating an instruction test sequence based on a neural network is provided, the device comprising a neural network training module and an instruction generation module, wherein:

[0021] The neural network training module includes a random probability vector generation unit, an instruction generator and a neural network to be trained, and is used to train the neural network;

[0022] The instruction generation module includes a random probability vector generation unit, a fixed parameter neural network, a judge and an instruction generator, and is used to generate a test sequence.

[0023] As another aspect of the present invention, there is provided an electronic device, comprising:

[0024] one or more processors;

[0025] A memory for storing one or more instructions,

[0026] When the one or more instructions are executed by the one or more processors, the one or more processors implement the method as described above.

[0027] Based on the above technical solution, it can be seen that the neural network-based instruction test sequence generation method of the present invention has at least one or part of the following beneficial effects compared with the prior art:

[0028] The present invention uses a neural network to establish the relationship between the probability parameters of the instruction generator and the coverage of each module. The neural network has a high accuracy rate for classification, regression and other problems. For different modules, or multiple modules, the neural network can identify targeted probability parameters. The identification process does not need to generate instructions and input RTL for simulation, saving a lot of time. Targeted probability parameters generate required instructions, which can achieve a higher coverage level faster. BRIEF DESCRIPTION OF THE DRAWINGS

[0029] Figure 1 It is a schematic diagram of the neuron structure in the prior art;

[0030] Figure 2 is a schematic diagram of a neural network in the prior art;

[0031] Figure 3 is a flow chart of an efficient test instruction generation method based on a neural network in an embodiment of the present invention;

[0032] Figure 4 are three instruction types R (register type), I (immediate type), and J (jump type) instructions of MIPS in the embodiment of the present invention, and a 33-bit probability vector for generating 95 instructions;

[0033] Figure 5 is the ADD instruction of MIPS in the embodiment of the present invention;

[0034] Figure 6 is a flowchart of a neural network training process in an embodiment of the present invention;

[0035] Figure 7 Schematic diagram of the system structure of the neural network training module in an embodiment of the present invention (taking 95 instructions as an example);

[0036] Figure 8 is a flow chart of an efficient instruction generation process in an embodiment of the present invention;

[0037] Fig. 9 It is a schematic diagram of the system structure of the efficient instruction generation module in an embodiment of the present invention (taking 95 instructions as an example). DETAILED DESCRIPTION

[0038] The processor is divided into instruction fetch and pre-decoding module (fetch&preDec), instruction dispatch module (dispatch), jump exception control module (BrExcp), arithmetic operation module (ALU), multiplication module (MUL), storage control module (LDST), address translation module (TLB), instruction cache module (ICACHE) and other modules. These modules have coverage data respectively, which can be viewed through tools such as DVE.

[0039] Neural networks have good performance in regression and classification. Figure 1 As shown in , neurons have linear parameters w1, w2, ..., wn, b and nonlinear functions f, so neural networks can solve linear inseparable problems. Figure 2 As shown in the figure, the neural network is divided into an input layer, an output layer, and several hidden layers, and each layer can learn different features.

[0040] The probability parameters of the instruction generator affect the proportion of specific instructions generated, and the proportion of specific instructions affects the coverage of each module of the processor. For example, if the proportion of arithmetic instructions is high, then the coverage of the arithmetic operation module is higher. This patent uses a neural network to learn the mapping relationship between the probability parameters of the instruction generator and the coverage of each module of the processor. In this way, it is used to guide what instruction generator probability parameters should be adopted to quickly improve the coverage of certain modules of interest, so as to speed up the improvement of the verification coverage of the modules of interest. The neural network is a regression network, that is, the output is a specific value, which fits the specific coverage value.

[0041] The present invention aims at improving the verification coverage of the processor and proposes an instruction generation method based on a neural network. Simulation verification is to apply incentives such as instructions to the processor and compare them with expected results. Verification is the key to ensuring the correct function of the processor. The coverage of verification is an important indicator to measure the completeness of verification. The present invention establishes the relationship between the probability parameters and coverage of the instruction generator through a neural network. It can generate targeted instructions for several different modules of the processor for simulation verification, and achieve a higher coverage faster.

[0042] Specifically, the present invention discloses a method for generating a test instruction sequence based on a neural network, such as Figure 3 It includes the following steps:

[0043] Randomly generate probability vectors;

[0044] Generate M kinds of instructions through an instruction generator according to the probability vector;

[0045] Sending the instructions into processor hardware code to obtain processor module coverage;

[0046] Training a neural network using the plurality of probability vectors as input and the processor module coverage as output;

[0047] After the neural network is trained, a fixed parameter neural network is obtained, and the randomly generated probability vector is input into the fixed parameter neural network to determine whether the output of the fixed parameter neural network exceeds a threshold;

[0048] When the corresponding outputs of the processor modules concerned all exceed the threshold, the corresponding probability vector is selected to generate a test sequence.

[0049] In order to make the objectives, technical solutions and advantages of the present invention more clearly understood, the present invention is further described in detail below in conjunction with specific embodiments and with reference to the accompanying drawings.

[0050] like Figure 4 As shown in the figure, MIPS instructions are composed of 32 bits, which are divided into R (register type), I (immediate type), and J (jump type) instructions. The upper 6 bits are the opcode, and the opcode and function code represent different types of instructions. The lower 26 bits represent the register number, address offset, immediate value, function code, etc. This time, there are 95 types of MIPS instructions in common, and it can also be any type of instructions with the number M.

[0051] like Figure 4 Generate a 33-bit probability vector. Each of the upper 7 bits can be 0.1, 0.2, ..., 0.9, 1.0, representing the probability that the corresponding 7-bit binary number is 1. This 7-bit binary number encodes 95 types of instructions. For other types of numbers M, it can be ceil (log2M) bits, where ceil represents the smallest integer greater than or equal to the expression. Each of the lower 26 bits can be 0, 0.1, 0.2, ..., 0.9, 1.0, representing the probability that each bit of the corresponding instruction is 1. A batch of instructions can be generated based on this 33-bit probability vector. rand() < (RAND_MAX * probability) can be used to obtain 0 or 1 for each bit. rand() is a random function, and RAND_MAX is the maximum value of the random function. Enter the instructions into the hardware code (RTL) for functional verification.

[0052] The specific instruction generator generation process is to use C++ vector (container for storing integer elements) to read the required 95 instruction codes (constants defined to distinguish different instructions), and then use the high 7 bits of the probability vector to generate a 7-bit binary code to represent a random number from 0 to 94, and then get the instruction code prnum corresponding to the vector. According to different prnum, the corresponding opcode, function code, register number, immediate number and other parts of the instruction are generated. Figure 5In the ADD instruction shown, the probability values ​​of 25-21, 20-16, and 15-11 generate the register numbers represented by the 5-bit binary numbers of rs, rt, and rd respectively, and the other fixed bits 10-0 generate the operation code according to the format, the function code, and other register numbers. The fixed bits constitute a complete instruction.

[0053] like Figure 6 As shown, a ceil(log2M)+26-bit probability vector is randomly generated. Through the probability vector, the instruction generator generates a batch of instructions, and the instructions are sent to the RTL (processor hardware code) to obtain the coverage value. When the number of randomly generated probability vectors meets the requirement, multiple probability vectors are used as input and N module coverage values ​​are used as output to train the network. Loss function , is the expected coverage value, It is the output value of the neural network. The gradient descent method is used to train the neural network and update the network parameters.

[0054] like Figure 7 As shown in the figure, the probability generation module randomly generates a 33-bit probability vector float[32:0], which is used as a parameter of the instruction generator to generate instructions. The instructions are sent to the RTL (processor hardware code) for verification to obtain N module coverages. The randomly generated probability vector float[32:0] is used as input, and the N module coverage float[N:0] is used as output to train the neural network.

[0055] After the neural network is trained, Figure 8 As shown, a probability vector of ceil(log2M)+26 bits is randomly generated and input into the neural network. Then it is determined whether the output of the neural network exceeds a certain value, such as 60% (adjustable as needed). If it exceeds, it is 1, otherwise it is 0. If the outputs corresponding to one or several modules of interest are all 1, then the probability vector meets the requirements. This process does not require the generation of instructions to enter the RTL for simulation, which can save a lot of simulation time. The instruction generator uses the probability vector that meets the requirements as the instruction generator parameter, outputs a batch of instructions, and verifies them on the processor. The probability vector that meets the requirements can generate targeted instructions and achieve higher coverage faster.

[0056] like Fig. 9 As shown in the figure, the probability generation module randomly generates a 33-bit probability vector float[32:0] and inputs it into the neural network. The decision maker determines whether the output is greater than a value, such as 60%, and the output is 1, otherwise it is 0. If the corresponding outputs of the modules concerned are all 1, the probability vector float[32:0] is used as the instruction generator parameter to generate instructions and send them to RTL verification.

[0057] Previous simulation verifications were all based on random generation. After analysis, it was found that under ideal conditions, the coverage rate approaches 100% at a speed of the negative exponential of the natural constant e, and the coverage rate increases more and more slowly. Random generation lacks artificial modulation of the instruction generator parameters, resulting in a long time period to achieve the coverage requirement. The present invention uses a neural network to establish the relationship between the probability parameters of the instruction generator and the coverage of each module. The neural network has a high accuracy rate for classification, regression and other problems. For different modules, or multiple modules, the neural network can distinguish targeted probability parameters. The discrimination process does not need to generate instructions and input RTL for simulation, saving a lot of time. Targeted probability parameters generate the required instructions and can achieve higher coverage levels more quickly.

[0058] The present invention also discloses an efficient instruction generation device based on a neural network, including a neural network training module based on instruction coverage and an efficient instruction generation module, wherein the neural network training module includes a random probability vector generation module, an instruction generator, and a neural network to be trained. The probability vector generation module randomly generates a probability vector, a ceil(log2M)+26-bit vector, each bit represents the probability of generating 1, and can be 0, 0.1, 0.2...1.0. Ceil represents the smallest integer greater than or equal to the expression. M represents the number of instruction types. The instruction generator generation process is as follows: each bit probability of the high ceil(log2M) bit probability vector generates a corresponding binary bit 1. The generated ceil(log2M) bit binary number represents different instructions, and then the corresponding instruction number prnum is read from the C++ vector. The low 26-bit probability value of the probability vector generates a binary 1 corresponding to the instruction bit. In the training process of the neural network to be trained, the input is each bit of the randomly generated probability vector, and the coverage of each module of the processor is output.

[0059] The efficient instruction generation module includes a random probability vector generation module, a fixed parameter neural network, a judge, and an instruction generator. The functions and implementations of the random probability vector generation module and the instruction generator are respectively the same as those of the above-mentioned probability vector generation module and the instruction generator. The fixed parameter neural network is the result of the training of the above-mentioned neural network to be trained. The judge outputs 1 when the output of the neural network corresponding to the processor module is greater than a certain value such as 60%, otherwise it outputs 0. If the outputs of the modules concerned are all 1, the probability vector of the input neural network is provided to the instruction generator.

[0060] According to a further embodiment of the present invention, the probability vector is defined in such a way that each bit of the vector represents the probability of generating 1, which can be 0, 0.1, 0.2 ... 1.0. A method of using a probability vector to generate M kinds of instructions is used, and each bit probability of the high ceil (log2M) bit probability vector is used to generate a 1 of the corresponding binary bit. The generated ceil (log2M) bit binary number represents different types of instructions, and then the corresponding instruction number prnum is read out from the C++ vector. The low 26 bit probability value of the probability vector generates a binary 1 of the corresponding instruction bit. Together with the above prnum, a complete instruction can be formed.

[0061] According to a further embodiment of the present invention, the neural network includes an input layer, a hidden layer, and an output layer. The network output is the coverage of each module of the processor. The N module network has N outputs, which are 1 when the coverage is greater than a certain value, otherwise 0. The inputs are probability vectors of ceil(log2M)+26 bits. Ceil represents the smallest integer greater than or equal to the expression. This neural network is a multi-output regression network. The neural network is trained using the N module coverage and probability vectors. The loss function , is the expected coverage value, It is the output value of the neural network. Derivation and gradient descent operations are performed to train the neural network and update the network parameters. The trained neural network is input with ceil(log2M)+26-bit probability parameters, and the coverage of N modules is generated. If the decision maker determines that it is greater than a certain value, such as 60% (depending on the situation), the output is 1, otherwise the output is 0. If the output of the concerned module is 1, the probability vector is used as the instruction generator parameter to generate the required instructions and input the processor RTL code for verification.

[0062] An electronic device or server comprises: one or more processors; and a memory for storing one or more instructions, wherein when the one or more instructions are executed by the one or more processors, the one or more processors implement the method as described above.

[0063] The specific embodiments described above further illustrate the objectives, technical solutions and beneficial effects of the present invention in detail. It should be understood that the above description is only a specific embodiment of the present invention and is not intended to limit the present invention. Any modifications, equivalent substitutions, improvements, etc. made within the spirit and principles of the present invention should be included in the scope of protection of the present invention.

Claims

1. A method for generating instruction test sequences based on neural networks, It is characterized in that The following steps are involved: Randomly generate probability vectors; Generate M kinds of instructions through an instruction generator according to the probability vector; The specific process of the instruction generator generating M kinds of instructions includes: High ceil (log 2 The probability of each bit of the M-bit probability vector generating the corresponding binary bit is 1, and the generated ceil (log 2 M)-bit binary numbers represent different instructions, where M represents the number of instruction types, and ceil(A) represents the smallest integer greater than or equal to A; Read the corresponding actual MIPS opcode and function code from the C++ container storing integer elements; The lower 26-bit probability value of the probability vector generates a binary 1 for the corresponding instruction bit; Sending the instructions into processor hardware code to obtain processor module coverage; Taking the plurality of probability vectors as input and the processor module coverage as output, training a neural network; After the neural network is trained, a fixed parameter neural network is obtained, and the randomly generated probability vector is input into the fixed parameter neural network to determine whether the output of the fixed parameter neural network exceeds a threshold; When the fixed parameter neural network outputs corresponding to the processor modules concerned all exceed the threshold, the corresponding probability vector is selected to generate a test sequence.

2. The method for generating an instruction test sequence according to claim 1, It is characterized in that The process of training the neural network includes: in, is the expected coverage value, is the output value of the neural network, and N is the number of modules; Use the gradient descent method to train the neural network and update the network parameters.

3. The method for generating an instruction test sequence according to claim 1, It is characterized in that The probability vector is defined in such a way that each bit of the probability vector represents the probability of generating 1, which is 0, 0.1, 0.2, ..., 1.

0.

4. A device for generating instruction test sequences based on neural networks, It is characterized in that The device includes a neural network training module and an instruction generation module, wherein: The neural network training module includes a random probability vector generation unit and an instruction generator; Wherein, the neural network training module is used to: Using the random probability vector generation unit to randomly generate a probability vector; Generate M kinds of instructions through the instruction generator according to the probability vector; The process of the instruction generator generating M kinds of instructions is as follows: high ceil (log 2 The probability of each bit of the M-bit probability vector generating the corresponding binary bit is 1, and the generated ceil (log 2 M)-bit binary numbers represent different instructions, where M represents the number of instruction types, and ceil(A) represents the smallest integer greater than or equal to A; read the corresponding actual MIPS opcode and function code from the C++ container storing integer elements; the lower 26-bit probability value of the probability vector generates a binary 1 for the corresponding instruction bit; Sending the instructions into processor hardware code to obtain processor module coverage; Taking the plurality of probability vectors as input and the processor module coverage as output, training a neural network; The instruction generation module includes a random probability vector generation unit, a judge and an instruction generator; Wherein, the instruction generation module is used to: After the neural network is trained, a fixed parameter neural network is obtained, the probability vector randomly generated by the random probability vector generation unit is input into the fixed parameter neural network, and the decision device is used to determine whether the output of the fixed parameter neural network exceeds a threshold value; When the fixed parameter neural network outputs corresponding to the processor modules concerned all exceed the threshold, the corresponding probability vector is selected to generate a test sequence through the instruction generator.

5. The instruction test sequence generating device according to claim 4, It is characterized in that The process of training the neural network includes: , in, is the expected coverage value, is the output value of the neural network, and N is the number of modules; Use the gradient descent method to train the neural network and update the network parameters.

6. The instruction test sequence generating device according to claim 4, It is characterized in that The probability vector is defined in such a way that each bit of the probability vector represents the probability of generating 1, which is 0, 0.1, 0.2, ..., 1.

0.

7. An electronic device, include: one or more processors; A memory for storing one or more instructions, Wherein, when the one or more instructions are executed by the one or more processors, the one or more processors are enabled to implement the method according to any one of claims 1 to 3.

Citation Information

Patent Citations

  • Text sentiment classification algorithm based on convolutional neural network and attention mechanism

    CN108664632A

  • Network node label active learning method and system based on graph convolution network

    CN110363282A

  • Training device, speech detection device, training method, and computer program product

    US20170076200A1

  • Systems and methods for generation of sparse code for convolutional neural networks

    US20200160181A1