WO2023125821A1 - Chip test case generation method and apparatus, and storage medium - Google Patents

Chip test case generation method and apparatus, and storage medium Download PDF

Info

Publication number
WO2023125821A1
WO2023125821A1 PCT/CN2022/143439 CN2022143439W WO2023125821A1 WO 2023125821 A1 WO2023125821 A1 WO 2023125821A1 CN 2022143439 W CN2022143439 W CN 2022143439W WO 2023125821 A1 WO2023125821 A1 WO 2023125821A1
Authority
WO
WIPO (PCT)
Prior art keywords
test case
input parameters
value
value combination
target
Prior art date
Application number
PCT/CN2022/143439
Other languages
French (fr)
Chinese (zh)
Inventor
陈俊洁
毛航宇
郝建业
孙月凤
姜佳君
Original Assignee
华为技术有限公司
Priority date (The priority date is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the date listed.)
Filing date
Publication date
Application filed by 华为技术有限公司 filed Critical 华为技术有限公司
Publication of WO2023125821A1 publication Critical patent/WO2023125821A1/en

Links

Images

Classifications

    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F30/00Computer-aided design [CAD]
    • G06F30/30Circuit design
    • G06F30/32Circuit design at the digital level
    • G06F30/33Design verification, e.g. functional simulation or model checking
    • G06F30/3308Design verification, e.g. functional simulation or model checking using simulation
    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F18/00Pattern recognition
    • G06F18/20Analysing
    • G06F18/24Classification techniques
    • G06F18/243Classification techniques relating to the number of classes
    • G06F18/2431Multiple classes
    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F2115/00Details relating to the type of the circuit
    • G06F2115/02System on chip [SoC] design

Definitions

  • the present application relates to the field of artificial intelligence, in particular to a chip test case generation method, device and storage medium.
  • Chips are widely used in various electronic devices and are considered to be the heart of electronic devices.
  • the generation process of the chip is complicated, and it needs to go through many links such as chip specification definition, chip design, physical layout, and tape-out production.
  • chip design is particularly critical as the upstream basic link of the chip generation process.
  • developers design the features, attributes, and functional architecture of the chip in the specification definition link, and then use the Hardware Description Language (Hardware Description Language, HDL) to write the Register-Transfer-Level (RTL) level (RTL) implemented by the chip design in the chip design link. ) code, and the subsequent links will be further developed based on this RTL code.
  • HDL Hardware Description Language
  • RTL Register-Transfer-Level
  • RTL Register-Transfer-Level
  • the constraint-driven random test method (Constraint Driven Random, CDR) is mainly used to test the chip design under test (Design Under Test, DUT).
  • This method uses a constraint solver to correct randomly generated test cases, and uses the corrected test cases for testing.
  • This method often requires a large-scale test case collection and a long period of testing to achieve high functional coverage. rate, the test efficiency is low, and the test cost is high.
  • the present application proposes a chip test case generation method, device and storage medium.
  • an embodiment of the present application provides a method for generating test cases for a chip, the method comprising: obtaining an input parameter set; the input parameter set includes M input parameters of the chip, and M is an integer not less than 1 ; Input the input parameter set into the first model to generate the first test case set; wherein, the first test case includes: the values of the M input parameters, and the first model utilizes the first test case training samples As obtained from the training, the values of the M input parameters in the training samples of the first test case satisfy preset constraints.
  • the value of the input parameters in the first test case training sample satisfies the preset constraints
  • the first model is a model obtained by using the first test case training sample training, so that the first model obtained after training can be After learning the preset constraint
  • the effective value space can be selected from all the value spaces of the input parameters, thereby effectively reducing the value space of the input parameters to be explored in the process of generating the first test case; at the same time , the first model can automatically generate test cases whose values of input parameters meet the preset constraints without correction, which ensures the diversity of values of input parameters in the first test case set, so that by generating a smaller-scale first test
  • a collection of use cases can achieve high functional coverage, effectively reducing the time required for testing, effectively improving testing efficiency, and saving testing costs.
  • the method further includes: determining a target function coverage group, the target function coverage group including the target function to be tested; according to the function coverage group Associating information with input parameters, determine N target input parameters associated with the target function coverage group in the input parameter set, N is a positive integer not greater than M; wherein, the function coverage group and the input The correlation information between parameters is obtained by using the second test case training sample and the first function coverage information corresponding to the second test case training sample; the M input parameters in the second test case training sample The value satisfies the preset constraints, the first function coverage information indicates the tested functions and/or untested functions in each function coverage group; determine at least one first value of the N target input parameters value combination; using each of the at least one first value combination to replace a second value combination of the N target input parameters in the first test case set to obtain a second test case set, Wherein, the second test case includes values of the M input parameters.
  • the first function coverage information indicates the tested functions and/or untested functions in each function coverage group
  • the association information between the function coverage group and the input parameters is that the values of the input parameters satisfy the predetermined
  • the association information between the functional coverage group and the input parameter can indicate the associated functional coverage group and the input parameter ; and furthermore, the target input parameter associated with the target function coverage group in the input parameter set can be determined according to the association information, and the target input parameter is an important parameter that affects whether the target function to be tested in the target function coverage group can be tested,
  • the target input parameter is an important parameter that affects whether the target function to be tested in the target function coverage group can be tested
  • test cases that can cover the functional coverage group can be generated, thereby effectively improving the functional coverage rate, especially for the functional coverage group that is usually difficult to cover in the later stage of the test.
  • Better coverage effect reducing the manual intervention of domain experts, reducing the test cost, further improving the test efficiency, and effectively shortening the chip development cycle.
  • the determining at least one first value combination of the N target input parameters includes : Randomly generate a plurality of candidate value combinations according to the preset value ranges of the N target input parameters; use any value combination in the plurality of candidate value combinations as the value combination corresponding to the initial iteration round ; From the plurality of candidate value combinations, determine the value combination corresponding to the current iteration round; wherein, the value combination corresponding to the current iteration round has the largest difference from the determined value combination corresponding to each iteration round; The above operation of determining the value combination corresponding to the current iteration round is repeatedly performed until the preset iteration condition is met; and the value combination corresponding to each iteration round is used as the at least one first value combination.
  • the method further includes: filtering out the values of the M input parameters in the second test case set A second test case that does not satisfy the preset constraints.
  • the second test cases whose values of the input parameters do not meet the preset constraints are filtered out, so as to ensure that the values of the input parameters of each second test case in the second test case set all meet the preset constraints.
  • the determining the target function coverage group includes: obtaining the first test case corresponding to the first test case set Two function coverage information, the second function coverage information includes the number of untested functions in each function coverage group; according to the second function coverage information corresponding to the first test case set, it is determined that the first test case set corresponds to The heuristic score of each functional coverage group, the heuristic score is positively correlated with the number of untested functions in the functional coverage group; according to the heuristic score of each functional coverage group, determine the functional coverage group Corresponding probabilities: based on the probabilities corresponding to each functional coverage group, at least one target functional coverage group is determined.
  • the target function coverage group is selected through a heuristic strategy.
  • the more untested functions in the function coverage group, the higher the corresponding heuristic score, the greater the corresponding probability, and the more likely to be selected. is the target functional coverage group; that is, for the functional coverage group that is not covered, it is more likely to be selected as the target functional coverage group; especially in the later stage of the test, the functional coverage group that is difficult to be covered is more likely to be selected as the target functional coverage group , and then can generate test cases in a targeted manner, thereby improving functional coverage, reducing manual intervention by domain experts, reducing testing costs, and improving testing efficiency.
  • the fifth possible implementation of the first aspect determine the first A heuristic score for each functional coverage group corresponding to the test case set, including: determining the corresponding function of the first test case set according to the number of untested functions in each functional coverage group corresponding to the first test case set The total number of untested functions; according to the proportion of the number of untested functions in each functional coverage group to the total number of untested functions, determine the heuristic score of each functional coverage group.
  • the method further includes: acquiring the first test case training samples; using The first test case training sample is used to train the first preset model to obtain the first model.
  • the first preset model is trained by using the first test case training sample whose value of the input parameter satisfies the preset constraint.
  • the first preset model can continuously learn the relationship between different input parameters. value constraints, and select an effective value space from the large-scale input parameter value space, so that the first model trained can generate the first test case whose input parameter value satisfies the preset constraint, and generates
  • the value space of the input parameters to be explored in the process of the first test case is reduced, avoiding the generation of redundant or invalid test cases, without correction, and ensuring the diversity of the values of the input parameters in the first test case set, Therefore, by generating a smaller-scale test case set, a higher functional coverage rate can be achieved, which effectively reduces the time required for testing, improves testing efficiency, and saves testing costs.
  • the first preset model includes a generative adversarial network, and the generative adversarial network includes a generator and a discriminator;
  • the training of the first preset model using the first test case training sample to obtain the first model includes: using the first test case training sample to generate an adversarial network Carry out multiple rounds of training; and determine the test case invariance rate corresponding to the generator when each round of training converges, the test case invariance rate represents that the values in the M input parameters of the test case generated by the generator meet the preset The ratio of the input parameters of the constraint; the generator corresponding to the maximum test case invariance rate is used as the first model.
  • the generator can tap into the potential value constraints between different input parameters, and The effective value space is selected from the value space of the large-scale input parameters, thereby reducing the value space of the input parameters to be explored in the process of generating test cases.
  • the generator corresponding to the maximum test case invariance rate is used as the first model, so that the first model can be used to automatically generate test cases whose input parameter values meet the preset constraints, while achieving high functional coverage, effective The number of test cases that need to be generated is reduced, the test efficiency is improved, and the test cost is saved.
  • the method further includes: using the convergent discriminator to filter out the second test A second test case in which the M input parameters in the test case set do not satisfy the preset constraints.
  • the method further includes: acquiring the second test case training sample and the second test case Use the first function coverage information corresponding to the training sample of the test case; use the second test case training sample and the first function coverage information to train the second preset model, and obtain the association between the function coverage group and the input parameters information.
  • the use case process provides guidance to generate test cases that can cover the functional coverage points in the target functional coverage group in a targeted manner, thereby effectively improving the functional coverage.
  • the value space effectively improves the test efficiency.
  • the second preset model includes a random forest model; the using the second test Using case training samples and the first function coverage information to train the second preset model to obtain the association information between the function coverage group and input parameters, including: for the target function coverage group, the The second test case training sample is input into the random forest model, and the random forest model is trained with the first functional coverage information as a label to obtain the correlation information between the functional coverage group and the input parameters.
  • the first functional coverage information corresponding to the second test case training sample can be used as a label, and the random forest model corresponding to the functional coverage group can be trained by using the second test case training sample , so as to dig out the correlation between the functional coverage group and the input parameters of the test cases, that is, to dig out the important input parameters that affect whether the functions in the functional coverage group can be tested, so as to obtain the relationship between the functional coverage group and the input parameters
  • the associated information can provide guidance for the process of further generating test cases, so as to generate targeted test cases that can cover the functional coverage points in the target functional coverage group, thereby effectively improving the functional coverage rate and further reducing the test case size.
  • the value space of the input parameters that needs to be explored during the use case generation process effectively improves the test efficiency.
  • the using each of the at least one first value combination replaces the A second value combination of the N target input parameters in the first test case set includes: for each first value combination, determining the first value combination whose similarity with the first value combination satisfies a preset condition A second value combination is used as a target second value combination of the first value combination; and the first value combination is used to replace the target second value combination.
  • the value of the input parameter in the second value combination satisfies the preset constraint, and the second value combination whose similarity with the first value combination satisfies the preset constraint is used as the target second value combination, so that It is ensured to the greatest extent that the values of the input parameters in the generated second test case containing the first value combination satisfy the preset constraints.
  • an embodiment of the present application provides a device for generating test cases for a chip, the device comprising: a transmission module configured to obtain an input parameter set; the input parameter set includes M input parameters of the chip, and M is An integer not less than 1; a processing module, configured to input the input parameter set into the first model to generate a first test case set; wherein, the first test case includes: the values of the M input parameters, the first A model is obtained by training by using a first test case training sample, and values of the M input parameters in the first test case training sample satisfy preset constraints.
  • the value of the input parameters in the first test case training sample satisfies the preset constraints
  • the first model is a model obtained by using the first test case training sample training, so that the first model obtained after training can be After learning the preset constraint
  • the effective value space can be selected from all the value spaces of the input parameters, thereby effectively reducing the value space of the input parameters to be explored in the process of generating the first test case; at the same time , the first model can automatically generate test cases whose values of input parameters meet the preset constraints without correction, which ensures the diversity of values of input parameters in the first test case set, so that by generating a smaller-scale first test
  • a collection of use cases can achieve high functional coverage, effectively reducing the time required for testing, effectively improving testing efficiency, and saving testing costs.
  • the processing module is further configured to: determine a target function coverage group, where the target function coverage group includes the target function to be tested; The association information between the function coverage group and the input parameters, determine the N target input parameters associated with the target function coverage group in the input parameter set, N is a positive integer not greater than M; wherein, the function coverage The association information between the group and the input parameters is obtained by using the second test case training sample and the first function coverage information corresponding to the second test case training sample; the M in the second test case training sample The value of the input parameter satisfies the preset constraint, and the first function coverage information indicates the tested function and/or the untested function in each function coverage group; determine at least one of the N target input parameters The first value combination; using each of the at least one first value combination to replace a second value combination of the N target input parameters in the first test case set to obtain a second test A set of use cases, wherein the second test case includes the values of the M input parameters.
  • the first function coverage information indicates the tested functions and/or untested functions in each function coverage group
  • the association information between the function coverage group and the input parameters is that the values of the input parameters satisfy the predetermined
  • the association information between the functional coverage group and the input parameter can indicate the associated functional coverage group and the input parameter ; and furthermore, the target input parameter associated with the target function coverage group in the input parameter set can be determined according to the association information, and the target input parameter is an important parameter that affects whether the target function to be tested in the target function coverage group can be tested,
  • the target input parameter is an important parameter that affects whether the target function to be tested in the target function coverage group can be tested
  • test cases that can cover the functional coverage group can be generated, thereby effectively improving the functional coverage rate, especially for the functional coverage group that is usually difficult to cover in the later stage of the test.
  • Better coverage effect reducing the manual intervention of domain experts, reducing the test cost, further improving the test efficiency, and effectively shortening the chip development cycle.
  • the processing module is further configured to: according to the preset of the N target input parameters Value range, randomly generating a plurality of candidate value combinations; using any value combination in the plurality of candidate value combinations as the value combination corresponding to the initial iteration round; from the plurality of candidate value combinations, Determine the value combination corresponding to the current iteration round; wherein, the difference between the value combination corresponding to the current iteration round and the determined value combination corresponding to each iteration round is the largest; repeat the above-mentioned determination of the value combination corresponding to the current iteration round operation until the preset iteration condition is satisfied; and the value combination corresponding to each iteration round is used as the at least one first value combination.
  • the processing module is further configured to: filter out the A second test case in which the values of the M input parameters do not satisfy the preset constraints.
  • the second test cases whose values of the input parameters do not meet the preset constraints are filtered out, so as to ensure that the values of the input parameters of each second test case in the second test case set all meet the preset constraints.
  • the processing module is further configured to: acquire the second test case set corresponding to the first test case set Function coverage information, the second function coverage information includes the number of untested functions in each function coverage group; according to the second function coverage information corresponding to the first test case set, determine the first test case set corresponding The heuristic score of each functional coverage group, the heuristic score is positively correlated with the number of untested functions in the functional coverage group; according to the heuristic score of each functional coverage group, it is determined that each functional coverage group corresponds to probability; at least one target function coverage group is determined based on the probability corresponding to each function coverage group.
  • the target function coverage group is selected through a heuristic strategy.
  • the more untested functions in the function coverage group, the higher the corresponding heuristic score, the greater the corresponding probability, and the more likely to be selected. is the target functional coverage group; that is, for the functional coverage group that is not covered, it is more likely to be selected as the target functional coverage group; especially in the later stage of the test, the functional coverage group that is difficult to be covered is more likely to be selected as the target functional coverage group , and then can generate test cases in a targeted manner, thereby improving functional coverage, reducing manual intervention by domain experts, reducing testing costs, and improving testing efficiency.
  • the processing module is further configured to: The number of untested functions in the function coverage group determines the total number of untested functions corresponding to the first test case set; according to the number of untested functions in each function coverage group accounts for the untested The proportion of the total number of functions tested determines the heuristic score for each functional coverage group.
  • the processing module is further configured to: obtain the first test case training samples; use the The first test case training sample is used to train the first preset model to obtain the first model.
  • the first preset model is trained by using the first test case training sample whose value of the input parameter satisfies the preset constraint.
  • the first preset model can continuously learn the relationship between different input parameters. value constraints, and select an effective value space from the large-scale input parameter value space, so that the first model trained can generate the first test case whose input parameter value satisfies the preset constraint, and generates
  • the value space of the input parameters to be explored in the process of the first test case is reduced, avoiding the generation of redundant or invalid test cases, without correction, and ensuring the diversity of the values of the input parameters in the first test case set, Therefore, by generating a smaller-scale test case set, a higher functional coverage rate can be achieved, which effectively reduces the time required for testing, effectively improves testing efficiency, and saves testing costs.
  • the first preset model includes a generative adversarial network, and the generative adversarial network includes a generator and a discriminator; the processing module is also used for: utilizing the first test case training sample to carry out multiple rounds of training to the generation confrontation network; and determining the test case invariance rate corresponding to the generator when each round of training converges , the test case invariance rate represents the ratio of the input parameters whose value meets the preset constraints among the M input parameters of the test cases generated by the generator; the generator corresponding to the maximum test case invariance rate is used as the Describe the first model.
  • the generator can tap into the potential value constraints between different input parameters, and The effective value space is selected from the value space of the large-scale input parameters, thereby reducing the value space of the input parameters to be explored in the process of generating test cases.
  • the generator corresponding to the maximum test case invariance rate is used as the first model, so that the first model can be used to automatically generate test cases whose input parameter values meet the preset constraints, while achieving high functional coverage, effective The number of test cases that need to be generated is reduced, the test efficiency is improved, and the test cost is saved.
  • the processing module is further configured to: filter out the A second test case in which the M input parameters do not satisfy the preset constraint in the second test case set.
  • the processing module is further configured to: acquire the second test case training sample and the The first function coverage information corresponding to the second test case training sample; using the second test case training sample and the first function coverage information to train the second preset model to obtain the function coverage group and the input parameters related information between them.
  • the use case process provides guidance to generate test cases that can cover the functional coverage points in the target functional coverage group in a targeted manner, thereby effectively improving the functional coverage.
  • the value space effectively improves the test efficiency.
  • the second preset model includes a random forest model; the processing module is further configured to : For the target functional coverage group, input the second test case training sample into the random forest model, and use the first functional coverage information as a label to train the random forest model to obtain the functional coverage Association information between groups and input parameters.
  • the first functional coverage information corresponding to the second test case training sample can be used as a label, and the random forest model corresponding to the functional coverage group can be trained by using the second test case training sample , so as to dig out the correlation between the functional coverage group and the input parameters of the test cases, that is, to dig out the important input parameters that affect whether the functions in the functional coverage group can be tested, so as to obtain the relationship between the functional coverage group and the input parameters
  • the associated information can provide guidance for the process of further generating test cases, so as to generate targeted test cases that can cover the functional coverage points in the target functional coverage group, thereby effectively improving the functional coverage rate and further reducing the test case size.
  • the value space of the input parameters that needs to be explored during the use case generation process effectively improves the test efficiency.
  • the processing module is further configured to: for each first value combination, determine and The second value combination whose similarity of the first value combination satisfies the preset condition is used as the target second value combination of the first value combination; use the first value combination to replace the target second value combination.
  • the value of the input parameter in the second value combination satisfies the preset constraint, and the second value combination whose similarity with the first value combination satisfies the preset constraint is used as the target second value combination, so that It is ensured to the greatest extent that the values of the input parameters in the generated second test case containing the first value combination satisfy the preset constraints.
  • an embodiment of the present application provides a device for generating test cases for a chip, including: a processor; a memory for storing instructions executable by the processor; wherein the processor is configured to execute the instructions
  • a device for generating test cases for a chip including: a processor; a memory for storing instructions executable by the processor; wherein the processor is configured to execute the instructions
  • the embodiments of the present application provide a computer-readable storage medium, on which computer program instructions are stored, and when the computer program instructions are executed by a processor, the above first aspect or various possibilities of the first aspect can be realized
  • the test case generation method of the chip in the implementation manner can be realized.
  • the embodiments of the present application provide a computer program product, which, when the computer program product runs on a computer, causes the computer to execute the above-mentioned first aspect or various possible implementation manners of the first aspect.
  • FIG. 1 shows a schematic diagram of chip testing in different steps.
  • FIG. 2 shows a schematic diagram of a scene for testing a chip design.
  • FIG. 3 shows a schematic diagram of the relationship among test cases, functional coverage points and functional coverage groups.
  • Fig. 4 shows a schematic flow diagram of a constraint-driven random testing method.
  • Fig. 5 shows a flowchart of a method for generating test cases for a chip according to an embodiment of the present application.
  • Fig. 6 shows a flow chart of another chip test case generation method according to an embodiment of the present application.
  • Fig. 7 shows a flow chart of another chip test case generation method according to an embodiment of the present application.
  • Fig. 8 shows a flow chart of another chip test case generation method according to an embodiment of the present application.
  • FIG. 9 shows a flowchart of another method for generating test cases for a chip according to an embodiment of the present application.
  • Fig. 10 shows a flowchart of a method for determining a target function coverage group according to an embodiment of the present application.
  • Fig. 11 shows a flowchart of a method for determining a first value combination according to an embodiment of the present application.
  • Fig. 12 shows a flow chart of another chip test case generation method according to an embodiment of the present application.
  • Fig. 13 shows a comparison chart of test results according to an embodiment of the present application.
  • Fig. 14 shows a structural diagram of an apparatus for generating test cases for a chip according to an embodiment of the present application.
  • FIG. 15 shows a schematic structural diagram of a device for generating test cases for a chip according to an embodiment of the present application.
  • GAN Generative adversarial networks
  • the basic structure of generative confrontation network includes generator and discriminator.
  • the generation problem is regarded as the confrontation and game between the two networks of the discriminator and the generator: the generator is used to exploit random noise (for example, uniform distribution or normal distribution) noise) to generate synthetic data, and the discriminator is used to distinguish the output data of the generator from the real data.
  • the generator tries to produce data that is closer to the real data, and accordingly, the discriminator tries to more perfectly distinguish the real data from the data output by the generator.
  • the generative confrontation network learns through the mutual game between the generator and the discriminator.
  • the generator and the discriminator progress in the confrontation, and continue to fight after the progress.
  • the performance of the generative confrontation network continues to improve, and the data generated by the generator becomes more and more perfect. , which is close to the real data, and then the generator can be used to obtain the expected data.
  • Random forest refers to a classification model constructed with a certain number of decision trees (Decision Tree) as the base learner; the random forest is obtained by training each decision tree through samples, and when using random forest for classification, each decision tree is Classification, and the final classification result can be determined by voting method according to the majority principle.
  • Decision Tree decision trees
  • the decision tree is a tree structure, and the decision is completed by passing down from the root node.
  • the decision tree generation algorithm can include iterative binary tree three generations (Iterative Dichotomiser 3, ID3), C4.5 (an extension of the ID3 algorithm) and classification regression Tree algorithm (Classification And Regression Tree, CART), etc., in which, during the generation of the decision tree, each node is split based on the selected optimal feature (feature), so that the samples contained on the end node are as much as possible of the same type category.
  • the generation process of the decision tree in the random forest has two characteristics: random selection of sample sets and random selection of the characteristics of each node; among them, random selection of sample sets refers to the construction of sub-sample sets from the original sample set by sampling with replacement , the number of samples in the sub-sample set is the same as the original sample set, and a decision tree is trained through each sub-sample set; similar to randomly selected sample sets, each node splitting process of the decision tree does not use all the features, and It is to randomly select a certain number of features from all the features, and then select the optimal feature from the randomly selected features according to the evaluation index as the feature used when the node is split.
  • the evaluation index can include Information Entropy (Information Entropy) , Gain Ratio, Gini Index, etc.
  • a hardware description language is a language for describing digital circuits and systems in a formal way. Based on this language, chip developers can systematically describe chip design ideas. Common hardware description languages may include Very-High-Speed Integrated Circuit Hardware Description Language (VHDL) and Verilog Hardware Description Language.
  • VHDL Very-High-Speed Integrated Circuit Hardware Description Language
  • Verilog Hardware Description Language Verilog Hardware Description Language
  • the register conversion level is a level of chip design, and the chip design code at this level describes the registers of all levels in the chip and the conversion of signals between different registers.
  • Chip testing runs through the chip design and production links.
  • Figure 1 shows a schematic diagram of chip testing in different links.
  • chip testing can include: chip design testing in the chip design stage; , Chip testing may include: process technology testing at the wafer processing stage, wafer testing at the packaging stage, design testing at the mass production stage, and so on.
  • the chip design test in the chip design stage has the characteristics of long time ratio, high personnel investment, and high cost. From the perspective of time cost, in most chip projects, testing work occupies more than 60% of the development cycle. Development teams spend more time on chip design testing than chip design and development. From the perspective of labor costs, the proportion of testers in the chip development team has increased year by year, surpassing the number of chip design and development personnel. The test cost of chip design directly affects the entire development cycle of the chip.
  • chip design testing has unique challenges.
  • the scale of its input parameters is huge, and there are complex value constraints among different input parameters, so it is difficult for traditional software testing methods to test the large and complex input parameter value space. Explore efficiently.
  • Fig. 2 shows a schematic diagram of a scenario where a chip design is tested, as shown in Fig. 2, a test case is generated, the test case is input into a chip emulator, and a simulation result is obtained, wherein the simulation result may include functional coverage, etc., if If the simulation result does not meet expectations, a new test case can be generated and input to the above-mentioned chip emulator, and the above operations are repeated until the simulation result meets expectations.
  • test case also called a test parameter use case or a test input
  • Each test case may include multiple preset input parameters and the values of each input parameter, and multiple test cases are correspondingly generated based on different value combinations of the input parameters.
  • the preset input parameters are parameters designed during chip design, and the value of each input parameter is within a pre-designed value range.
  • x1, x2...xK are K test cases, and these K test cases combine a test case set; p1, p2...pL are L input parameters contained in the test case, a11, a12...aKL are the values of the input parameters in the test case, for example, a31, a32...a3L in the row of the test case x3 are the values of the input parameters of the test case x3, where a32 represents the value of the input parameter p2 in the test case x3 value. For any two test cases, the value of at least one input parameter is different.
  • Functional coverage refers to the ratio of the functional coverage bins of the chip design to be tested to be covered by test cases. Achieving high functional coverage is one of the important goals of chip design and testing.
  • each function coverage point represents a function to be tested in the chip design to be tested; the function coverage point being covered by the test case indicates that the function to be tested corresponding to the function coverage point has been tested.
  • multiple function coverage points can be divided based on the different functions of the chip design to be tested.
  • Functional coverage points corresponding to similar functions can form a functional coverage group (Functional cover group), that is, functional coverage points in a functional coverage group represent multiple similar functions that need to be tested in the chip design to be tested; for any two A functional coverage group contains different functional coverage points.
  • Fig. 3 shows a schematic diagram of the relationship between a test case, a functional coverage point and a functional coverage group. As shown in Fig. 3, the functional coverage group includes two functional coverage points.
  • a functional coverage point in the functional coverage group is covered, that is, the function corresponding to the functional coverage point is tested; while another functional coverage point is not covered, that is, the function corresponding to the functional coverage point is not tested; and
  • the ratio of the number of functional coverage points of the chip design to be tested covered by the test cases to the number of all functional coverage points of the chip design to be tested can be calculated to obtain the functional coverage.
  • the random test method based on the constraint drive is the main test method used in the chip design test at the present stage. This method randomly selects the value of the corresponding input parameter within the value range of each input parameter, that is, randomly generates the test case of the chip design to be tested, but the value of each input parameter in the randomly generated test case may violate the relationship between different input parameters.
  • the value constraints between different input parameters cannot be directly applied to the test, and then use the constraint solver that can solve the value constraints between the above different input parameters to correct the randomly generated test cases, so as to obtain the corrected test cases, and use the correction
  • the following test cases are used to test the chip design under test.
  • the value constraint between the input parameter b can be: the value of the input parameter a and the number parameter b cannot be 1 at the same time, that is, the design interface A and interface B cannot be opened at the same time.
  • the value constraints between the set input parameter a, input parameter b, and input parameter c can be: input parameter c, input
  • the sum of the values of parameter d and input parameter e cannot be greater than a certain value.
  • Fig. 4 shows the schematic flow chart of the random test method based on constraint drive, as shown in Fig. 4, the main process includes: 1) adopting a random method to generate a large amount of test cases for the design of the chip to be tested, thereby obtaining a set of test cases; 2 ) The constraint solver can automatically modify the input parameter values of test cases that do not meet the preset constraints based on the value constraints between different input parameters defined in the chip design process, thereby generating test cases that are compared to random generation A test case set that more satisfies the preset constraints; 3) input the test case set that satisfies the value constraints between different input parameters into the chip emulator for simulation, obtain the number of covered function coverage points, and then compare with the pre-defined Compare the number of functional coverage points that need to be tested, so as to obtain the functional coverage.
  • the K test cases shown in Table 1 above are input into the constraint solver, and the constraint solver automatically modifies the value of the input parameters that do not meet the value constraints between the input parameters in each test case, so that The corrected test cases are obtained;
  • Table 2 shows the test cases corrected by the constraint solver, and the input parameter values of each test case.
  • x'1, x'2...x'K are the K test cases corrected by the constraint solver
  • p1, p2...pL are the L input parameters contained in the test cases
  • a11, a12, a'13...aKL is the value of the input parameter in the test case, where a'13, a'32, a'2L, etc. represent the value of the input parameter modified by the constraint solver, for example, a'13 represents the constraint solver
  • the device modifies the value a13 of the input parameter p3 in the test case x1 in Table 1 above.
  • Table 3 shows the test cases and the corresponding functional coverage information, as As shown in Table 3, x'1, x'2...x'K are K test cases corrected by the constraint solver, g1, g2...gR are R function coverage groups, b1, b2...bT are T functions Coverage points, c11, c12...cKT are function coverage parameters, indicating whether the corresponding function coverage points are covered by the corresponding test cases, that is, whether the functions that need to be tested represented by the function coverage points are tested; for example, c12, c22, c23 respectively indicates whether the functional coverage points b1, b2 and b3 in the functional coverage group g1 are covered by the test case x'2.
  • c11, c12... or cKT can be used to distinguish that the corresponding function coverage point has been covered by the corresponding test case and the corresponding function coverage point has not been covered by the corresponding test case; for example, c11, c12... or cKT It can be 0 or 1. When it is 1, it means that the function coverage point corresponding to the column where the function coverage parameter is located is covered by the test case corresponding to the row. When it is 0, it means that the function coverage point corresponding to the column where the function coverage parameter is located is not covered by the row.
  • the constraint-driven random testing method above can generate test cases satisfying the value constraints between different input parameters, since the design of the chip to be tested usually involves a large number of input parameters, the value space of the input parameters is huge, and there are There are a large number of complex value constraints between different input parameters.
  • the method of randomly generating test cases does not consider the value constraints between different input parameters, which will randomly generate a large number of redundant and even Invalid test cases, and then the constraint solver modifies the value of the input parameters that do not meet the requirements in the randomly generated test cases, which limits the value space of the input parameters explored to a certain extent, and the generated
  • the diversity of input parameter values in the test case set becomes worse. Therefore, it is often necessary to generate a large-scale test case set and conduct a long-term test to achieve high functional coverage, low test efficiency, and low test cost. higher.
  • the present application provides a method for generating test cases for a chip.
  • the method may be executed by an entity having data processing capabilities such as a processor, a server, and a server cluster.
  • the above entities can also simulate the simulation environment of the chip design to be tested, so that the test cases can be run in the simulation environment and corresponding simulation results can be obtained.
  • Fig. 5 shows a flowchart of a method for generating test cases for a chip according to an embodiment of the present application. As shown in Figure 5, the method may include the following steps:
  • Step 501 Obtain an input parameter set.
  • the input parameter set includes M input parameters of the chip, and M is an integer not less than 1.
  • the chip can be designed for the chip to be tested; for example, it can be a system-on-chip (System on Chip, SOC) of a terminal device, a server chip, an artificial intelligence chip, a communication base station chip, a communication terminal chip or other dedicated chips, etc.
  • SOC System on Chip
  • Various types of chip designs to be tested are not limited.
  • the input parameter set may include predefined input parameters of the chip design to be tested in the chip design stage, for example, the input parameter set may include the input parameters p1, p2 . . . pL in Table 1 above.
  • the value range corresponding to each input parameter in the input parameter set may also be acquired. It can be understood that the value range corresponding to each input parameter may be preset during chip design.
  • Step 502 Input the input parameter set into the first model to generate the first test case set.
  • the first test case includes: the values of the above M input parameters, the first model is obtained by using the training samples of the first test case, and the values of the M input parameters in the training samples of the first test case satisfy the preset constraints .
  • the preset constraints may include value constraints between any two or more input parameters among the M input parameters. It can be understood that between any two or more input parameters among the M input parameters
  • the value constraints of can be preset during chip design.
  • the first test case training sample can be a pre-generated test case; the first test case training sample includes M input parameters in the above input parameter set, and the values of the M input parameters meet the preset constraints; exemplary Specifically, the first test case training samples may include test cases generated by using a constraint-driven random testing method; for example, they may include test cases x'1, x'2... or x'K in Table 2 above.
  • the first model is a model obtained by using the first test case training sample training, so that the first model can learn the value constraints between different input parameters, and input the input parameter set to the first model, the second A model can automatically generate one or more first test cases whose values of input parameters meet preset constraints, that is, a set of first test cases.
  • the first model may include a generator that generates an adversarial network, for example, may include GAN, Wasserstein GAN (Wasserstein GAN, WGAN), Wasserstein GAN-gradient penalty (Wasserstein GAN-gradient penalty , WGAN-GP), the generator of mutual information generation confrontation network (InfoGAN), and can also include variational autoencoder (Variational Autoencoder, VAE), conditional transformation autoencoder (Conditional Variational Autoencoders, CVAE) and other similar model, which is not limited.
  • the M input parameters and the value range corresponding to each input parameter may be input into the first model, so that one or more test cases are automatically generated by using the first model, and each test case includes the M input
  • the value of the parameter, the value of each input parameter is within the corresponding preset value range, and the values of the M input parameters meet the preset constraints.
  • the generated first test case set can be input into the chip emulator to run, so as to obtain the corresponding power coverage.
  • the preset number of function coverage points can be obtained, and the number of function coverage points covered by the first test case set running in the simulation environment can be obtained, and then the difference between the number of covered function coverage points and the preset number of function coverage points can be calculated.
  • the ratio of the number of functional coverage points is used to obtain the power coverage rate corresponding to the first test case set. Since the design of the chip to be tested usually involves a large number of input parameters, and the value range of each input parameter is usually large, resulting in a large scale of the value space of the input parameters, in addition, there are a large number of complex differences between different input parameters.
  • the first model learns the value constraints between different input parameters, that is, the effective value space is selected from the value space of the large-scale input parameters, thereby reducing the number of first model generation.
  • the value space of the input parameters that needs to be explored in the process of a test case; at the same time, since the value of the input parameters of the first test case generated by the first model meets the preset constraints, no correction is required, ensuring that the test case set
  • the diversity of input parameter values can cover more functional coverage points. In this way, by generating a smaller test case set and spending less testing time, a higher functional coverage rate can be achieved, which effectively improves the Test efficiency. Compared with the method of randomly generating test cases in the constraint-driven random testing method, the number of required test cases is effectively reduced while achieving the same functional coverage.
  • the operation of inputting the input parameter set into the first model and generating the first test case set may be repeatedly performed until a preset stop condition is satisfied; for example, the stop condition may include that the number of cumulatively generated test cases exceeds the first preset The set value or the function coverage exceeds the second preset value and so on.
  • the first preset value and the second preset value can be set according to the test requirement, which is not limited.
  • the first model can automatically generate a preset number of first test cases, calculate the cumulative number of first test cases generated by the first model, and compare them with the first A preset value is compared, and if the accumulatively generated number of first test cases exceeds the first preset value, the above operation of inputting the input parameter set into the first model is stopped.
  • the first model can automatically generate a preset number of first test cases, and the number of first test cases contained in the first test case set If the function coverage rate exceeds the second preset value, the above operation of inputting the input parameter set into the first model is stopped , thus completing the test.
  • the value of the input parameter in the first test case training sample satisfies the preset constraints
  • the first model is a model obtained by using the first test case training sample training.
  • the preset constraint can be learned, that is, the effective value space can be selected from all the value spaces of the input parameters, thereby effectively reducing the value space of the input parameters to be explored in the process of generating the first test case;
  • the first model can automatically generate test cases whose input parameters meet the preset constraints without correction, which ensures the diversity of input parameter values in the first test case set, so that by generating smaller-scale first A collection of test cases can achieve high functional coverage, effectively reducing the time required for testing, effectively improving testing efficiency, and saving testing costs.
  • the manner of obtaining the first model through training by using the training sample of the first test case is exemplarily described below.
  • Fig. 6 shows a flow chart of another chip test case generation method according to an embodiment of the present application. As shown in Figure 6, the method may include the following steps:
  • Step 601. Obtain a training sample of a first test case.
  • a preset number of test cases can be randomly generated, for example, a small batch of test cases can be generated randomly, and then the above randomly generated test cases can be input into the constraint solver,
  • the constraint solver can modify the value of the input parameters in the randomly generated test cases that do not meet the preset constraints, so as to obtain a preset number of test cases whose input parameter values meet the preset constraints, that is, the test case training sample set,
  • the first test case training sample is any one in the test case training sample set.
  • the above-mentioned preset quantity can be set according to requirements, which is not limited.
  • Step 602 Using the training sample of the first test case to train the first preset model to obtain the first model.
  • the first preset model may include a generation confrontation network, and the generation confrontation network includes a generator and a discriminator; for example, the first preset model may be GAN, WGAN, WGAN-GP, InfoGAN, Variational Autoencoder, Conditional Variational Autoencoders Wait, no limit on this.
  • a conventional training method may be used to train the first preset model by using the first test case training samples obtained above, so as to obtain a trained model, that is, the first model.
  • the above steps 601 and 602 may be performed before the above step 501 .
  • the first test case set when the first test case set is generated by repeatedly performing the operation of inputting the input parameter set into the first model, after performing one or more operations, the newly generated The first test case trains the first model, so as to further improve the performance of the first model.
  • the first preset model is trained by using the first test case training samples whose input parameter values meet the preset constraints.
  • the first preset model can continuously learn the value constraints between different input parameters.
  • the first preset model can continuously learn the adjustment of the input parameter values in the randomly generated test cases by the constraint solver, and select an effective value space from the large-scale input parameter value space,
  • the trained first model can generate the first test case whose input parameter values meet the preset constraints, and the value space of the input parameters to be explored in the process of generating the first test case is reduced, thus avoiding the need to generate Redundant or invalid test cases do not need to be corrected, which ensures the diversity of input parameter values in the first test case set, so that more functional coverage points can be covered.
  • by generating a smaller-scale first test case Aggregation can achieve high functional coverage, effectively reducing the time required for testing, effectively improving testing efficiency, and saving testing costs.
  • the process of using the first test case training sample to train the first preset model in the above step 602 to obtain the first model will be described in detail below.
  • Fig. 7 shows a flow chart of another chip test case generation method according to an embodiment of the present application. As shown in Figure 7, the method may include the following steps:
  • Step 701 using the first test case training sample to perform multiple rounds of training on the GAN; and determine the test case invariance rate corresponding to the generator when each round of training converges.
  • the test case invariance rate indicates the ratio of the input parameters whose values meet the preset constraints among the M input parameters of the test cases generated by the generator.
  • the test case invariance rate can be determined through the constraint solver; the test case generated by the generator is input into the constraint solver, and the constraint solver will modify the values of the input parameters that do not satisfy the preset constraints, In this way, the input parameter whose value has not been modified among the M input parameters of the test case is the input parameter that satisfies the preset constraint, so that the invariance rate of the test case can be obtained.
  • the input parameter set and the value range of each input parameter can be input into the generator to generate the target test case; the target test case and the first test case are trained
  • the sample is input into the discriminator to obtain the similarity between the target test case and the first training test case; according to the similarity, the loss function value is obtained; the backpropagation is performed according to the loss function value, and the generator and the discriminator are trained until reaching convergence.
  • the target test case generated by the generator at the time of convergence can be input into the constraint solver, and the constraint solver can modify the value of the input parameters in the target test case that do not meet the preset constraints; thus the target can be obtained
  • the test case takes the number of input parameters whose value has not been modified before and after the constraint solver, and calculates the ratio of the number to the total number of all input parameters, which is the test case invariance rate corresponding to the generator when the current round of training converges. It can be understood that the higher the test case invariance rate corresponding to the generator, the more input parameters whose values satisfy the preset constraints in the test cases generated by the generator, that is, the better the performance of the generator.
  • Step 702 taking the generator corresponding to the maximum test case invariance rate as the first model.
  • the maximum test case invariance rate is selected. It can be understood that, compared with the generator obtained in other rounds of training, the maximum test case rate The generator corresponding to the invariant rate can better generate test cases whose values of input parameters meet the preset constraints.
  • the invariant rate corresponds to the generator as the first model, which is used to generate test cases whose values of input parameters satisfy preset constraints.
  • the update target of the generator is that the generated target test case can fool the discriminator , so as to be identified as the same as the corresponding first test case sample, the discriminator’s update goal is to be able to identify the target test case generated by the generator; through continuous training, the capabilities of the generator and the discriminator are getting stronger and stronger, generating
  • the detector can mine the potential value constraints between different input parameters, and filter out the effective value space from the large-scale input parameter value space, thereby reducing the number of input parameters that need to be explored in the process of generating test cases. value space.
  • the first model can be used to automatically generate test cases whose values of input parameters meet the preset constraints. While achieving high functional coverage, it effectively reduces the number of test cases to be generated, improves test efficiency, and saves cost of testing.
  • the constraint solver modifies the value of the input parameters in the constraint-driven random testing method is unknown. Therefore, it is difficult for the constraint solver to target the uncovered functional coverage points. Generate corresponding test cases; there are usually many functional coverage points that are difficult to be covered in the later stage of the test. For these functional coverage points that are difficult to be covered, domain experts are often required to test by manually designing related test cases. It consumes a lot of time, thereby greatly increasing the test cost, reducing the test efficiency, and affecting the chip development cycle.
  • the embodiment of the present application further narrows the value space for exploring the input parameters through the correlation information between the target function coverage group and the input parameters on the basis of the above-mentioned first test case where the value of the input parameter satisfies the preset constraints. , so as to generate test cases that can effectively test the untested functions in the target functional coverage group, and improve the functional coverage.
  • Fig. 8 shows a flow chart of another chip test case generation method according to an embodiment of the present application. As shown in Figure 8, the method may include the following steps:
  • Step 801. Obtain an input parameter set.
  • step 501 For a specific description of this step, reference may be made to relevant expressions in the above-mentioned step 501, which will not be repeated here.
  • Step 802 Input the input parameter set into the first model to generate the first test case set.
  • Step 803 determine the target function coverage group.
  • the target function coverage group includes the target function to be tested.
  • the target function coverage group can be any one of the preset function coverage groups; for example, the target function coverage group can be g1, g2... or gR in the above table 3; the target function is the target function coverage group
  • the functionality that needs to be tested is represented by the included functional coverage points.
  • Step 804. Determine N target input parameters associated with the target function coverage group in the input parameter set according to the association information between the function coverage group and the input parameters, where N is a positive integer not greater than M.
  • the association information between the functional coverage group and the input parameters is obtained through training using the second test case training samples and the first functional coverage information corresponding to the second test case training samples.
  • the values of the M input parameters in the second test case training sample meet the preset constraints; the second test case training sample can be a pre-generated test case; illustratively, the second test case training sample can be the same as the above-mentioned first test case The training samples are the same.
  • the first function coverage information indicates tested functions and/or untested functions in each function coverage group.
  • the first function coverage information corresponding to the second test case training sample can include the functions that have been tested by the second test case training sample in the target function coverage group and/or the functions that have not been tested by the second test case training sample in the target function coverage group function.
  • the tested functions in the functional coverage group are the functions to be tested represented by the functional coverage points covered by the second test case training sample in the functional coverage group
  • the untested functions in the functional coverage group are Functions that need to be tested are represented by functional coverage points in the functional coverage group that are not covered by the training samples of the second test case.
  • the first functional coverage information may include the values of the functional coverage parameters c11, c12...cKT in Table 3 above; for example, if the test case x'2 in Table 3 is the second test case training sample, then the corresponding first A function coverage information may include the values of the function coverage parameters c12, c22, c23 corresponding to the function coverage group g1, the values of the function coverage parameters c24, c25, c26, c27 corresponding to the function coverage group g2, etc.
  • R function coverage groups The corresponding function overrides the value of the parameter.
  • the association information between the functional coverage group and the input parameters can indicate the associated functional coverage group and input parameters.
  • any functional coverage group if an input parameter has an impact on the coverage of the functional coverage points contained in the functional coverage group or the impact is relatively large, it is considered that the functional coverage group is associated with the input parameter; otherwise, the functional coverage group is not associated with the input parameter. It can be understood that any functional coverage group can be associated with one or more input parameters; any input parameter can also be associated with one or more functional coverage groups.
  • the association information between the functional coverage group and the input parameters is the training of the second test case training sample using the value of the input parameter to meet the preset constraints, and the first functional coverage information corresponding to the second test case training sample, so
  • the association information between each function coverage group and the input parameters is excavated; and then according to the association information, the target input parameters associated with the target function coverage group in the input parameter set are determined, and the target input parameters are the factors that affect the target function coverage group.
  • An important parameter of whether the functional coverage point of is covered that is, an important parameter that affects whether the target function to be tested in the target functional coverage group can be tested.
  • Step 805. Determine at least one first value combination of N target input parameters.
  • the first value combination includes values of N target input parameters.
  • multiple first value combinations may be determined according to the value range corresponding to each target input parameter, and at least one target input parameter has a different value in any two first value combinations.
  • the target input parameter is associated with the target function coverage group, that is, the target input parameter has an impact on whether the target function to be tested in the target function coverage group can be tested, therefore, a certain number of first value combinations can be determined, so that The values of the target input parameters are as diverse as possible, so as to effectively improve the test efficiency while improving the functional coverage; for example, all the values in the value range of each target input parameter can be distributed, so as to generate multiple first Combination of values.
  • Step 806 using each of at least one first value combination to replace a second value combination of N target input parameters in the first test case set to obtain a second test case set; wherein, the second test case Including the values of M input parameters.
  • the values of the first value combination and the second value combination including the target input parameters may be the same or different; since the first value combination includes the values of the target input parameters associated with the target function coverage group value, using the first value combination to replace the second value combination, the obtained second test case set can more effectively cover the function coverage points in the target function coverage group, so that the target function to be tested in the target function coverage group Conduct effective testing and improve functional coverage.
  • each first value combination can be used to replace the second value combination in the first test case set in the following manner.
  • Method 1 For each first value combination, determine a second value combination whose similarity with the first value combination satisfies a preset condition, as the target second value combination of the first value combination; use The first combination of values replaces the target second combination of values.
  • the second value combination of each first test case in the first test case set can be obtained, thereby obtaining a plurality of second value combinations, and for any first value combination, the first value combination is calculated respectively.
  • the similarity between the value combination and each second value combination, and the second value combination corresponding to the highest similarity is used as the target second value combination, and then in the first test case where the target second value combination is located, use The first value combination replaces the target second value combination, so as to obtain the second test case.
  • the second value combination whose similarity with the first value combination satisfies the preset constraint is taken as the target second value combination, so as to ensure the generation of The value of the input parameter in the second test case containing the first value combination satisfies the preset constraint.
  • Mode 2 For each first value combination, replace the second value combination of each first test case in turn.
  • the second value combination of each first test case in the first test case set can be obtained, thereby obtaining a plurality of second value combinations, and for any first value combination, each second value combination is sequentially replaced. value combination, so as to obtain multiple second test cases, and so on, until the above substitution operation is completed for all the first value combinations.
  • the above steps 803-806 may be repeatedly executed, and for each determined target function coverage group, a second test case for effectively testing the target function to be tested in the target function coverage group is generated until the preset condition is met;
  • the preset conditions may include: the number of accumulatively generated test cases exceeds a preset number, the function coverage meets a preset requirement, or all preset function coverage point groups have been traversed, and the like.
  • the first function coverage information indicates the tested functions and/or untested functions in each function coverage group
  • the association information between the function coverage group and the input parameters is that the value of the input parameters satisfies
  • the second test case training sample with preset constraints and the first functional coverage information corresponding to the second test case training sample are trained, and the association information between the functional coverage group and the input parameters can indicate the associated functional coverage group and the input parameter Parameters; furthermore, the target input parameter associated with the target function coverage group in the input parameter set can be determined according to the associated information, and the target input parameter is an important parameter that affects whether the target function to be tested in the target function coverage group can be tested , so as to further narrow the value space of the exploration input parameters and improve the test efficiency; determine the value combination of the target input parameters, and generate the second test case set containing the value combination, and then can target the target function coverage group to be tested Test the target functions more efficiently and effectively improve the functional coverage.
  • test cases that can cover the functional coverage group can be generated, thereby effectively improving the functional coverage rate, especially for the functional coverage group that is usually difficult to cover in the later stage of the test (or functional coverage point) has better coverage effect, reduces the manual intervention of domain experts, reduces the test cost, further improves the test efficiency, and effectively shortens the chip development cycle.
  • FIG. 9 shows a flowchart of another method for generating test cases for a chip according to an embodiment of the present application. As shown in Figure 9, the method may include:
  • Step 901 obtain the second test case training sample and the first function coverage information corresponding to the second test case training sample.
  • a certain number of test cases can be randomly generated according to the set of input parameters, and the above randomly generated test cases can be input into the constraint solver, and the constraint solver can test the randomly generated test cases that do not satisfy the preset constraints
  • the value of the input parameter in the test case is modified to obtain a test case whose value of the input parameter satisfies the preset constraint, that is, the test case training sample set, and the second test case training sample is any one of the test case training sample set;
  • the second test case training sample can be input into the chip emulator to run, so as to obtain the first function coverage information corresponding to the second test case training sample.
  • Step 902 using the second test case training sample and the first function coverage information to train the second preset model to obtain the association information between the function coverage group and the input parameters.
  • the second preset model can be a random forest model, for example, it can be a random forest model constructed by decision tree generation algorithms such as ID3, C4.5, and CART;
  • the model of the association relationship is not limited.
  • the second test case training sample can be input into the random forest model, and the first function coverage information is used as a label to train the random forest model.
  • Forest model to obtain the association information between functional coverage groups and input parameters.
  • the second test case training sample set is input into the random forest model, and the functions that have been tested by the second test case training samples in the target function coverage group and the target function coverage group that have not been trained by the second test case
  • the function tested by the sample is used as a label to train the random forest model.
  • the influence of different input parameters on the classification in the training sample of the second test case is continuously mined, that is, whether different input parameters can affect the functions in the target function coverage group.
  • Influenced by the test determine the input parameters used when each node splits, so that the trained random forest model can accurately predict the coverage of the second test case training samples for the functional coverage points in the target functional coverage group; in the above training process , the input parameters used when splitting each node are the input parameters that affect whether the functions in the target function coverage group can be tested, and then after the training is completed, the importance of each influential input parameter can be determined, and according to the importance Select the N most important input parameters as the input parameters associated with the target function coverage group, wherein the value of N can be set according to actual needs.
  • a corresponding random forest model can be trained in the above manner to obtain the input parameters associated with the preset functional coverage group, Therefore, the association information between the function coverage groups and the input parameters can be determined according to each preset function coverage group and the input parameters associated with each function coverage group.
  • the importance score of the input parameter can be calculated, and the importance score can evaluate the effect of the input parameter on the training sample of the second test case
  • the role played by the set in the process of classifying that is, the degree of influence of the input parameter on the coverage of the target function coverage group.
  • the higher the importance score, the corresponding input parameter is more important to the realization of the second test case training
  • the more important the accurate classification of the sample set is, the greater the impact of the corresponding input parameters on the coverage of the functional coverage points in the target functional coverage group; for example, the input parameters can be split in all decision trees of the random forest model.
  • Such as, Gini index, information entropy, information gain, etc. as the importance score of the input parameter; thus sorted according to the importance score, and the top N input parameters are used as the coverage group with the target function Associated input parameters.
  • the test case training sample set is obtained.
  • the functional coverage information corresponding to group g each sample contains L input parameters; when training each decision tree, first, there are K times of random sampling in the test case training sample set, so that K test cases are selected Training samples, use the selected K test case training samples to train the decision tree, that is, as samples at the root node of the decision tree; then, when each node of the decision tree needs to be split, randomly select from L input parameters Select l input parameters, where l is a constant less than L; determine the evaluation index value corresponding to each input parameter in the l input parameters according to the functional coverage information corresponding to the functional coverage group g, and then select one of the l input parameters The input parameter with the best evaluation index value is used as the feature when the node is split.
  • the Gini index corresponding to each possible value of the input parameter can be calculated, and then Get the Gini index corresponding to the input parameter, and so on, get the Gini index corresponding to all input parameters, so as to select the input parameter corresponding to the minimum Gini index as the feature used when the node is split; similarly, each node according to the The method determines the corresponding features and splits until the node can no longer be split or the number of nodes exceeds the preset value, then a decision tree is generated without pruning. In this way, by repeatedly performing the above operations of random sampling and randomly selecting the features of each node, a preset number of decision trees are generated, that is, the training of the random forest is completed.
  • the importance scores corresponding to the input parameters used for node splitting can be calculated, and some input parameters with the highest importance scores can be selected as being associated with the functional coverage group g, so that the functional coverage group g and the input Correlation information between parameters.
  • the embodiment of the present application In the second preset model, the second preset model is trained by using the second test case training sample and the first function coverage information corresponding to the second test case training sample, so as to dig out the correlation between each function coverage group and the input parameters, that is, for For any functional coverage group, dig out the important input parameters that affect whether the functions in the functional coverage group can be tested, so as to obtain the correlation information between the functional coverage group and the input parameters.
  • the first functional coverage information corresponding to the second test case training sample can be used as a label, and the second test case training sample is used to train the random forest model corresponding to the functional coverage group, In this way, the relationship between the functional coverage group and the input parameters of the test case is excavated, that is, the important input parameters that affect whether the functions in the functional coverage group can be tested are excavated, and the relationship between the functional coverage group and the input parameters is obtained.
  • Associated information can provide guidance for the process of further generating test cases, so that test cases that can cover the functional coverage points in the target functional coverage group can be generated in a targeted manner, thereby effectively improving the functional coverage rate.
  • the value space of the input parameters to be explored effectively improves the test efficiency.
  • test cases can also be efficiently generated based on a predefined heuristic strategy, so as to further improve test efficiency.
  • the target function coverage group can be determined through a predefined heuristic strategy, for example, in the above step 803, the target function coverage can be determined through a predefined heuristic strategy; exemplarily, a roulette algorithm can be used , sequential selection and other heuristic strategies to determine the target function coverage group.
  • FIG. 10 shows a flowchart of a method for determining a target function coverage group according to an embodiment of the present application. As shown in FIG. 10 , the following steps may be included:
  • Step 1001. Obtain second function coverage information corresponding to the first test case set.
  • the second function coverage information may include the number of untested functions in each function coverage group, that is, the number of function coverage points not covered by the first test case set in each function coverage group.
  • Step 1002 according to the second functional coverage information corresponding to the first test case set, determine the heuristic score of each functional coverage group corresponding to the first test case set.
  • the heuristic score is positively correlated with the number of untested functions in the functional coverage group. It can be understood that the greater the number of untested functions in the functional coverage group, the greater the heuristic score of the functional coverage group.
  • the total number of untested functions corresponding to the first test case set can be determined according to the number of untested functions in each function coverage group corresponding to the first test case set; The ratio of the number of tested functions to the total number of untested functions determines the heuristic score of each functional coverage group.
  • the heuristic score of the functional coverage group can be shown as the following formula (1):
  • S g is the heuristic score of the functional coverage group g
  • u g is the number of uncovered functional coverage points in the functional coverage group g
  • G is the functional coverage group set where the functional coverage group g belongs to
  • u k is the number of uncovered functional coverage points in the kth functional coverage group in the functional coverage group set G.
  • Step 1003 according to the heuristic score of each functional coverage group, determine the probability corresponding to each functional coverage group.
  • the probability corresponding to the functional coverage group is positively correlated with the heuristic score of the functional coverage group. It is understandable that the higher the heuristic score for a functional coverage group, the greater the corresponding probability.
  • r g is the probability corresponding to the functional coverage group g
  • S g is the heuristic score of the functional coverage group g
  • G is the functional coverage group set where the functional coverage group g belongs to
  • S k is the functional coverage group set Heuristic score for the kth functional coverage group in G.
  • Step 1004 Determine at least one target function coverage group based on the probability corresponding to each function coverage group.
  • a roulette algorithm can be used to select one or more functional coverage groups as the target functional coverage group based on the probability corresponding to each functional coverage group; the higher the probability corresponding to the functional coverage group, the more likely it will be selected as the target function Override group.
  • the target function coverage group is selected through a heuristic strategy.
  • the first value combination may be determined based on a predefined heuristic strategy.
  • a predefined heuristic strategy For example, in the above step 805, at least one first value combination of N target input parameters may be determined according to the heuristic strategy; exemplary Specifically, an adaptive random sampling algorithm such as a distance sampling (T-wise) algorithm and a fixed-size candidate set (Fixed-Size-Candidate-Set, FSCS) can be used as a heuristic strategy to determine the first value combination.
  • an adaptive random sampling algorithm such as a distance sampling (T-wise) algorithm and a fixed-size candidate set (Fixed-Size-Candidate-Set, FSCS) can be used as a heuristic strategy to determine the first value combination.
  • Fig. 11 shows a flowchart of a method for determining a first value combination according to an embodiment of the present application. As shown in Fig. 11, the following steps may be included:
  • Step 1101 randomly generate multiple candidate value combinations according to the preset value ranges of N target input parameters.
  • a larger number of candidate value combinations may be generated, for example, 30*k candidate value combinations may be generated, where k is a preset number of value combinations.
  • Step 1102 taking any value combination among multiple candidate value combinations as the value combination corresponding to the initial iteration round.
  • a value combination may be randomly selected from the above multiple candidate value combinations.
  • Step 1103 from multiple candidate value combinations, determine the value combination corresponding to the current iteration round.
  • the value combination corresponding to the current iteration round has the largest difference from the determined value combination corresponding to each iteration round.
  • the total distance (such as Euclidean distance) between it and the value combination corresponding to the previous iterative rounds determined can be calculated; furthermore, the total distance corresponding to each candidate value combination
  • the candidate value combination corresponding to the maximum total distance is the value combination corresponding to the current iteration round; thus ensuring that the values of the target input parameters in the value combinations corresponding to each iteration round are more uniform and diverse.
  • Step 1104 Repeat the above operation of determining the value combination corresponding to the current iteration round until the preset iteration condition is met; and use the value combination corresponding to each iteration round as at least one first value combination.
  • the preset iteration condition may be that the determined value combinations corresponding to each iteration round reach the preset number K of value combinations.
  • the corresponding value range can include more values, if all the values are traversed, the number of first value combinations generated is too large, for example, N target input parameters
  • the preset value range of contains 512 values. If all the values are traversed, there are 512 N value combinations.
  • sampling is performed through a heuristic strategy, and multiple candidate value combinations are first generated, and then through multiple iterations, the value combination corresponding to each iteration round is determined, and the value combination corresponding to each iteration round is the same as
  • the determined value combinations corresponding to each iterative round have the largest difference, thus ensuring that the values of the N target input parameters in the value combinations corresponding to each iterative round are more uniform and diverse; in turn, the values of the input parameters can be generated to be more uniform ,
  • Various test cases while ensuring functional coverage, effectively reduce the number of required test cases and further improve test efficiency.
  • the obtained second test case set there may be values of input parameters that do not meet the preset constraints
  • post-processing can be performed on each test case in the second test case set obtained above, and the values of the M input parameters in the second test case set are filtered out if they do not satisfy the preset Constrained second test case.
  • the above post-processing operation may be performed after the above step 806 .
  • the discriminator converged during the above training process of generating an adversarial network may be used to filter out the second test cases whose values of M input parameters do not meet the preset constraints in the second test case set.
  • it can be determined to obtain a round of training of the generator corresponding to the maximum test case invariance rate, so as to use the discriminator when this round of training converges to filter out the second test A second test case whose values of the M input parameters in the test case set do not satisfy the preset constraints.
  • the above-mentioned constraint solver may be used to filter out the second test cases whose M input parameters do not satisfy the preset constraints in the second test case set.
  • the second test case set is input to the constraint solver, and the value of the input parameter does not meet the preset constraint.
  • the second test case is corrected, thereby realizing filtering out M input parameters in the second test case set A second test case whose values do not satisfy the preset constraints.
  • the second test cases whose values of input parameters do not meet the preset constraints are filtered out, so as to ensure that the values of the input parameters of each second test case in the second test case set all meet the preset constraints.
  • the input parameter set includes 575 input parameters, 7219 function coverage points, and 681 corresponding function coverage groups.
  • FIG. 12 shows a flow chart of another chip test case generation method according to an embodiment of the present application. As shown in FIG. 12, the following stages may be included:
  • Information acquisition stage In this stage, relevant information about the chip design to be tested can be obtained, for example, the set of input parameters, the value range of each input parameter, function coverage points, function coverage groups, and the corresponding relationship between function coverage groups and function coverage points etc.
  • test case sets and functional coverage information can also be obtained as training samples for training the generated confrontation network and random forest model described below.
  • a small batch (for example, 10,000) of test case sets X1 is generated in a random manner, and the test case set X1 is input into the constraint solver, and the constraint solver will vary the values of the input parameters in the test case set X1 Correct the test cases that meet the preset constraints, and return the test case set X2 whose input parameter values meet the preset constraints, input the test case set X2 into the emulator F to run, and obtain the corresponding function coverage information, the function coverage
  • the information can be a 10000*7219 functional coverage matrix M cover .
  • each row represents a test case in the test case set X2
  • each column represents a functional coverage point
  • the value of each element is 0 or 1 , where 1 means that the test case corresponding to the row where the element is located covers the functional coverage point corresponding to the column where the element is located, and 0 means that the test case corresponding to the row where the element is located does not cover the functional coverage point corresponding to the column where the element is located point.
  • the information mining stage which is used to learn the value constraints between different input parameters of test cases, and to mine the correlation between each function coverage group and input parameters.
  • the generator and discriminator of the generative confrontation network are initialized, and the optimizer and loss function are defined.
  • the test case set X2 obtained above is used as a training sample to train the generative confrontation network.
  • random noise is used as the input of the generator to generate fake samples
  • the discriminator is used to distinguish true and false samples
  • the discriminator and generator are trained end-to-end according to the loss value; so that the generator can compare the test case set X2 with The modeling ability of the constraint relationship C(X1, X2) between the test case sets X1 is getting better and better, that is, the value constraints between different input parameters of the test cases are continuously learned.
  • the test case set X2 obtained above is used as a training sample, and the functional coverage matrix M cover corresponds to the functional coverage group g
  • the input parameters as the characteristics of node splitting, train the random forest model, so that it can accurately predict the coverage of each test case in the test case set X2 for the functional coverage points in the functional coverage group g; for the trained random forest model , use the impurity of each input parameter to determine the correlation information R(g, p) between the functional coverage group g and the input parameter p, where the greater the impurity, the corresponding input parameters have a greater impact on the functional coverage point in the functional coverage group g
  • the greater the impact of the coverage the N input parameters that have the greatest impact on the coverage of the functional coverage points in the functional coverage group g are selected, and the set of N input parameters is denoted as P g .
  • a corresponding random forest model is trained by the above method, and the correlation between the functional coverage group and the input parameters is mined, so as to obtain the correlation information between each functional coverage group and the input parameters;
  • the associated information is used as a heuristic guide to quickly generate test cases with better coverage.
  • test case generation stage which is based on the heuristic strategy, uses the value constraints between the different input parameters of the test cases learned above, and digs out the relationship between each function coverage group and the input parameters to guide the direction towards Test cases are generated in a direction that is more likely to achieve higher functional coverage.
  • model first, then generate method, first, use the generative confrontation network to learn the value constraints between different input parameters, and use the random forest mining function to cover the relationship between the group and the input parameters; then, through One or more rounds of iterations are used to generate a set of test cases.
  • the trained generator is used to generate test cases whose values of input parameters meet the preset constraints, and the function coverage of this round is selected through a heuristic strategy.
  • test cases determine one or more input parameters associated with the function coverage group, and generate a variety of value combinations for each input parameter; combine the diversified value combinations and the values of the input parameters to meet the preset constraints
  • the test cases are fused, and the test case sets are generated in a targeted manner, so as to test the functions to be tested in the selected functional coverage group more efficiently; in this way, by generating a smaller test case set, a higher
  • the functional coverage rate especially for the functional coverage group that is usually difficult to be covered in the later stage of the test, has a better coverage effect, effectively reducing the manual intervention of domain experts, so that 100% functional coverage can be achieved by automatically generating test cases, reducing the test cost.
  • the cost reduces the time required for testing and effectively shortens the chip development cycle; at the same time, it greatly reduces the value space of input parameters that need to be explored when generating test cases, greatly improving test efficiency.
  • Fig. 13 shows a comparison diagram of test results according to an embodiment of the present application, wherein, the dotted line is the test result obtained by testing the above-mentioned chip design D to be tested by using the test case generation method of the chip in the embodiment of the present application, and the solid line is the test result obtained by using Test results obtained by testing the above-mentioned chip design D under test based on a constraint-driven random testing method.
  • the dotted line is the test result obtained by testing the above-mentioned chip design D to be tested by using the test case generation method of the chip in the embodiment of the present application
  • the solid line is the test result obtained by using Test results obtained by testing the above-mentioned chip design D under test based on a constraint-driven random testing method.
  • the method in the embodiment of the application can effectively reduce the number of test cases required.
  • the method in the embodiment of this application can cover 7217 functional coverage points, while the constraint-driven random testing method can only cover 7176 functional coverage points. It can be seen that when generating the same When there are a large number of test cases, the method in the embodiment of the present application can effectively improve the functional coverage.
  • the embodiments of the present application also provide a chip test case generation device, the chip test case generation device is used to implement the technical solutions described in the above method embodiments. For example, each step of the method shown in any one of the above-mentioned Figs. 5-12 may be executed.
  • Fig. 14 shows a structural diagram of a device for generating test cases for a chip according to an embodiment of the present application.
  • the device may include: a transmission module 1401 for obtaining a set of input parameters; the set of input parameters It includes M input parameters of the chip, and M is an integer not less than 1; the processing module 1402 is configured to input the set of input parameters into the first model to generate a first set of test cases; wherein, the first test case includes: the The values of M input parameters, the first model is obtained by using the training samples of the first test case, and the values of the M input parameters in the first test case training samples satisfy the preset constraints.
  • the processing module 1402 is further configured to: determine the target function coverage group, the target function coverage group includes the target function to be tested; according to the association information between the function coverage group and the input parameters , determine N target input parameters associated with the target function coverage group in the input parameter set, N is a positive integer not greater than M; wherein, the association information between the function coverage group and the input parameters is utilized
  • the second test case training sample and the first function coverage information corresponding to the second test case training sample are obtained through training; the values of the M input parameters in the second test case training sample satisfy the preset constraints , the first function coverage information represents the tested functions and/or untested functions in each function coverage group; determine at least one first value combination of the N target input parameters; use the at least one Each of the first value combinations replaces a second value combination of the N target input parameters in the first test case set to obtain a second test case set, wherein the second test case includes all Describe the values of the M input parameters.
  • the processing module 1402 is further configured to: randomly generate multiple candidate value combinations according to the preset value ranges of the N target input parameters; Any value combination in the value combination is used as the value combination corresponding to the initial iteration round; from the plurality of candidate value combinations, determine the value combination corresponding to the current iteration round; wherein, the value corresponding to the current iteration round The difference between the value combination and the determined value combination corresponding to each iteration round is the largest; repeat the operation of determining the value combination corresponding to the current iteration round until the preset iteration condition is satisfied; and combine the value combinations corresponding to each iteration round As the at least one first value combination.
  • the processing module 1402 is further configured to: filter out second test cases whose values of the M input parameters in the second test case set do not satisfy the preset constraints .
  • the processing module 1402 is further configured to: obtain the second function coverage information corresponding to the first test case set, the second function coverage information includes The number of functions tested; according to the second function coverage information corresponding to the first test case set, determine the heuristic score of each function coverage group corresponding to the first test case set, and the heuristic score is the same as that in the function coverage group The number of untested functions is positively correlated; according to the heuristic scores of each functional coverage group, determine the probability corresponding to each functional coverage group; based on the probability corresponding to each functional coverage group, determine at least one target functional coverage group .
  • the processing module 1402 is further configured to: determine the first test case according to the number of untested functions in each function coverage group corresponding to the first test case set The total number of untested functions corresponding to the set; according to the proportion of the number of untested functions in each functional coverage group to the total number of untested functions, determine the heuristic score of each functional coverage group.
  • the processing module 1402 is further configured to: obtain the first test case training sample; use the first test case training sample to train the first preset model to obtain the first model.
  • the first preset model includes a generative adversarial network, and the generative adversarial network includes a generator and a discriminator; the processing module 1402 is further configured to: utilize the first test case The training samples carry out multiple rounds of training to the generation confrontation network; and determine the test case invariance rate corresponding to the generator when each round of training converges, and the test case invariance rate represents the M input parameters of the test case generated by the generator The ratio of the input parameters whose values meet the preset constraints; the generator corresponding to the maximum test case invariance rate is used as the first model.
  • the processing module 1402 is further configured to: filter out the M input parameters in the second test case set that do not satisfy the preset constraints by using the discriminator during convergence. Second test case.
  • the processing module 1402 is further configured to: obtain the second test case training sample and the first function coverage information corresponding to the second test case training sample; use the second The test case training sample and the first function coverage information train the second preset model to obtain the association information between the function coverage group and the input parameters.
  • the second preset model includes a random forest model; the processing module 1402 is further configured to: for the target function coverage group, input the second test case training sample into The random forest model uses the first functional coverage information as a label to train the random forest model to obtain association information between the functional coverage group and input parameters.
  • the processing module 1402 is further configured to: for each first value combination, determine a second value combination whose similarity with the first value combination satisfies a preset condition, A target second value combination as the first value combination; using the first value combination to replace the target second value combination.
  • each module of the test case generation device for the above chip is only a division of logical functions, and may be fully or partially integrated into a physical entity or physically separated during actual implementation.
  • these modules can all be implemented in the form of software through scheduling of processing elements; they can also be implemented in the form of hardware; some modules can also be implemented in the form of processing element scheduling software, and some modules can be implemented in the form of hardware.
  • An embodiment of the present application provides a device for generating test cases for a chip, including: a processor and a memory for storing instructions executable by the processor; wherein the processor is configured to implement the above method when executing the instructions.
  • the test case generation method for the chip shown in any one of the above-mentioned FIGS. 5-12 can be implemented.
  • Fig. 15 shows a schematic structural diagram of a test case generation device for a chip according to an embodiment of the present application.
  • the test case generation device for the chip may include: at least one processor 1501, a communication line 1502, and a memory 1503 and at least one communication interface 1504.
  • the processor 1501 can be a general-purpose central processing unit (central processing unit, CPU), a microprocessor, a specific application integrated circuit (application-specific integrated circuit, ASIC), or one or more for controlling the execution of the application program program integrated circuit.
  • CPU central processing unit
  • ASIC application-specific integrated circuit
  • Communication line 1502 may include a pathway for communicating information between the above-described components.
  • the communication interface 1504 uses any device such as a transceiver to communicate with other devices or communication networks, such as Ethernet, RAN, wireless local area networks (wireless local area networks, WLAN) and so on.
  • a transceiver to communicate with other devices or communication networks, such as Ethernet, RAN, wireless local area networks (wireless local area networks, WLAN) and so on.
  • the memory 1503 can be a read-only memory (read-only memory, ROM) or other types of static storage devices that can store static information and instructions, random access memory (random access memory, RAM) or other types that can store information and instructions It can also be an electrically erasable programmable read-only memory (EEPROM), compact disc read-only memory (CD-ROM) or other optical disc storage, optical disc storage (including compact discs, laser discs, optical discs, digital versatile discs, Blu-ray discs, etc.), magnetic disk storage media or other magnetic storage devices, or can be used to carry or store desired program code in the form of instructions or data structures and can be programmed by a computer Any other medium accessed, but not limited to.
  • EEPROM electrically erasable programmable read-only memory
  • CD-ROM compact disc read-only memory
  • optical disc storage including compact discs, laser discs, optical discs, digital versatile discs, Blu-ray discs, etc.
  • magnetic disk storage media or other magnetic storage devices or can be used to carry or store
  • the memory may exist independently and be connected to the processor through the communication line 1502 . Memory can also be integrated with the processor.
  • the memory provided by the embodiment of the present application may generally be non-volatile.
  • the memory 1503 is used to store computer-executed instructions for implementing the solutions of the present application, and the execution is controlled by the processor 1501 .
  • the processor 1501 is configured to execute computer-executed instructions stored in the memory 1503, so as to implement the methods provided in the foregoing embodiments of the present application. Exemplarily, each step of the method shown in any one of the above-mentioned Figs. 5-12 can be implemented.
  • the computer-executed instructions in the embodiments of the present application may also be referred to as application program codes, which is not specifically limited in the embodiments of the present application.
  • the processor 1501 may include one or more CPUs, such as CPU0 and CPU1 in FIG. 15 .
  • the device for generating test cases of a chip may include multiple processors, such as processor 1501 and processor 1507 in FIG. 15 .
  • processors may be a single-core (single-CPU) processor or a multi-core (multi-CPU) processor.
  • a processor herein may refer to one or more devices, circuits, and/or processing cores for processing data (eg, computer program instructions).
  • the device for generating test cases for a chip may further include an output device 1505 and an input device 1506 .
  • Output device 1505 is in communication with processor 1501 and can display information in a variety of ways.
  • the output device 1505 may be a liquid crystal display (liquid crystal display, LCD), a light emitting diode (light emitting diode, LED) display device, a cathode ray tube (cathode ray tube, CRT) display device, or a projector (projector) wait.
  • the input device 1506 communicates with the processor 1501 and can receive user input in various ways.
  • the input device 1506 may be a mouse, a keyboard, a touch screen device, or a sensory device, among others.
  • the transmission module 1401 in FIG. 14 above can be realized by the communication interface 1504 in FIG.
  • the processor 1501 is implemented.
  • An embodiment of the present application provides a non-volatile computer-readable storage medium, on which computer program instructions are stored, and when the computer program instructions are executed by a processor, the foregoing method is realized. Exemplarily, each step of the method shown in any one of the above-mentioned Figs. 5-12 can be implemented.
  • An embodiment of the present application provides a computer program product, including computer-readable codes, or a non-volatile computer-readable storage medium bearing computer-readable codes, when the computer-readable codes are stored in a processor of an electronic device When running in the electronic device, the processor in the electronic device executes the above method. Exemplarily, each step of the method shown in any one of the above-mentioned Figs. 5-12 can be implemented.
  • a computer readable storage medium may be a tangible device that can retain and store instructions for use by an instruction execution device.
  • a computer readable storage medium may be, for example, but is not limited to, an electrical storage device, a magnetic storage device, an optical storage device, an electromagnetic storage device, a semiconductor storage device, or any suitable combination of the foregoing.
  • Non-exhaustive list of computer-readable storage media include: portable computer disk, hard disk, random access memory (Random Access Memory, RAM), read only memory (Read Only Memory, ROM), erasable Electrically Programmable Read-Only-Memory (EPROM or flash memory), Static Random-Access Memory (Static Random-Access Memory, SRAM), Portable Compression Disk Read-Only Memory (Compact Disc Read-Only Memory, CD - ROM), Digital Video Disc (DVD), memory sticks, floppy disks, mechanically encoded devices such as punched cards or raised structures in grooves with instructions stored thereon, and any suitable combination of the foregoing .
  • RAM Random Access Memory
  • ROM read only memory
  • EPROM or flash memory erasable Electrically Programmable Read-Only-Memory
  • Static Random-Access Memory SRAM
  • Portable Compression Disk Read-Only Memory Compact Disc Read-Only Memory
  • CD - ROM Compact Disc Read-Only Memory
  • DVD Digital Video Disc
  • Computer readable program instructions or codes described herein may be downloaded from a computer readable storage medium to a respective computing/processing device, or downloaded to an external computer or external storage device over a network, such as the Internet, local area network, wide area network, and/or wireless network.
  • the network may include copper transmission cables, fiber optic transmission, wireless transmission, routers, firewalls, switches, gateway computers, and/or edge servers.
  • a network adapter card or a network interface in each computing/processing device receives computer-readable program instructions from the network and forwards the computer-readable program instructions for storage in a computer-readable storage medium in each computing/processing device .
  • Computer program instructions for performing the operations of the present application may be assembly instructions, instruction set architecture (Instruction Set Architecture, ISA) instructions, machine instructions, machine-related instructions, microcode, firmware instructions, state setting data, or in one or more source or object code written in any combination of programming languages, including object-oriented programming languages—such as Smalltalk, C++, etc., and conventional procedural programming languages—such as the “C” language or similar programming languages.
  • Computer readable program instructions may execute entirely on the user's computer, partly on the user's computer, as a stand-alone software package, partly on the user's computer and partly on a remote computer, or entirely on the remote computer or server implement.
  • the remote computer can be connected to the user's computer through any kind of network, including a Local Area Network (LAN) or a Wide Area Network (WAN), or it can be connected to an external computer such as use an Internet service provider to connect via the Internet).
  • electronic circuits such as programmable logic circuits, field-programmable gate arrays (Field-Programmable Gate Array, FPGA) or programmable logic arrays (Programmable Logic Array, PLA), the electronic circuit can execute computer-readable program instructions, thereby realizing various aspects of the present application.
  • These computer-readable program instructions may be provided to a processor of a general purpose computer, special purpose computer, or other programmable data processing apparatus to produce a machine such that when executed by the processor of the computer or other programmable data processing apparatus , producing an apparatus for realizing the functions/actions specified in one or more blocks in the flowchart and/or block diagram.
  • These computer-readable program instructions can also be stored in a computer-readable storage medium, and these instructions cause computers, programmable data processing devices and/or other devices to work in a specific way, so that the computer-readable medium storing instructions includes An article of manufacture comprising instructions for implementing various aspects of the functions/acts specified in one or more blocks in flowcharts and/or block diagrams.
  • each block in a flowchart or block diagram may represent a module, a portion of a program segment, or an instruction that includes one or more Executable instructions.
  • the functions noted in the block may occur out of the order noted in the figures. For example, two blocks in succession may, in fact, be executed substantially concurrently, or they may sometimes be executed in the reverse order, depending upon the functionality involved.
  • each block in the block diagrams and/or flowcharts, and combinations of blocks in the block diagrams and/or flowcharts can be implemented with hardware (such as circuits or ASIC (Application Specific Integrated Circuit, application-specific integrated circuit)), or it can be realized by a combination of hardware and software, such as firmware.
  • hardware such as circuits or ASIC (Application Specific Integrated Circuit, application-specific integrated circuit)
  • firmware such as firmware

Landscapes

  • Engineering & Computer Science (AREA)
  • Theoretical Computer Science (AREA)
  • Computer Hardware Design (AREA)
  • Physics & Mathematics (AREA)
  • Evolutionary Computation (AREA)
  • General Engineering & Computer Science (AREA)
  • General Physics & Mathematics (AREA)
  • Data Mining & Analysis (AREA)
  • Geometry (AREA)
  • Life Sciences & Earth Sciences (AREA)
  • Artificial Intelligence (AREA)
  • Bioinformatics & Cheminformatics (AREA)
  • Bioinformatics & Computational Biology (AREA)
  • Computer Vision & Pattern Recognition (AREA)
  • Evolutionary Biology (AREA)
  • Tests Of Electronic Circuits (AREA)

Abstract

The present application relates to a chip test case generation method and apparatus, and a storage medium. The method may comprise: acquiring a set of input parameters, wherein the set of input parameters comprises M input parameters of a chip, M being an integer not less than 1; and inputting the set of input parameters into a first model, so as to generate a set of first test cases, wherein each first test case comprises values of the M input parameters, the first model is obtained by using a first test case training sample to perform training, and the values of the M input parameters in the first test case training sample satisfy a preset constraint. In the present application, a relatively high function coverage rate can be reached by means of generating a small-scale set of first test cases, such that the time required for testing is effectively shortened, thereby improving the testing efficiency, and saving on the testing costs.

Description

一种芯片的测试用例生成方法、装置及存储介质A chip test case generation method, device and storage medium
本申请要求于2021年12月31日提交中国专利局、申请号为202111663515.6、发明名称为“一种芯片的测试用例生成方法、装置及存储介质”的中国专利申请的优先权,其全部内容通过引用结合在本申请中。This application claims the priority of the Chinese patent application submitted to the China Patent Office on December 31, 2021, with the application number 202111663515.6, and the title of the invention is "a method, device and storage medium for generating test cases for a chip", all of which have been passed References are incorporated in this application.
技术领域technical field
本申请涉及人工智能领域,尤其涉及一种芯片的测试用例生成方法、装置及存储介质。The present application relates to the field of artificial intelligence, in particular to a chip test case generation method, device and storage medium.
背景技术Background technique
芯片被广泛应用于各类电子设备中,被认为是电子设备的心脏。芯片的生成过程复杂,需要经历芯片规格定义、芯片设计、物理布局、流片生产等诸多环节。其中,芯片设计作为芯片生成过程的上游基础环节尤为关键。通常,开发人员在规格定义环节设计芯片的特征、属性、功能架构,而后在芯片设计环节使用硬件描述语言(Hardware Description Language,HDL)编写芯片设计实现的寄存器转换级别(Register-Transfer-Level,RTL)代码,后续环节基于此RTL代码进行进一步开发。由于芯片设计一旦被投入量产,将很难再进行更改,芯片设计上的不足会带来灾难性的经济损失,甚至危害使用者生命安全,因此,保证芯片设计的质量是一项十分重要的任务,在将芯片设计投入到生产环节之前,对芯片设计进行充分测试是十分必要的。Chips are widely used in various electronic devices and are considered to be the heart of electronic devices. The generation process of the chip is complicated, and it needs to go through many links such as chip specification definition, chip design, physical layout, and tape-out production. Among them, chip design is particularly critical as the upstream basic link of the chip generation process. Usually, developers design the features, attributes, and functional architecture of the chip in the specification definition link, and then use the Hardware Description Language (Hardware Description Language, HDL) to write the Register-Transfer-Level (RTL) level (RTL) implemented by the chip design in the chip design link. ) code, and the subsequent links will be further developed based on this RTL code. Once the chip design is put into mass production, it will be difficult to change it, and the lack of chip design will bring catastrophic economic losses and even endanger the lives of users. Therefore, it is very important to ensure the quality of chip design. It is very necessary to fully test the chip design before putting the chip design into production.
目前,主要采用基于约束驱动的随机测试方法(Constraint Driven Random,CDR)对待测芯片设计(Design Under Test,DUT)进行测试。该方法使用约束求解器对随机生成的测试用例进行校正,并利用校正后的测试用例进行测试,该方法往往需要大规模的测试用例集合,进行较长时间的测试,才能达到较高的功能覆盖率,测试效率较低,测试成本较高。At present, the constraint-driven random test method (Constraint Driven Random, CDR) is mainly used to test the chip design under test (Design Under Test, DUT). This method uses a constraint solver to correct randomly generated test cases, and uses the corrected test cases for testing. This method often requires a large-scale test case collection and a long period of testing to achieve high functional coverage. rate, the test efficiency is low, and the test cost is high.
发明内容Contents of the invention
有鉴于此,本申请提出了一种芯片的测试用例生成方法、装置及存储介质。In view of this, the present application proposes a chip test case generation method, device and storage medium.
第一方面,本申请的实施例提供了一种芯片的测试用例生成方法,所述方法包括:获取输入参数集合;所述输入参数集合包括芯片的M个输入参数,M为不小于1的整数;将所述输入参数集合输入第一模型,生成第一测试用例集合;其中,第一测试用例包括:所述M个输入参数的取值,所述第一模型为利用第一测试用例训练样本训练所得到,所述第一测试用例训练样本中所述M个输入参数的取值满足预设约束。In the first aspect, an embodiment of the present application provides a method for generating test cases for a chip, the method comprising: obtaining an input parameter set; the input parameter set includes M input parameters of the chip, and M is an integer not less than 1 ; Input the input parameter set into the first model to generate the first test case set; wherein, the first test case includes: the values of the M input parameters, and the first model utilizes the first test case training samples As obtained from the training, the values of the M input parameters in the training samples of the first test case satisfy preset constraints.
基于上述技术方案,第一测试用例训练样本中输入参数的取值满足预设约束,第一模型为利用第一测试用例训练样本训练所得到的模型,这样,经过训练所得到的第一模型可以学习到该预设约束,即可以从输入参数全部的取值空间中筛选出有效的取值空间,从而有效减少了生成第一测试用例的过程中所需探索的输入参数的取值空间;同时,第一模型可以自动生成输入参数的取值满足预设约束的测试用例,无需进行校正,保证了第一测试用例集合中输入参数取值的多样性,从而通过生成较小规模的第一测试用例集合,即可达到较高的功能覆盖率,有效减少了测试所需时间,有效提高了测试效率,节约了测试成本。Based on the above technical solution, the value of the input parameters in the first test case training sample satisfies the preset constraints, and the first model is a model obtained by using the first test case training sample training, so that the first model obtained after training can be After learning the preset constraint, the effective value space can be selected from all the value spaces of the input parameters, thereby effectively reducing the value space of the input parameters to be explored in the process of generating the first test case; at the same time , the first model can automatically generate test cases whose values of input parameters meet the preset constraints without correction, which ensures the diversity of values of input parameters in the first test case set, so that by generating a smaller-scale first test A collection of use cases can achieve high functional coverage, effectively reducing the time required for testing, effectively improving testing efficiency, and saving testing costs.
根据第一方面,在所述第一方面的第一种可能的实现方式中,所述方法还包括:确定目标功能覆盖组,所述目标功能覆盖组包括待测试的目标功能;根据功能覆盖组与输入参数之间的关联信息,确定所述输入参数集合中与所述目标功能覆盖组相关联的N个目标输入参数,N为不大于M的正整数;其中,所述功能覆盖组与输入参数之间的关联信息为利用第二测试用例训练样本及所述第二测试用例训练样本对应的第一功能覆盖信息训练所得到;所述第二测试用例训练样本中所述M个输入参数的取值满足所述预设约束,所述第一功能覆盖信息表示各功能覆盖组中已被测试的功能和/或未被测试的功能;确定所述N个目标输入参数的至少一个第一取值组合;利用所述至少一个第一取值组合中的每一个,替代所述第一测试用例集合中的所述N个目标输入参数的一个第二取值组合,得到第二测试用例集合,其中,第二测试用例包括所述M个输入参数的取值。According to the first aspect, in the first possible implementation manner of the first aspect, the method further includes: determining a target function coverage group, the target function coverage group including the target function to be tested; according to the function coverage group Associating information with input parameters, determine N target input parameters associated with the target function coverage group in the input parameter set, N is a positive integer not greater than M; wherein, the function coverage group and the input The correlation information between parameters is obtained by using the second test case training sample and the first function coverage information corresponding to the second test case training sample; the M input parameters in the second test case training sample The value satisfies the preset constraints, the first function coverage information indicates the tested functions and/or untested functions in each function coverage group; determine at least one first value of the N target input parameters value combination; using each of the at least one first value combination to replace a second value combination of the N target input parameters in the first test case set to obtain a second test case set, Wherein, the second test case includes values of the M input parameters.
基于上述技术方案,第一功能覆盖信息表示各功能覆盖组中已被测试的功能和/或未被测试的功能,功能覆盖组与输入参数之间的关联信息为利用输入参数的取值满足预设约束的第二测试用例训练样本、及第二测试用例训练样本对应的第一功能覆盖信息训练所得到,功能覆盖组与输入参数之间的关联信息可以指示相关联的功能覆盖组与输入参数;进而可以根据该关联信息确定输入参数集合中与目标功能覆盖组相关联的目标输入参数,该目标输入参数即为影响目标功能覆盖组中待测试的目标功能能否被测试到的重要参数,从而进一步缩小探索输入参数的取值空间,提升了测试效率;确定目标输入参数的取值组合,并生成包含该取值组合的第二测试用例集合,进而可以针对目标功能覆盖组中待测试的目标功能进行更加高效地测试,有效提升功能覆盖率。在一些示例中,针对未覆盖的功能覆盖组,可以生成能覆盖该功能覆盖组的测试用例,从而有效提升功能覆盖率,尤其对于测试后期通常难以被覆盖的功能覆盖组具有更好的覆盖效果,减少了领域专家的人工介入,降低了测试成本,进一步提升了测试效率,有效缩小了芯片开发周期。Based on the above technical solution, the first function coverage information indicates the tested functions and/or untested functions in each function coverage group, and the association information between the function coverage group and the input parameters is that the values of the input parameters satisfy the predetermined Assuming that the training sample of the second test case constrained and the first functional coverage information corresponding to the second test case training sample are obtained through training, the association information between the functional coverage group and the input parameter can indicate the associated functional coverage group and the input parameter ; and furthermore, the target input parameter associated with the target function coverage group in the input parameter set can be determined according to the association information, and the target input parameter is an important parameter that affects whether the target function to be tested in the target function coverage group can be tested, Thereby further narrowing the value space of the exploration input parameters and improving the test efficiency; determining the value combination of the target input parameters and generating a second test case set containing the value combination, and then covering the target function coverage group to be tested The target function is tested more efficiently and the functional coverage is effectively improved. In some examples, for an uncovered functional coverage group, test cases that can cover the functional coverage group can be generated, thereby effectively improving the functional coverage rate, especially for the functional coverage group that is usually difficult to cover in the later stage of the test. Better coverage effect , reducing the manual intervention of domain experts, reducing the test cost, further improving the test efficiency, and effectively shortening the chip development cycle.
根据上述第一方面的第一种可能的实现方式,在所述第一方面的第二种可能的实现方式中,所述确定所述N个目标输入参数的至少一个第一取值组合,包括:根据所述N个目标输入参数的预设取值范围,随机生成多个候选取值组合;将所述多个候选取值组合中的任一取值组合作为初始迭代回合对应的取值组合;从所述多个候选取值组合中,确定当前迭代回合对应的取值组合;其中,所述当前迭代回合对应的取值组合与已确定的各迭代回合对应的取值组合的差异最大;重复执行上述确定当前迭代回合对应的取值组合的操作,直到满足预设迭代条件;并将各迭代回合对应的取值组合作为所述至少一个第一取值组合。According to the first possible implementation of the first aspect above, in the second possible implementation of the first aspect, the determining at least one first value combination of the N target input parameters includes : Randomly generate a plurality of candidate value combinations according to the preset value ranges of the N target input parameters; use any value combination in the plurality of candidate value combinations as the value combination corresponding to the initial iteration round ; From the plurality of candidate value combinations, determine the value combination corresponding to the current iteration round; wherein, the value combination corresponding to the current iteration round has the largest difference from the determined value combination corresponding to each iteration round; The above operation of determining the value combination corresponding to the current iteration round is repeatedly performed until the preset iteration condition is met; and the value combination corresponding to each iteration round is used as the at least one first value combination.
基于上述技术方案,考虑到对于任一目标输入参数,其对应的取值范围内可以包括较多的取值,若遍历所有的取值,生成的第一取值组合数量规模太大,因此,通过启发式策略进行采样,首先生成多个候选取值组合,进而通过多次迭代,确定每一迭代回合对应的取值组合,且每一迭代回合对应的取值组合与已确定的各迭代回合对应的取值组合的差异最大,从而保证了各迭代回合对应的取值组合中N个目标输入参数的取值更加均匀、多样;进而可以生成输入参数的取值更加均匀、多样的测试用例,在保证功能覆盖率的同时,进一步提升了测试效率。Based on the above technical solution, considering that for any target input parameter, its corresponding value range may include more values, if all the values are traversed, the number of first value combinations generated is too large, therefore, Sampling is performed through a heuristic strategy. First, multiple candidate value combinations are generated, and then through multiple iterations, the value combination corresponding to each iteration round is determined, and the value combination corresponding to each iteration round is consistent with the determined iteration rounds. The corresponding value combinations have the largest difference, thus ensuring that the values of the N target input parameters in the value combinations corresponding to each iteration round are more uniform and diverse; thus, test cases with more uniform and diverse input parameter values can be generated. While ensuring the functional coverage, the test efficiency is further improved.
根据上述各种可能的实现方式,在所述第一方面的第三种可能的实现方式中,所述方法还包括:过滤掉所述第二测试用例集合中所述M个输入参数的取值不满足所述预设约束的第二测试用例。According to the various possible implementations above, in the third possible implementation of the first aspect, the method further includes: filtering out the values of the M input parameters in the second test case set A second test case that does not satisfy the preset constraints.
基于上述技术方案,过滤掉输入参数的取值不满足预设约束的第二测试用例,从而保证第二测试用例集合中各第二测试用例的输入参数的取值均满足预设约束。Based on the above technical solution, the second test cases whose values of the input parameters do not meet the preset constraints are filtered out, so as to ensure that the values of the input parameters of each second test case in the second test case set all meet the preset constraints.
根据上述第一方面的各种可能的实现方式,在所述第一方面的第四种可能的实现方式中,所述确定目标功能覆盖组,包括:获取所述第一测试用例集合对应的第二功能覆盖信息,所述第二功能覆盖信息包括各功能覆盖组中未被测试的功能的个数;根据所述第一测试用例集合对应的第二功能覆盖信息,确定第一测试用例集合对应的各功能覆盖组的启发式分数,所述启发式分数与功能覆盖组中未被测试的功能的个数正相关;根据所述各功能覆盖组的启发式分数,确定所述各功能覆盖组对应的概率;基于各功能覆盖组对应的概率,确定至少一个目标功能覆盖组。According to various possible implementations of the above first aspect, in a fourth possible implementation of the first aspect, the determining the target function coverage group includes: obtaining the first test case corresponding to the first test case set Two function coverage information, the second function coverage information includes the number of untested functions in each function coverage group; according to the second function coverage information corresponding to the first test case set, it is determined that the first test case set corresponds to The heuristic score of each functional coverage group, the heuristic score is positively correlated with the number of untested functions in the functional coverage group; according to the heuristic score of each functional coverage group, determine the functional coverage group Corresponding probabilities: based on the probabilities corresponding to each functional coverage group, at least one target functional coverage group is determined.
基于上述技术方案,通过启发式策略选取目标功能覆盖组,功能覆盖组中未被测试的功能的个数越多,对应的启发式分数越高,则对应的概率越大,则越可能被选为目标功能覆盖组;即针对未被覆盖的功能覆盖组,更有可能被选为目标功能覆盖组;尤其是在测试后期,难以被覆盖的功能覆盖组更有可能被选为目标功能覆盖组,进而可以针对性地生成测试用例,从而提升功能覆盖率,减少了领域专家的人工介入,降低了测试成本,提高了测试效率。Based on the above technical solution, the target function coverage group is selected through a heuristic strategy. The more untested functions in the function coverage group, the higher the corresponding heuristic score, the greater the corresponding probability, and the more likely to be selected. is the target functional coverage group; that is, for the functional coverage group that is not covered, it is more likely to be selected as the target functional coverage group; especially in the later stage of the test, the functional coverage group that is difficult to be covered is more likely to be selected as the target functional coverage group , and then can generate test cases in a targeted manner, thereby improving functional coverage, reducing manual intervention by domain experts, reducing testing costs, and improving testing efficiency.
根据上述第一方面的第四种可能的实现方式,在所述第一方面的第五种可能的实现方式中,所述根据所述第一测试用例集合对应的第二功能覆盖信息,确定第一测试用例集合对应的各功能覆盖组的启发式分数,包括:根据所述第一测试用例集合对应的各功能覆盖组中未被测试的功能的个数,确定所述第一测试用例集合对应的未被测试的功能总数;根据所述各功能覆盖组中未被测试的功能的个数占所述未被测试的功能总数的比重,确定所述各功能覆盖组的启发式分数。According to the fourth possible implementation of the first aspect above, in the fifth possible implementation of the first aspect, according to the second function coverage information corresponding to the first test case set, determine the first A heuristic score for each functional coverage group corresponding to the test case set, including: determining the corresponding function of the first test case set according to the number of untested functions in each functional coverage group corresponding to the first test case set The total number of untested functions; according to the proportion of the number of untested functions in each functional coverage group to the total number of untested functions, determine the heuristic score of each functional coverage group.
根据上述第一方面或第一方面的各种可能的实现方式,在所述第一方面的第六种可能的实现方式中,所述方法还包括:获取所述第一测试用例训练样本;利用所述第一测试用例训练样本对第一预设模型进行训练,得到所述第一模型。According to the above first aspect or various possible implementations of the first aspect, in a sixth possible implementation of the first aspect, the method further includes: acquiring the first test case training samples; using The first test case training sample is used to train the first preset model to obtain the first model.
基于上述技术方案,利用输入参数的取值满足预设约束的第一测试用例训练样本对第一预设模型进行训练,在训练过程中,第一预设模型可以不断学习不同输入参数之间的取值约束,从规模庞大的输入参数的取值空间中筛选出有效的取值空间,这样,训练得到的第一模型能够生成输入参数的取值满足预设约束的第一测试用例,且生成第一测试用例的过程中所需探索的输入参数的取值空间减少,避免了生成冗余或无效的测试用例,无需进行校正,保证了第一测试用例集合中输入参数取值的多样性,从而通过生成较小规模的测试用例集合,即可达到较高的功能覆盖率,有效减少了测试所需时间,提高了测试效率,节约了测试成本。Based on the above technical solution, the first preset model is trained by using the first test case training sample whose value of the input parameter satisfies the preset constraint. During the training process, the first preset model can continuously learn the relationship between different input parameters. value constraints, and select an effective value space from the large-scale input parameter value space, so that the first model trained can generate the first test case whose input parameter value satisfies the preset constraint, and generates The value space of the input parameters to be explored in the process of the first test case is reduced, avoiding the generation of redundant or invalid test cases, without correction, and ensuring the diversity of the values of the input parameters in the first test case set, Therefore, by generating a smaller-scale test case set, a higher functional coverage rate can be achieved, which effectively reduces the time required for testing, improves testing efficiency, and saves testing costs.
根据上述第一方面的第六种可能的实现方式,在所述第一方面的第七种可能的实现方式中,所述第一预设模型包括生成对抗网络,所述生成对抗网络包含生成器及判别器;所述利用所述第一测试用例训练样本对所述第一预设模型进行训练,得到所述第一模型,包括:利用所述第一测试用例训练样本对所述生成对抗网络进行多轮训练;并确定每轮训练收敛时的生成器对应的测试用例不变率,所述测试用例不变率表示生成器生成的测试用例的M个输入参数中取值符合所述预设约束的输入参数的比率;将与最大测试用例不变率对应的生成器,作为所述第一模型。According to the sixth possible implementation of the first aspect above, in the seventh possible implementation of the first aspect, the first preset model includes a generative adversarial network, and the generative adversarial network includes a generator and a discriminator; the training of the first preset model using the first test case training sample to obtain the first model includes: using the first test case training sample to generate an adversarial network Carry out multiple rounds of training; and determine the test case invariance rate corresponding to the generator when each round of training converges, the test case invariance rate represents that the values in the M input parameters of the test case generated by the generator meet the preset The ratio of the input parameters of the constraint; the generator corresponding to the maximum test case invariance rate is used as the first model.
基于上述技术方案,利用第一测试用例训练样本对生成对抗网络中的判别器和生成器进行多轮对抗训练,通过不断训练,生成器可以挖掘到不同输入参数之间潜在的取值约束,且 从规模庞大的输入参数的取值空间中筛选出有效的取值空间,从而减少了生成测试用例的过程中所需探索的输入参数的取值空间。将与最大测试用例不变率对应的生成器作为第一模型,从而可以利用第一模型自动生成输入参数的取值满足预设约束的测试用例,在达到较高的功能覆盖率的同时,有效减少了所需生成的测试用例数量,提高了测试效率,节约了测试成本。Based on the above technical solution, use the first test case training sample to conduct multiple rounds of confrontation training on the discriminator and generator in the generative confrontation network. Through continuous training, the generator can tap into the potential value constraints between different input parameters, and The effective value space is selected from the value space of the large-scale input parameters, thereby reducing the value space of the input parameters to be explored in the process of generating test cases. The generator corresponding to the maximum test case invariance rate is used as the first model, so that the first model can be used to automatically generate test cases whose input parameter values meet the preset constraints, while achieving high functional coverage, effective The number of test cases that need to be generated is reduced, the test efficiency is improved, and the test cost is saved.
根据上述第一方面的第七种可能的实现方式,在所述第一方面的第八种可能的实现方式中,所述方法还包括:利用收敛时的判别器,过滤掉所述第二测试用例集合中所述M个输入参数不满足所述预设约束的第二测试用例。According to the seventh possible implementation of the first aspect above, in the eighth possible implementation of the first aspect, the method further includes: using the convergent discriminator to filter out the second test A second test case in which the M input parameters in the test case set do not satisfy the preset constraints.
根据上述第一方面的各种可能的实现方式,在所述第一方面的第九种可能的实现方式中,所述方法还包括:获取所述第二测试用例训练样本及所述第二测试用例训练样本对应的第一功能覆盖信息;利用所述第二测试用例训练样本及所述第一功能覆盖信息对第二预设模型进行训练,得到所述功能覆盖组与输入参数之间的关联信息。According to various possible implementations of the first aspect above, in a ninth possible implementation of the first aspect, the method further includes: acquiring the second test case training sample and the second test case Use the first function coverage information corresponding to the training sample of the test case; use the second test case training sample and the first function coverage information to train the second preset model, and obtain the association between the function coverage group and the input parameters information.
基于上述技术方案,利用第二测试用例训练样本及第二测试用例训练样本对应的第一功能覆盖信息对第二预设模型进行训练,从而挖掘出各功能覆盖组与输入参数之间的关联关系,即针对任一功能覆盖组,挖掘出影响该功能覆盖组中功能能否被测试到的重要输入参数,从而得到功能覆盖组与输入参数之间的关联信息;该关联信息可以为进一步生成测试用例地过程提供引导,以便针对性地生成能够覆盖目标功能覆盖组中功能覆盖点的测试用例,从而有效提升功能覆盖率,同时,进一步缩小了测试用例生成过程中所需探索的输入参数的取值空间,有效提高了测试效率。Based on the above technical solution, use the second test case training sample and the first function coverage information corresponding to the second test case training sample to train the second preset model, so as to dig out the relationship between each function coverage group and the input parameters , that is, for any functional coverage group, dig out the important input parameters that affect whether the function in the functional coverage group can be tested, so as to obtain the correlation information between the functional coverage group and the input parameters; the correlation information can be used for further generation of test The use case process provides guidance to generate test cases that can cover the functional coverage points in the target functional coverage group in a targeted manner, thereby effectively improving the functional coverage. The value space effectively improves the test efficiency.
根据上述第一方面的第九种可能的实现方式,在所述第一方面的第十种可能的实现方式中,所述第二预设模型包括随机森林模型;所述利用所述第二测试用例训练样本及所述第一功能覆盖信息对所述第二预设模型进行训练,得到所述功能覆盖组与输入参数之间的关联信息,包括:针对所述目标功能覆盖组,将所述第二测试用例训练样本输入到所述随机森林模型,并以所述第一功能覆盖信息作为标签,训练所述随机森林模型,得到所述功能覆盖组与输入参数之间的关联信息。According to the ninth possible implementation manner of the above first aspect, in the tenth possible implementation manner of the first aspect, the second preset model includes a random forest model; the using the second test Using case training samples and the first function coverage information to train the second preset model to obtain the association information between the function coverage group and input parameters, including: for the target function coverage group, the The second test case training sample is input into the random forest model, and the random forest model is trained with the first functional coverage information as a label to obtain the correlation information between the functional coverage group and the input parameters.
基于上述技术方案,针对任一功能覆盖组,可以以第二测试用例训练样本对应的第一功能覆盖信息作为标签,利用第二测试用例训练样本对与该功能覆盖组对应的随机森林模型进行训练,从而挖掘出该功能覆盖组与测试用例的输入参数之间的关联关系,即挖掘出影响该功能覆盖组中功能能否被测试到的重要输入参数,从而得到功能覆盖组与输入参数之间的关联信息;该关联信息可以为进一步生成测试用例地过程提供引导,以便针对性地生成能够覆盖目标功能覆盖组中功能覆盖点的测试用例,从而有效提升功能覆盖率,同时,进一步缩小了测试用例生成过程中所需探索的输入参数的取值空间,有效提高了测试效率。Based on the above technical solution, for any functional coverage group, the first functional coverage information corresponding to the second test case training sample can be used as a label, and the random forest model corresponding to the functional coverage group can be trained by using the second test case training sample , so as to dig out the correlation between the functional coverage group and the input parameters of the test cases, that is, to dig out the important input parameters that affect whether the functions in the functional coverage group can be tested, so as to obtain the relationship between the functional coverage group and the input parameters The associated information; the associated information can provide guidance for the process of further generating test cases, so as to generate targeted test cases that can cover the functional coverage points in the target functional coverage group, thereby effectively improving the functional coverage rate and further reducing the test case size. The value space of the input parameters that needs to be explored during the use case generation process effectively improves the test efficiency.
根据上述第一方面的各种可能的实现方式,在所述第一方面的第十一种可能的实现方式中,所述利用所述至少一个第一取值组合中的每一个,替代所述第一测试用例集合中的所述N个目标输入参数的一个第二取值组合,包括:针对每一第一取值组合,确定与该第一取值组合的相似度满足预设条件的第二取值组合,作为该第一取值组合的目标第二取值组合;利用该第一取值组合替代所述目标第二取值组合。According to various possible implementation manners of the first aspect above, in the eleventh possible implementation manner of the first aspect, the using each of the at least one first value combination replaces the A second value combination of the N target input parameters in the first test case set includes: for each first value combination, determining the first value combination whose similarity with the first value combination satisfies a preset condition A second value combination is used as a target second value combination of the first value combination; and the first value combination is used to replace the target second value combination.
基于上述技术方案,第二取值组合中输入参数的取值满足预设约束,将与第一取值组合的相似度满足预设约束的第二取值组合作为目标第二取值组合,从而最大程度保证生成的包含该第一取值组合的第二测试用例中输入参数的取值满足预设约束。Based on the above technical solution, the value of the input parameter in the second value combination satisfies the preset constraint, and the second value combination whose similarity with the first value combination satisfies the preset constraint is used as the target second value combination, so that It is ensured to the greatest extent that the values of the input parameters in the generated second test case containing the first value combination satisfy the preset constraints.
第二方面,本申请的实施例提供了一种芯片的测试用例生成装置,所述装置包括:传输模块,用于获取输入参数集合;所述输入参数集合包括芯片的M个输入参数,M为不小于1的整数;处理模块,用于将所述输入参数集合输入第一模型,生成第一测试用例集合;其中,第一测试用例包括:所述M个输入参数的取值,所述第一模型为利用第一测试用例训练样本训练所得到,所述第一测试用例训练样本中所述M个输入参数的取值满足预设约束。In a second aspect, an embodiment of the present application provides a device for generating test cases for a chip, the device comprising: a transmission module configured to obtain an input parameter set; the input parameter set includes M input parameters of the chip, and M is An integer not less than 1; a processing module, configured to input the input parameter set into the first model to generate a first test case set; wherein, the first test case includes: the values of the M input parameters, the first A model is obtained by training by using a first test case training sample, and values of the M input parameters in the first test case training sample satisfy preset constraints.
基于上述技术方案,第一测试用例训练样本中输入参数的取值满足预设约束,第一模型为利用第一测试用例训练样本训练所得到的模型,这样,经过训练所得到的第一模型可以学习到该预设约束,即可以从输入参数全部的取值空间中筛选出有效的取值空间,从而有效减少了生成第一测试用例的过程中所需探索的输入参数的取值空间;同时,第一模型可以自动生成输入参数的取值满足预设约束的测试用例,无需进行校正,保证了第一测试用例集合中输入参数取值的多样性,从而通过生成较小规模的第一测试用例集合,即可达到较高的功能覆盖率,有效减少了测试所需时间,有效提高了测试效率,节约了测试成本。Based on the above technical solution, the value of the input parameters in the first test case training sample satisfies the preset constraints, and the first model is a model obtained by using the first test case training sample training, so that the first model obtained after training can be After learning the preset constraint, the effective value space can be selected from all the value spaces of the input parameters, thereby effectively reducing the value space of the input parameters to be explored in the process of generating the first test case; at the same time , the first model can automatically generate test cases whose values of input parameters meet the preset constraints without correction, which ensures the diversity of values of input parameters in the first test case set, so that by generating a smaller-scale first test A collection of use cases can achieve high functional coverage, effectively reducing the time required for testing, effectively improving testing efficiency, and saving testing costs.
根据第二方面,在所述第二方面的第一种可能的实现方式中,所述处理模块,还用于:确定目标功能覆盖组,所述目标功能覆盖组包括待测试的目标功能;根据功能覆盖组与输入参数之间的关联信息,确定所述输入参数集合中与所述目标功能覆盖组相关联的N个目标输入参数,N为不大于M的正整数;其中,所述功能覆盖组与输入参数之间的关联信息为利用第二测试用例训练样本及所述第二测试用例训练样本对应的第一功能覆盖信息训练所得到;所述第二测试用例训练样本中所述M个输入参数的取值满足所述预设约束,所述第一功能覆盖信息表示各功能覆盖组中已被测试的功能和/或未被测试的功能;确定所述N个目标输入参数的至少一个第一取值组合;利用所述至少一个第一取值组合中的每一个,替代所述第一测试用例集合中的所述N个目标输入参数的一个第二取值组合,得到第二测试用例集合,其中,第二测试用例包括所述M个输入参数的取值。According to the second aspect, in the first possible implementation manner of the second aspect, the processing module is further configured to: determine a target function coverage group, where the target function coverage group includes the target function to be tested; The association information between the function coverage group and the input parameters, determine the N target input parameters associated with the target function coverage group in the input parameter set, N is a positive integer not greater than M; wherein, the function coverage The association information between the group and the input parameters is obtained by using the second test case training sample and the first function coverage information corresponding to the second test case training sample; the M in the second test case training sample The value of the input parameter satisfies the preset constraint, and the first function coverage information indicates the tested function and/or the untested function in each function coverage group; determine at least one of the N target input parameters The first value combination; using each of the at least one first value combination to replace a second value combination of the N target input parameters in the first test case set to obtain a second test A set of use cases, wherein the second test case includes the values of the M input parameters.
基于上述技术方案,第一功能覆盖信息表示各功能覆盖组中已被测试的功能和/或未被测试的功能,功能覆盖组与输入参数之间的关联信息为利用输入参数的取值满足预设约束的第二测试用例训练样本、及第二测试用例训练样本对应的第一功能覆盖信息训练所得到,功能覆盖组与输入参数之间的关联信息可以指示相关联的功能覆盖组与输入参数;进而可以根据该关联信息确定输入参数集合中与目标功能覆盖组相关联的目标输入参数,该目标输入参数即为影响目标功能覆盖组中待测试的目标功能能否被测试到的重要参数,从而进一步缩小探索输入参数的取值空间,提升了测试效率;确定目标输入参数的取值组合,并生成包含该取值组合的第二测试用例集合,进而可以针对目标功能覆盖组中待测试的目标功能进行更加高效地测试,有效提升功能覆盖率。在一些示例中,针对未覆盖的功能覆盖组,可以生成能覆盖该功能覆盖组的测试用例,从而有效提升功能覆盖率,尤其对于测试后期通常难以被覆盖的功能覆盖组具有更好的覆盖效果,减少了领域专家的人工介入,降低了测试成本,进一步提升了测试效率,有效缩小了芯片开发周期。Based on the above technical solution, the first function coverage information indicates the tested functions and/or untested functions in each function coverage group, and the association information between the function coverage group and the input parameters is that the values of the input parameters satisfy the predetermined Assuming that the training sample of the second test case constrained and the first functional coverage information corresponding to the second test case training sample are obtained through training, the association information between the functional coverage group and the input parameter can indicate the associated functional coverage group and the input parameter ; and furthermore, the target input parameter associated with the target function coverage group in the input parameter set can be determined according to the association information, and the target input parameter is an important parameter that affects whether the target function to be tested in the target function coverage group can be tested, Thereby further narrowing the value space of the exploration input parameters and improving the test efficiency; determining the value combination of the target input parameters and generating a second test case set containing the value combination, and then covering the target function coverage group to be tested The target function is tested more efficiently and the functional coverage is effectively improved. In some examples, for an uncovered functional coverage group, test cases that can cover the functional coverage group can be generated, thereby effectively improving the functional coverage rate, especially for the functional coverage group that is usually difficult to cover in the later stage of the test. Better coverage effect , reducing the manual intervention of domain experts, reducing the test cost, further improving the test efficiency, and effectively shortening the chip development cycle.
根据上述第二方面的第一种可能的实现方式,在所述第二方面的第二种可能的实现方式中,所述处理模块,还用于:根据所述N个目标输入参数的预设取值范围,随机生成多个候选取值组合;将所述多个候选取值组合中的任一取值组合作为初始迭代回合对应的取值组合;从所述多个候选取值组合中,确定当前迭代回合对应的取值组合;其中,所述当前迭代回合对应的取值组合与已确定的各迭代回合对应的取值组合的差异最大;重复执行上述确定当前 迭代回合对应的取值组合的操作,直到满足预设迭代条件;并将各迭代回合对应的取值组合作为所述至少一个第一取值组合。According to the first possible implementation of the second aspect above, in the second possible implementation of the second aspect, the processing module is further configured to: according to the preset of the N target input parameters Value range, randomly generating a plurality of candidate value combinations; using any value combination in the plurality of candidate value combinations as the value combination corresponding to the initial iteration round; from the plurality of candidate value combinations, Determine the value combination corresponding to the current iteration round; wherein, the difference between the value combination corresponding to the current iteration round and the determined value combination corresponding to each iteration round is the largest; repeat the above-mentioned determination of the value combination corresponding to the current iteration round operation until the preset iteration condition is satisfied; and the value combination corresponding to each iteration round is used as the at least one first value combination.
基于上述技术方案,考虑到对于任一目标输入参数,其对应的取值范围内可以包括较多的取值,若遍历所有的取值,生成的第一取值组合数量规模太大,因此,通过启发式策略进行采样,首先生成多个候选取值组合,进而通过多次迭代,确定每一迭代回合对应的取值组合,且每一迭代回合对应的取值组合与已确定的各迭代回合对应的取值组合的差异最大,从而保证了各迭代回合对应的取值组合中N个目标输入参数的取值更加均匀、多样;进而可以生成输入参数的取值更加均匀、多样的测试用例,在保证功能覆盖率的同时,进一步提升了测试效率。Based on the above technical solution, considering that for any target input parameter, its corresponding value range may include more values, if all the values are traversed, the number of first value combinations generated is too large, therefore, Sampling is performed through a heuristic strategy. First, multiple candidate value combinations are generated, and then through multiple iterations, the value combination corresponding to each iteration round is determined, and the value combination corresponding to each iteration round is consistent with the determined iteration rounds. The corresponding value combinations have the largest difference, thus ensuring that the values of the N target input parameters in the value combinations corresponding to each iteration round are more uniform and diverse; thus, test cases with more uniform and diverse input parameter values can be generated. While ensuring the functional coverage, the test efficiency is further improved.
根据上述第二方面的各种可能的实现方式,在所述第二方面的第三种可能的实现方式中,所述处理模块,还用于:过滤掉所述第二测试用例集合中所述M个输入参数的取值不满足所述预设约束的第二测试用例。According to various possible implementations of the second aspect above, in a third possible implementation of the second aspect, the processing module is further configured to: filter out the A second test case in which the values of the M input parameters do not satisfy the preset constraints.
基于上述技术方案,过滤掉输入参数的取值不满足预设约束的第二测试用例,从而保证第二测试用例集合中各第二测试用例的输入参数的取值均满足预设约束。Based on the above technical solution, the second test cases whose values of the input parameters do not meet the preset constraints are filtered out, so as to ensure that the values of the input parameters of each second test case in the second test case set all meet the preset constraints.
根据上述第二方面的各种可能的实现方式,在所述第二方面的第四种可能的实现方式中,所述处理模块,还用于:获取所述第一测试用例集合对应的第二功能覆盖信息,所述第二功能覆盖信息包括各功能覆盖组中未被测试的功能的个数;根据所述第一测试用例集合对应的第二功能覆盖信息,确定第一测试用例集合对应的各功能覆盖组的启发式分数,所述启发式分数与功能覆盖组中未被测试的功能的个数正相关;根据所述各功能覆盖组的启发式分数,确定所述各功能覆盖组对应的概率;基于各功能覆盖组对应的概率,确定至少一个目标功能覆盖组。According to various possible implementations of the second aspect above, in a fourth possible implementation of the second aspect, the processing module is further configured to: acquire the second test case set corresponding to the first test case set Function coverage information, the second function coverage information includes the number of untested functions in each function coverage group; according to the second function coverage information corresponding to the first test case set, determine the first test case set corresponding The heuristic score of each functional coverage group, the heuristic score is positively correlated with the number of untested functions in the functional coverage group; according to the heuristic score of each functional coverage group, it is determined that each functional coverage group corresponds to probability; at least one target function coverage group is determined based on the probability corresponding to each function coverage group.
基于上述技术方案,通过启发式策略选取目标功能覆盖组,功能覆盖组中未被测试的功能的个数越多,对应的启发式分数越高,则对应的概率越大,则越可能被选为目标功能覆盖组;即针对未被覆盖的功能覆盖组,更有可能被选为目标功能覆盖组;尤其是在测试后期,难以被覆盖的功能覆盖组更有可能被选为目标功能覆盖组,进而可以针对性地生成测试用例,从而提升功能覆盖率,减少了领域专家的人工介入,降低了测试成本,提高了测试效率。Based on the above technical solution, the target function coverage group is selected through a heuristic strategy. The more untested functions in the function coverage group, the higher the corresponding heuristic score, the greater the corresponding probability, and the more likely to be selected. is the target functional coverage group; that is, for the functional coverage group that is not covered, it is more likely to be selected as the target functional coverage group; especially in the later stage of the test, the functional coverage group that is difficult to be covered is more likely to be selected as the target functional coverage group , and then can generate test cases in a targeted manner, thereby improving functional coverage, reducing manual intervention by domain experts, reducing testing costs, and improving testing efficiency.
根据上述第二方面的第四种可能的实现方式,在所述第二方面的第五种可能的实现方式中,所述处理模块,还用于:根据所述第一测试用例集合对应的各功能覆盖组中未被测试的功能的个数,确定所述第一测试用例集合对应的未被测试的功能总数;根据所述各功能覆盖组中未被测试的功能的个数占所述未被测试的功能总数的比重,确定所述各功能覆盖组的启发式分数。According to the fourth possible implementation of the second aspect above, in the fifth possible implementation of the second aspect, the processing module is further configured to: The number of untested functions in the function coverage group determines the total number of untested functions corresponding to the first test case set; according to the number of untested functions in each function coverage group accounts for the untested The proportion of the total number of functions tested determines the heuristic score for each functional coverage group.
根据上述第二方面或各种可能的实现方式,在所述第二方面的第六种可能的实现方式中,所述处理模块,还用于:获取所述第一测试用例训练样本;利用所述第一测试用例训练样本对第一预设模型进行训练,得到所述第一模型。According to the above second aspect or various possible implementation manners, in a sixth possible implementation manner of the second aspect, the processing module is further configured to: obtain the first test case training samples; use the The first test case training sample is used to train the first preset model to obtain the first model.
基于上述技术方案,利用输入参数的取值满足预设约束的第一测试用例训练样本对第一预设模型进行训练,在训练过程中,第一预设模型可以不断学习不同输入参数之间的取值约束,从规模庞大的输入参数的取值空间中筛选出有效的取值空间,这样,训练得到的第一模型能够生成输入参数的取值满足预设约束的第一测试用例,且生成第一测试用例的过程中所需探索的输入参数的取值空间减少,避免了生成冗余或无效的测试用例,无需进行校正,保 证了第一测试用例集合中输入参数取值的多样性,从而通过生成较小规模的测试用例集合,即可达到较高的功能覆盖率,有效减少了测试所需时间,有效提高了测试效率,节约了测试成本。Based on the above technical solution, the first preset model is trained by using the first test case training sample whose value of the input parameter satisfies the preset constraint. During the training process, the first preset model can continuously learn the relationship between different input parameters. value constraints, and select an effective value space from the large-scale input parameter value space, so that the first model trained can generate the first test case whose input parameter value satisfies the preset constraint, and generates The value space of the input parameters to be explored in the process of the first test case is reduced, avoiding the generation of redundant or invalid test cases, without correction, and ensuring the diversity of the values of the input parameters in the first test case set, Therefore, by generating a smaller-scale test case set, a higher functional coverage rate can be achieved, which effectively reduces the time required for testing, effectively improves testing efficiency, and saves testing costs.
根据上述第二方面的第六种可能的实现方式,在所述第二方面的第七种可能的实现方式中,所述第一预设模型包括生成对抗网络,所述生成对抗网络包含生成器及判别器;所述处理模块,还用于:利用所述第一测试用例训练样本对所述生成对抗网络进行多轮训练;并确定每轮训练收敛时的生成器对应的测试用例不变率,所述测试用例不变率表示生成器生成的测试用例的M个输入参数中取值符合所述预设约束的输入参数的比率;将与最大测试用例不变率对应的生成器,作为所述第一模型。According to the sixth possible implementation of the second aspect above, in the seventh possible implementation of the second aspect, the first preset model includes a generative adversarial network, and the generative adversarial network includes a generator and a discriminator; the processing module is also used for: utilizing the first test case training sample to carry out multiple rounds of training to the generation confrontation network; and determining the test case invariance rate corresponding to the generator when each round of training converges , the test case invariance rate represents the ratio of the input parameters whose value meets the preset constraints among the M input parameters of the test cases generated by the generator; the generator corresponding to the maximum test case invariance rate is used as the Describe the first model.
基于上述技术方案,利用第一测试用例训练样本对生成对抗网络中的判别器和生成器进行多轮对抗训练,通过不断训练,生成器可以挖掘到不同输入参数之间潜在的取值约束,且从规模庞大的输入参数的取值空间中筛选出有效的取值空间,从而减少了生成测试用例的过程中所需探索的输入参数的取值空间。将与最大测试用例不变率对应的生成器作为第一模型,从而可以利用第一模型自动生成输入参数的取值满足预设约束的测试用例,在达到较高的功能覆盖率的同时,有效减少了所需生成的测试用例数量,提高了测试效率,节约了测试成本。Based on the above technical solution, use the first test case training sample to conduct multiple rounds of confrontation training on the discriminator and generator in the generative confrontation network. Through continuous training, the generator can tap into the potential value constraints between different input parameters, and The effective value space is selected from the value space of the large-scale input parameters, thereby reducing the value space of the input parameters to be explored in the process of generating test cases. The generator corresponding to the maximum test case invariance rate is used as the first model, so that the first model can be used to automatically generate test cases whose input parameter values meet the preset constraints, while achieving high functional coverage, effective The number of test cases that need to be generated is reduced, the test efficiency is improved, and the test cost is saved.
根据上述第二方面的第七种可能的实现方式,在所述第二方面的第八种可能的实现方式中,所述处理模块,还用于:利用收敛时的判别器,过滤掉所述第二测试用例集合中所述M个输入参数不满足所述预设约束的第二测试用例。According to the seventh possible implementation of the second aspect above, in the eighth possible implementation of the second aspect, the processing module is further configured to: filter out the A second test case in which the M input parameters do not satisfy the preset constraint in the second test case set.
根据上述第二方面的各种可能的实现方式,在所述第二方面的第九种可能的实现方式中,所述处理模块,还用于:获取所述第二测试用例训练样本及所述第二测试用例训练样本对应的第一功能覆盖信息;利用所述第二测试用例训练样本及所述第一功能覆盖信息对第二预设模型进行训练,得到所述功能覆盖组与输入参数之间的关联信息。According to various possible implementations of the second aspect above, in a ninth possible implementation of the second aspect, the processing module is further configured to: acquire the second test case training sample and the The first function coverage information corresponding to the second test case training sample; using the second test case training sample and the first function coverage information to train the second preset model to obtain the function coverage group and the input parameters related information between them.
基于上述技术方案,利用第二测试用例训练样本及第二测试用例训练样本对应的第一功能覆盖信息对第二预设模型进行训练,从而挖掘出各功能覆盖组与输入参数之间的关联关系,即针对任一功能覆盖组,挖掘出影响该功能覆盖组中功能能否被测试到的重要输入参数,从而得到功能覆盖组与输入参数之间的关联信息;该关联信息可以为进一步生成测试用例地过程提供引导,以便针对性地生成能够覆盖目标功能覆盖组中功能覆盖点的测试用例,从而有效提升功能覆盖率,同时,进一步缩小了测试用例生成过程中所需探索的输入参数的取值空间,有效提高了测试效率。Based on the above technical solution, use the second test case training sample and the first function coverage information corresponding to the second test case training sample to train the second preset model, so as to dig out the relationship between each function coverage group and the input parameters , that is, for any functional coverage group, dig out the important input parameters that affect whether the function in the functional coverage group can be tested, so as to obtain the correlation information between the functional coverage group and the input parameters; the correlation information can be used for further generation of test The use case process provides guidance to generate test cases that can cover the functional coverage points in the target functional coverage group in a targeted manner, thereby effectively improving the functional coverage. The value space effectively improves the test efficiency.
根据上述第二方面的第九种可能的实现方式,在所述第二方面的第十种可能的实现方式中,所述第二预设模型包括随机森林模型;所述处理模块,还用于:针对所述目标功能覆盖组,将所述第二测试用例训练样本输入到所述随机森林模型,并以所述第一功能覆盖信息作为标签,训练所述随机森林模型,得到所述功能覆盖组与输入参数之间的关联信息。According to the ninth possible implementation manner of the second aspect above, in the tenth possible implementation manner of the second aspect, the second preset model includes a random forest model; the processing module is further configured to : For the target functional coverage group, input the second test case training sample into the random forest model, and use the first functional coverage information as a label to train the random forest model to obtain the functional coverage Association information between groups and input parameters.
基于上述技术方案,针对任一功能覆盖组,可以以第二测试用例训练样本对应的第一功能覆盖信息作为标签,利用第二测试用例训练样本对与该功能覆盖组对应的随机森林模型进行训练,从而挖掘出该功能覆盖组与测试用例的输入参数之间的关联关系,即挖掘出影响该功能覆盖组中功能能否被测试到的重要输入参数,从而得到功能覆盖组与输入参数之间的关联信息;该关联信息可以为进一步生成测试用例地过程提供引导,以便针对性地生成能够覆盖目标功能覆盖组中功能覆盖点的测试用例,从而有效提升功能覆盖率,同时,进一步缩小 了测试用例生成过程中所需探索的输入参数的取值空间,有效提高了测试效率。Based on the above technical solution, for any functional coverage group, the first functional coverage information corresponding to the second test case training sample can be used as a label, and the random forest model corresponding to the functional coverage group can be trained by using the second test case training sample , so as to dig out the correlation between the functional coverage group and the input parameters of the test cases, that is, to dig out the important input parameters that affect whether the functions in the functional coverage group can be tested, so as to obtain the relationship between the functional coverage group and the input parameters The associated information; the associated information can provide guidance for the process of further generating test cases, so as to generate targeted test cases that can cover the functional coverage points in the target functional coverage group, thereby effectively improving the functional coverage rate and further reducing the test case size. The value space of the input parameters that needs to be explored during the use case generation process effectively improves the test efficiency.
根据上述第二方面的各种可能的实现方式,在所述第二方面的第十一种可能的实现方式中,所述处理模块,还用于:针对每一第一取值组合,确定与该第一取值组合的相似度满足预设条件的第二取值组合,作为该第一取值组合的目标第二取值组合;利用该第一取值组合替代所述目标第二取值组合。According to various possible implementation manners of the second aspect above, in the eleventh possible implementation manner of the second aspect, the processing module is further configured to: for each first value combination, determine and The second value combination whose similarity of the first value combination satisfies the preset condition is used as the target second value combination of the first value combination; use the first value combination to replace the target second value combination.
基于上述技术方案,第二取值组合中输入参数的取值满足预设约束,将与第一取值组合的相似度满足预设约束的第二取值组合作为目标第二取值组合,从而最大程度保证生成的包含该第一取值组合的第二测试用例中输入参数的取值满足预设约束。Based on the above technical solution, the value of the input parameter in the second value combination satisfies the preset constraint, and the second value combination whose similarity with the first value combination satisfies the preset constraint is used as the target second value combination, so that It is ensured to the greatest extent that the values of the input parameters in the generated second test case containing the first value combination satisfy the preset constraints.
第三方面,本申请的实施例提供了一种芯片的测试用例生成装置,包括:处理器;用于存储处理器可执行指令的存储器;其中,所述处理器被配置为执行所述指令时实现上述第一方面或者第一方面的各种可能的实现方式中的芯片的测试用例生成方法。In a third aspect, an embodiment of the present application provides a device for generating test cases for a chip, including: a processor; a memory for storing instructions executable by the processor; wherein the processor is configured to execute the instructions A method for generating test cases for a chip in the above first aspect or various possible implementation manners of the first aspect is implemented.
第四面,本申请的实施例提供了一种计算机可读存储介质,其上存储有计算机程序指令,所述计算机程序指令被处理器执行时实现上述第一方面或者第一方面的各种可能的实现方式中的芯片的测试用例生成方法。On the fourth aspect, the embodiments of the present application provide a computer-readable storage medium, on which computer program instructions are stored, and when the computer program instructions are executed by a processor, the above first aspect or various possibilities of the first aspect can be realized The test case generation method of the chip in the implementation manner.
第五方面,本申请的实施例提供了一种计算机程序产品,当所述计算机程序产品在计算机上运行时,使得所述计算机执行上述第一方面或者第一方面的各种可能的实现方式中的芯片的测试用例生成方法。In the fifth aspect, the embodiments of the present application provide a computer program product, which, when the computer program product runs on a computer, causes the computer to execute the above-mentioned first aspect or various possible implementation manners of the first aspect. A test case generation method for chips.
上述第二方面到第五方面及各种可能的实现方式的技术效果,可参见上述第一方面及第一方面的各种可能的实现方式的技术效果。For the technical effects of the above-mentioned second aspect to the fifth aspect and various possible implementation manners, refer to the above-mentioned first aspect and the technical effects of various possible implementation manners of the first aspect.
附图说明Description of drawings
包含在说明书中并且构成说明书的一部分的附图与说明书一起示出了本申请的示例性实施例、特征和方面,并且用于解释本申请的原理。The accompanying drawings, which are incorporated in and constitute a part of the specification, illustrate exemplary embodiments, features, and aspects of the application and, together with the specification, serve to explain the principles of the application.
图1示出不同环节进行芯片测试的示意图。FIG. 1 shows a schematic diagram of chip testing in different steps.
图2示出对芯片设计进行测试的场景示意图。FIG. 2 shows a schematic diagram of a scene for testing a chip design.
图3示出测试用例、功能覆盖点及功能覆盖组的关系示意图。FIG. 3 shows a schematic diagram of the relationship among test cases, functional coverage points and functional coverage groups.
图4示出了基于约束驱动的随机测试方法的流程示意图。Fig. 4 shows a schematic flow diagram of a constraint-driven random testing method.
图5示出根据本申请一实施例的一种芯片的测试用例生成方法的流程图。Fig. 5 shows a flowchart of a method for generating test cases for a chip according to an embodiment of the present application.
图6示出根据本申请一实施例的另一种芯片的测试用例生成方法的流程图。Fig. 6 shows a flow chart of another chip test case generation method according to an embodiment of the present application.
图7示出根据本申请一实施例的另一种芯片的测试用例生成方法的流程图。Fig. 7 shows a flow chart of another chip test case generation method according to an embodiment of the present application.
图8示出根据本申请一实施例的另一种芯片的测试用例生成方法的流程图。Fig. 8 shows a flow chart of another chip test case generation method according to an embodiment of the present application.
图9示出根据本申请一实施例的另一种芯片的测试用例生成方法的流程图。FIG. 9 shows a flowchart of another method for generating test cases for a chip according to an embodiment of the present application.
图10示出根据本申请一实施例的一种确定目标功能覆盖组的方法流程图。Fig. 10 shows a flowchart of a method for determining a target function coverage group according to an embodiment of the present application.
图11示出根据本申请一实施例的一种确定第一取值组合的方法流程图。Fig. 11 shows a flowchart of a method for determining a first value combination according to an embodiment of the present application.
图12示出根据本申请一实施例的另一种芯片的测试用例生成方法的流程图。Fig. 12 shows a flow chart of another chip test case generation method according to an embodiment of the present application.
图13示出根据本申请一实施例的测试结果对比图。Fig. 13 shows a comparison chart of test results according to an embodiment of the present application.
图14示出根据本申请一实施例的一种芯片的测试用例生成装置的结构图。Fig. 14 shows a structural diagram of an apparatus for generating test cases for a chip according to an embodiment of the present application.
图15示出根据本申请一实施例的一种芯片的测试用例生成装置的结构示意图。FIG. 15 shows a schematic structural diagram of a device for generating test cases for a chip according to an embodiment of the present application.
具体实施方式Detailed ways
以下将参考附图详细说明本申请的各种示例性实施例、特征和方面。附图中相同的附图标记表示功能相同或相似的元件。尽管在附图中示出了实施例的各种方面,但是除非特别指出,不必按比例绘制附图。Various exemplary embodiments, features, and aspects of the present application will be described in detail below with reference to the accompanying drawings. The same reference numbers in the figures indicate functionally identical or similar elements. While various aspects of the embodiments are shown in drawings, the drawings are not necessarily drawn to scale unless specifically indicated.
在这里专用的词“示例性”意为“用作例子、实施例或说明性”。这里作为“示例性”所说明的任何实施例不必解释为优于或好于其它实施例。The word "exemplary" is used exclusively herein to mean "serving as an example, embodiment, or illustration." Any embodiment described herein as "exemplary" is not necessarily to be construed as superior or better than other embodiments.
另外,为了更好的说明本申请,在下文的具体实施方式中给出了众多的具体细节。本领域技术人员应当理解,没有某些具体细节,本申请同样可以实施。在一些实例中,对于本领域技术人员熟知的方法、手段、元件和电路未作详细描述,以便于凸显本申请的主旨。In addition, in order to better illustrate the present application, numerous specific details are given in the following specific implementation manners. It will be understood by those skilled in the art that the present application may be practiced without certain of the specific details. In some instances, methods, means, components and circuits well known to those skilled in the art have not been described in detail in order to highlight the gist of the present application.
为了便于理解,下面首先对本申请实施例中涉及的一些概念进行介绍。For ease of understanding, the following first introduces some concepts involved in the embodiments of the present application.
1、生成对抗网络(generative adversarial networks,GAN)1. Generative adversarial networks (GAN)
生成对抗网络的基本结构包括生成器(generator)和判别器(discriminator)。受博弈论中的零和博弈启发,在训练过程中,将生成问题视作判别器和生成器这两个网络的对抗和博弈:生成器用于利用随机噪声(例如,均匀分布或者正态分布的噪声)产生合成数据,判别器用于分辨生成器的输出数据和真实数据。生成器试图产生更接近真实数据的数据,相应地,判别器试图更完美地分辨真实数据与生成器输出的数据。这样,生成对抗网络通过生成器和判别器相互博弈学习,生成器与判别器在对抗中进步,在进步后继续对抗,生成对抗网络的性能不断提升,生成器生成的数据也就越来越完美,逼近真实数据,进而可以利用生成器得到期望的数据。The basic structure of generative confrontation network includes generator and discriminator. Inspired by the zero-sum game in game theory, during the training process, the generation problem is regarded as the confrontation and game between the two networks of the discriminator and the generator: the generator is used to exploit random noise (for example, uniform distribution or normal distribution) noise) to generate synthetic data, and the discriminator is used to distinguish the output data of the generator from the real data. The generator tries to produce data that is closer to the real data, and accordingly, the discriminator tries to more perfectly distinguish the real data from the data output by the generator. In this way, the generative confrontation network learns through the mutual game between the generator and the discriminator. The generator and the discriminator progress in the confrontation, and continue to fight after the progress. The performance of the generative confrontation network continues to improve, and the data generated by the generator becomes more and more perfect. , which is close to the real data, and then the generator can be used to obtain the expected data.
2、随机森林(Random Forests,RF)2. Random Forests (RF)
随机森林是指以一定数目的决策树(Decision Tree)作为基学习器构建组成的分类模型;通过样本对各决策树进行训练得到随机森林,在利用随机森林进行分类时,每一决策树均进行分类,并可以通过投票法根据多数原则决定最终的分类结果。Random forest refers to a classification model constructed with a certain number of decision trees (Decision Tree) as the base learner; the random forest is obtained by training each decision tree through samples, and when using random forest for classification, each decision tree is Classification, and the final classification result can be determined by voting method according to the majority principle.
其中,决策树是一个树形结构,通过从根节点向下传递完成决策,决策树生成算法可以包括迭代二叉树三代(Iterative Dichotomiser 3,ID3)、C4.5(ID3算法的一个扩展)和分类回归树算法(Classification And Regression Tree,CART)等,其中,决策树的生成过程中,每一节点基于选定的最优的特征(feature)进行分裂,以使末端节点上包含的样本尽量是同一种类别。在随机森林中决策树的生成过程具有两大特点:随机选取样本集以及随机选取每一节点的特征;其中,随机选取样本集是指从原始样本集中采取有放回的抽样方式构造子样本集,子样本集的样本数量与原始样本集相同,通过每一子样本集训练出一棵决策树;与随机选取样本集类似,决策树的每一个节点分裂过程并未用到所有的特征,而是从所有的特征中随机选取一定数量的特征,之后根据评估指标从随机选取的特征中选取出最优的特征作为该节点分裂时采用的特征,其中,评估指标可以包括信息熵(Information Entropy)、信息增益(Gain Ratio)、基尼指数(Gini Index)等等。Among them, the decision tree is a tree structure, and the decision is completed by passing down from the root node. The decision tree generation algorithm can include iterative binary tree three generations (Iterative Dichotomiser 3, ID3), C4.5 (an extension of the ID3 algorithm) and classification regression Tree algorithm (Classification And Regression Tree, CART), etc., in which, during the generation of the decision tree, each node is split based on the selected optimal feature (feature), so that the samples contained on the end node are as much as possible of the same type category. The generation process of the decision tree in the random forest has two characteristics: random selection of sample sets and random selection of the characteristics of each node; among them, random selection of sample sets refers to the construction of sub-sample sets from the original sample set by sampling with replacement , the number of samples in the sub-sample set is the same as the original sample set, and a decision tree is trained through each sub-sample set; similar to randomly selected sample sets, each node splitting process of the decision tree does not use all the features, and It is to randomly select a certain number of features from all the features, and then select the optimal feature from the randomly selected features according to the evaluation index as the feature used when the node is split. Among them, the evaluation index can include Information Entropy (Information Entropy) , Gain Ratio, Gini Index, etc.
3、硬件描述语言(Hardware Description Language,HDL)3. Hardware Description Language (Hardware Description Language, HDL)
硬件描述语言是一种用形式化方法描述数字电路和系统的语言。基于这种语言,芯片开发人员可以系统地描述芯片的设计思想。常见的硬件描述语言可以包括超高速集成电路硬件描述语言(Very-High-Speed Integrated Circuit Hardware Description Language,VHDL)和Verilog硬件描述语言。A hardware description language is a language for describing digital circuits and systems in a formal way. Based on this language, chip developers can systematically describe chip design ideas. Common hardware description languages may include Very-High-Speed Integrated Circuit Hardware Description Language (VHDL) and Verilog Hardware Description Language.
4、寄存器转换级别(Register-Transfer-Level,RTL)4. Register-Transfer-Level (RTL)
寄存器转换级别是一种芯片设计的级别,在该级别下的芯片设计代码描述了芯片中的各级寄存器以及不同寄存器之间信号的转换。The register conversion level is a level of chip design, and the chip design code at this level describes the registers of all levels in the chip and the conversion of signals between different registers.
5、芯片测试5. Chip test
芯片测试贯穿于芯片设计环节及生产环节,图1示出不同环节进行芯片测试的示意图,如图1所示,在芯片设计环节,芯片测试可以包括:芯片设计阶段的芯片设计测试;在生产环节,芯片测试可以包括:在晶圆加工阶段的过程工艺测试、封装阶段的晶圆测试、在量产成品阶段的设计测试等等。Chip testing runs through the chip design and production links. Figure 1 shows a schematic diagram of chip testing in different links. As shown in Figure 1, in the chip design link, chip testing can include: chip design testing in the chip design stage; , Chip testing may include: process technology testing at the wafer processing stage, wafer testing at the packaging stage, design testing at the mass production stage, and so on.
其中,芯片设计阶段的芯片设计测试具有时间占比长、人员投入高、开销大等特点。从时间成本的角度看,在大多数芯片项目中,测试工作占据了超过60%的开发周期。开发团队花费在芯片设计测试上的时间已经超过芯片设计开发上的时间。从人力成本的角度看,芯片开发团队中的测试人员比重逐年增多,从数量上已经超越芯片设计开发人员。芯片设计的测试成本直接影响了芯片的整个开发周期。Among them, the chip design test in the chip design stage has the characteristics of long time ratio, high personnel investment, and high cost. From the perspective of time cost, in most chip projects, testing work occupies more than 60% of the development cycle. Development teams spend more time on chip design testing than chip design and development. From the perspective of labor costs, the proportion of testers in the chip development team has increased year by year, surpassing the number of chip design and development personnel. The test cost of chip design directly affects the entire development cycle of the chip.
相对于其他阶段的测试,芯片设计测试具有独特挑战,首先,与传统软件测试方法常用的结构覆盖不同,功能覆盖在芯片设计测试中起着更重要的作用。其次,由于待测芯片设计的功能众多,其输入参数的规模庞大,且不同输入参数之间包含复杂的取值约束,因此,传统软件测试方法难以对其庞大且复杂的输入参数取值空间进行高效探索。Compared with other stages of testing, chip design testing has unique challenges. First, unlike the structural coverage commonly used in traditional software testing methods, functional coverage plays a more important role in chip design testing. Secondly, due to the many functions of the chip design to be tested, the scale of its input parameters is huge, and there are complex value constraints among different input parameters, so it is difficult for traditional software testing methods to test the large and complex input parameter value space. Explore efficiently.
图2示出对芯片设计进行测试的场景示意图,如图2所示,生成测试用例,将测试用例输入到芯片仿真器中,并得到仿真结果,其中,仿真结果可以包括功能覆盖率等,若仿真结果不符合预期,则可以生成新的测试用例,并输入到上述芯片仿真器中,重复执行上述操作,直到仿真结果符合预期。Fig. 2 shows a schematic diagram of a scenario where a chip design is tested, as shown in Fig. 2, a test case is generated, the test case is input into a chip emulator, and a simulation result is obtained, wherein the simulation result may include functional coverage, etc., if If the simulation result does not meet expectations, a new test case can be generated and input to the above-mentioned chip emulator, and the above operations are repeated until the simulation result meets expectations.
5、测试用例5. Test cases
测试用例,也称测试参数用例或测试输入,是指为了对待测芯片设计进行测试,而向待测芯片设计提供的一组数据。每一测试用例可以包括多个预设输入参数及各输入参数的取值,基于输入参数的不同取值组合,对应生成多个测试用例。其中,预设输入参数为在芯片设计时设计好的参数,每一输入参数的取值在预先设计好的取值范围内。例如,如表1所示,x 1、x2…xK为K个测试用例,这K个测试用例组合了一个测试用例集合;p1、p2…pL为测试用例中包含的L个输入参数,a11、a12…aKL为测试用例中输入参数的取值,例如,测试用例x3所在行中a31、a32…a3L即为测试用例x3各输入参数的取值,其中,a32表示测试用例x3中输入参数p2的取值。对于任意两个测试用例,至少一个输入参数的取值不同。A test case, also called a test parameter use case or a test input, refers to a set of data provided to the chip design to be tested in order to test the chip design to be tested. Each test case may include multiple preset input parameters and the values of each input parameter, and multiple test cases are correspondingly generated based on different value combinations of the input parameters. Wherein, the preset input parameters are parameters designed during chip design, and the value of each input parameter is within a pre-designed value range. For example, as shown in Table 1, x1, x2...xK are K test cases, and these K test cases combine a test case set; p1, p2...pL are L input parameters contained in the test case, a11, a12...aKL are the values of the input parameters in the test case, for example, a31, a32...a3L in the row of the test case x3 are the values of the input parameters of the test case x3, where a32 represents the value of the input parameter p2 in the test case x3 value. For any two test cases, the value of at least one input parameter is different.
表1-测试用例及对应的输入参数Table 1 - Test cases and corresponding input parameters
Figure PCTCN2022143439-appb-000001
Figure PCTCN2022143439-appb-000001
6、功能覆盖率(Functional Coverage,FCOV)6. Functional Coverage (FCOV)
功能覆盖率是指待测芯片设计的功能覆盖点(Functional cover bins)被测试用例所覆盖的比率,实现高功能覆盖率是芯片设计测试的重要目标之一。Functional coverage refers to the ratio of the functional coverage bins of the chip design to be tested to be covered by test cases. Achieving high functional coverage is one of the important goals of chip design and testing.
其中,每一功能覆盖点代表待测芯片设计中的某个需要测试的功能;功能覆盖点被测试用例所覆盖表明该功能覆盖点所对应的需要测试的功能被测试到。在芯片设计测试中,可以基于需要测试的待测芯片设计的功能不同,划分出多个功能覆盖点。相近功能所对应的功能覆盖点可以组成一个功能覆盖组(Functional cover group),即一个功能覆盖组中的功能覆盖点代表了待测芯片设计中多个需要测试的相近的功能;对于任意两个功能覆盖组,所包含的功能覆盖点均不同。Wherein, each function coverage point represents a function to be tested in the chip design to be tested; the function coverage point being covered by the test case indicates that the function to be tested corresponding to the function coverage point has been tested. In the chip design test, multiple function coverage points can be divided based on the different functions of the chip design to be tested. Functional coverage points corresponding to similar functions can form a functional coverage group (Functional cover group), that is, functional coverage points in a functional coverage group represent multiple similar functions that need to be tested in the chip design to be tested; for any two A functional coverage group contains different functional coverage points.
在进行测试时,将测试用例输入到芯片仿真器后,在仿真环境中运行后可以得到对应的功能覆盖信息,如,功能覆盖组被覆盖的情况、功能覆盖点被覆盖的情况、功能覆盖率等,图3示出测试用例、功能覆盖点及功能覆盖组的关系示意图,如图3所示,功能覆盖组包括两个功能覆盖点,测试用例在待测芯片设计的仿真环境中运行后,功能覆盖组中的一个功能覆盖点被覆盖,即该功能覆盖点所对应的功能被测试到;而另一个功能覆盖点未被覆盖,即该功能覆盖点所对应的功能未被测试到;进而可以计算被测试用例覆盖的待测芯片设计的功能覆盖点数量与待测芯片设计的所有功能覆盖点数量的比值,从而得到功能覆盖率。When testing, after the test case is input into the chip emulator, the corresponding functional coverage information can be obtained after running in the simulation environment, such as the situation of the functional coverage group being covered, the situation of the functional coverage point being covered, and the functional coverage rate etc. Fig. 3 shows a schematic diagram of the relationship between a test case, a functional coverage point and a functional coverage group. As shown in Fig. 3, the functional coverage group includes two functional coverage points. After the test case runs in the simulation environment of the chip design to be tested, A functional coverage point in the functional coverage group is covered, that is, the function corresponding to the functional coverage point is tested; while another functional coverage point is not covered, that is, the function corresponding to the functional coverage point is not tested; and The ratio of the number of functional coverage points of the chip design to be tested covered by the test cases to the number of all functional coverage points of the chip design to be tested can be calculated to obtain the functional coverage.
7、基于约束驱动的随机测试方法(Constraint Driven Random,CDR)7. Constraint Driven Random (CDR)-based random testing method
基于约束驱动的随机测试方法为现阶段芯片设计测试主要采用的测试方式。该方法随机在各输入参数的取值范围内选取对应输入参数的取值,即随机生成待测芯片设计的测试用例,但随机产生的测试用例中各输入参数取值可能违反了不同输入参数之间的取值约束,无法直接应用于测试,进而使用可以求解上述不同输入参数之间的取值约束的约束求解器对随机生成的测试用例进行校正,从而得到校正后的测试用例,并利用校正后的测试用例对待测芯片设计进行测试。其中,上述不同输入参数之间的取值约束可以在芯片设计过程中预先设定;例如,芯片设计时定义输入参数a及输入参数b,其中,输入参数a的数值表示接口A的状态,a=1表示接口A打开,a=0表示接口A关闭;输入参数b的数值表示接口B的状态,b=1表示接口B打开,b=0表示接口B关闭;则设定的输入参数a与输入参数b之间的取值约束可以为:输入参数a与数去参数b的取值不能够同时为1,即设计接口A与接口B不能同时打开。再例如,芯片设计时定义输入参数c、输入参数d与输入参数e,则设定的输入参数a、输入参数b及输入参数c三者之间的取值约束可以为:输入参数c、输入参数d及输入参数e的取值之和不能大于某一数值。The random test method based on the constraint drive is the main test method used in the chip design test at the present stage. This method randomly selects the value of the corresponding input parameter within the value range of each input parameter, that is, randomly generates the test case of the chip design to be tested, but the value of each input parameter in the randomly generated test case may violate the relationship between different input parameters. The value constraints between different input parameters cannot be directly applied to the test, and then use the constraint solver that can solve the value constraints between the above different input parameters to correct the randomly generated test cases, so as to obtain the corrected test cases, and use the correction The following test cases are used to test the chip design under test. Among them, the value constraints between the above-mentioned different input parameters can be preset in the chip design process; for example, the input parameter a and the input parameter b are defined during chip design, wherein the value of the input parameter a represents the state of the interface A, and a = 1 means that interface A is open, a = 0 means that interface A is closed; the value of input parameter b indicates the state of interface B, b = 1 means that interface B is open, b = 0 means that interface B is closed; then the set input parameter a and The value constraint between the input parameter b can be: the value of the input parameter a and the number parameter b cannot be 1 at the same time, that is, the design interface A and interface B cannot be opened at the same time. For another example, if the input parameter c, input parameter d, and input parameter e are defined during chip design, the value constraints between the set input parameter a, input parameter b, and input parameter c can be: input parameter c, input The sum of the values of parameter d and input parameter e cannot be greater than a certain value.
图4示出了基于约束驱动的随机测试方法的流程示意图,如图4所示,主要流程包括:1)采用随机的方式为待测芯片设计产生大量的测试用例,从而得到测试用例集合;2)约束求解器可以自动基于芯片设计环节定义的不同输入参数之间的取值约束,对不符合该预设的约束的测试用例的输入参数取值进行修改,从而生成相比随机生成的测试用例更加满足预设的约束的测试用例集合;3)将满足不同输入参数之间的取值约束的测试用例集合输入到芯片仿真器中进行仿真,得到所覆盖的功能覆盖点数量,然后和预先定义的需要测试的功能覆盖点数量进行对比,从而得到功能覆盖率。Fig. 4 shows the schematic flow chart of the random test method based on constraint drive, as shown in Fig. 4, the main process includes: 1) adopting a random method to generate a large amount of test cases for the design of the chip to be tested, thereby obtaining a set of test cases; 2 ) The constraint solver can automatically modify the input parameter values of test cases that do not meet the preset constraints based on the value constraints between different input parameters defined in the chip design process, thereby generating test cases that are compared to random generation A test case set that more satisfies the preset constraints; 3) input the test case set that satisfies the value constraints between different input parameters into the chip emulator for simulation, obtain the number of covered function coverage points, and then compare with the pre-defined Compare the number of functional coverage points that need to be tested, so as to obtain the functional coverage.
举例来说,将上述表1所示的K个测试用例输入到约束求解器中,约束求解器对各测试用例中不符合输入参数之间的取值约束的输入参数取值进行自动修改,从而得到校正后的测试用例;表2为经过约束求解器校正后的测试用例,及各测试用例的输入参数取值。如表2 所示,x'1、x'2…x'K为经过约束求解器校正后的K个测试用例,p1、p2…pL为测试用例中包含的L个输入参数,a11、a12、a'13…aKL为测试用例中输入参数的取值,其中,a'13、a'32、a'2L等表示约束求解器所修改的输入参数的取值,例如,a'13表示约束求解器对上述表1中测试用例x1中输入参数p3的取值a13进行修改后的取值。For example, the K test cases shown in Table 1 above are input into the constraint solver, and the constraint solver automatically modifies the value of the input parameters that do not meet the value constraints between the input parameters in each test case, so that The corrected test cases are obtained; Table 2 shows the test cases corrected by the constraint solver, and the input parameter values of each test case. As shown in Table 2, x'1, x'2...x'K are the K test cases corrected by the constraint solver, p1, p2...pL are the L input parameters contained in the test cases, a11, a12, a'13...aKL is the value of the input parameter in the test case, where a'13, a'32, a'2L, etc. represent the value of the input parameter modified by the constraint solver, for example, a'13 represents the constraint solver The device modifies the value a13 of the input parameter p3 in the test case x1 in Table 1 above.
表2-经过约束求解器校正后的测试用例及对应的输入参数取值Table 2 - Test cases corrected by constraint solver and corresponding input parameter values
Figure PCTCN2022143439-appb-000002
Figure PCTCN2022143439-appb-000002
将表2所示的经过约束求解器校正后的测试用例输入到芯片仿真器中运行,从而可以得到各测试用例对应的功能覆盖信息,表3示出了测试用例及对应的功能覆盖信息,如表3所示,x'1、x'2…x'K为经过约束求解器校正后的K个测试用例,g1、g2…gR为R个功能覆盖组,b1、b2…bT为T个功能覆盖点,c11、c12…cKT为功能覆盖参数,表示对应的功能覆盖点是否被对应的测试用例所覆盖,即功能覆盖点所代表的需要测试的功能是否被测试到;例如,c12、c22、c23分别表示功能覆盖组g1中功能覆盖点b1、b2、b3是否被测试用例x'2所覆盖。示例性地,可以利用c11、c12…或cKT的不同取值区分对应的功能覆盖点已被对应的测试用例覆盖与对应功能覆盖点未被对应的测试用例覆盖;例如,c11、c12…或cKT可以取0或1,其中,取1时表示功能覆盖参数所在列对应的功能覆盖点被所在行对应的测试用例所覆盖,取0时表示功能覆盖参数所在列对应的功能覆盖点未被所在行对应的测试用例所覆盖;如c22=1,则表示功能覆盖点b2被测试用例x'2覆盖,c22=0,则表示功能覆盖点b2未被测试用例x'2覆盖。Input the test cases corrected by the constraint solver shown in Table 2 into the chip emulator to run, so that the functional coverage information corresponding to each test case can be obtained. Table 3 shows the test cases and the corresponding functional coverage information, as As shown in Table 3, x'1, x'2...x'K are K test cases corrected by the constraint solver, g1, g2...gR are R function coverage groups, b1, b2...bT are T functions Coverage points, c11, c12...cKT are function coverage parameters, indicating whether the corresponding function coverage points are covered by the corresponding test cases, that is, whether the functions that need to be tested represented by the function coverage points are tested; for example, c12, c22, c23 respectively indicates whether the functional coverage points b1, b2 and b3 in the functional coverage group g1 are covered by the test case x'2. Exemplarily, different values of c11, c12... or cKT can be used to distinguish that the corresponding function coverage point has been covered by the corresponding test case and the corresponding function coverage point has not been covered by the corresponding test case; for example, c11, c12... or cKT It can be 0 or 1. When it is 1, it means that the function coverage point corresponding to the column where the function coverage parameter is located is covered by the test case corresponding to the row. When it is 0, it means that the function coverage point corresponding to the column where the function coverage parameter is located is not covered by the row. It is covered by the corresponding test case; if c22=1, it means that the functional coverage point b2 is covered by the test case x'2, and if c22=0, it means that the functional coverage point b2 is not covered by the test case x'2.
表3-测试用例及对应的功能覆盖信息Table 3 - Test cases and corresponding functional coverage information
Figure PCTCN2022143439-appb-000003
Figure PCTCN2022143439-appb-000003
上述基于约束驱动的随机测试方法虽然能够生成满足不同输入参数之间的取值约束的测试用例,但是由于待测芯片设计通常涉及数量众多的输入参数,输入参数的取值空间规模庞大,且存在大量且复杂的不同输入参数之间的取值约束,在基于约束驱动的随机测试方法中随机生成测试用例方式并未考虑不同输入参数之间的取值约束,从而会随机产生大量冗余的甚至无效的测试用例,进而约束求解器对随机生成的测试用例中不符合要求的输入参数的取值进行了修改,其在一定程度上限制了所探索到的输入参数的取值空间,所生成的测试用例 集合中输入参数取值的多样性变差,因此,往往需要生成较大规模的测试用例集合,进行较长时间的测试,才能达到较高的功能覆盖率,测试效率较低,测试成本较高。Although the constraint-driven random testing method above can generate test cases satisfying the value constraints between different input parameters, since the design of the chip to be tested usually involves a large number of input parameters, the value space of the input parameters is huge, and there are There are a large number of complex value constraints between different input parameters. In the constraint-driven random testing method, the method of randomly generating test cases does not consider the value constraints between different input parameters, which will randomly generate a large number of redundant and even Invalid test cases, and then the constraint solver modifies the value of the input parameters that do not meet the requirements in the randomly generated test cases, which limits the value space of the input parameters explored to a certain extent, and the generated The diversity of input parameter values in the test case set becomes worse. Therefore, it is often necessary to generate a large-scale test case set and conduct a long-term test to achieve high functional coverage, low test efficiency, and low test cost. higher.
为了解决上述技术问题,本申请提供了一种芯片的测试用例生成方法。示例性地,该方法可以由处理器、服务器、服务器集群等具有数据处理能力的实体执行。在一些示例中,上述实体中还可以模拟待测芯片设计的仿真环境,从而在仿真环境中运行测试用例,并可以得到对应的仿真结果。In order to solve the above technical problems, the present application provides a method for generating test cases for a chip. Exemplarily, the method may be executed by an entity having data processing capabilities such as a processor, a server, and a server cluster. In some examples, the above entities can also simulate the simulation environment of the chip design to be tested, so that the test cases can be run in the simulation environment and corresponding simulation results can be obtained.
图5示出根据本申请一实施例的一种芯片的测试用例生成方法的流程图。如图5所示,该方法可以包括以下步骤:Fig. 5 shows a flowchart of a method for generating test cases for a chip according to an embodiment of the present application. As shown in Figure 5, the method may include the following steps:
步骤501、获取输入参数集合。 Step 501. Obtain an input parameter set.
其中,输入参数集合包括芯片的M个输入参数,M为不小于1的整数。Wherein, the input parameter set includes M input parameters of the chip, and M is an integer not less than 1.
示例性地,芯片可以为待测芯片设计;例如,可以为终端设备的系统级芯片(System on Chip,SOC)、服务器芯片、人工智能芯片、通信基站芯片、通信终端芯片或者其他专用芯片等等各种类型的待测芯片设计,对此不作限定。Exemplarily, the chip can be designed for the chip to be tested; for example, it can be a system-on-chip (System on Chip, SOC) of a terminal device, a server chip, an artificial intelligence chip, a communication base station chip, a communication terminal chip or other dedicated chips, etc. Various types of chip designs to be tested are not limited.
示例性地,输入参数集合可以包括在芯片设计阶段预先定义好的待测芯片设计的输入参数,例如,输入参数集合可以包括上述表1中的输入参数p1、p2…pL。Exemplarily, the input parameter set may include predefined input parameters of the chip design to be tested in the chip design stage, for example, the input parameter set may include the input parameters p1, p2 . . . pL in Table 1 above.
示例性地,还可以获取输入参数集合中各输入参数对应的取值范围,可以理解的是,各输入参数对应的取值范围可以在芯片设计时预先设定。Exemplarily, the value range corresponding to each input parameter in the input parameter set may also be acquired. It can be understood that the value range corresponding to each input parameter may be preset during chip design.
步骤502、将输入参数集合输入第一模型,生成第一测试用例集合。Step 502: Input the input parameter set into the first model to generate the first test case set.
其中,第一测试用例包括:上述M个输入参数的取值,第一模型为利用第一测试用例训练样本训练所得到,第一测试用例训练样本中M个输入参数的取值满足预设约束。Wherein, the first test case includes: the values of the above M input parameters, the first model is obtained by using the training samples of the first test case, and the values of the M input parameters in the training samples of the first test case satisfy the preset constraints .
示例性地,预设约束可以包括M个输入参数中任意两个或多个输入参数之间的取值约束,可以理解的是,该M个输入参数中任意两个或多个输入参数之间的取值约束可以在芯片设计时预先设定。Exemplarily, the preset constraints may include value constraints between any two or more input parameters among the M input parameters. It can be understood that between any two or more input parameters among the M input parameters The value constraints of can be preset during chip design.
其中,第一测试用例训练样本可以为预先生成的测试用例;第一测试用例训练样本中包括上述输入参数集合中M个输入参数,且该M个输入参数的取值满足预设约束;示例性地,第一测试用例训练样本可以包括采用基于约束驱动的随机测试方法所生成的测试用例;例如,可以包括上述表2中测试用例x'1、x'2…或x'K。Wherein, the first test case training sample can be a pre-generated test case; the first test case training sample includes M input parameters in the above input parameter set, and the values of the M input parameters meet the preset constraints; exemplary Specifically, the first test case training samples may include test cases generated by using a constraint-driven random testing method; for example, they may include test cases x'1, x'2... or x'K in Table 2 above.
该步骤中,第一模型为利用第一测试用例训练样本训练所得到的模型,这样,第一模型可以学习到不同输入参数之间的取值约束,将输入参数集合输入到第一模型,第一模型可以自动生成输入参数的取值满足预设约束的一个或多个第一测试用例,即第一测试用例集合。示例性地,第一模型可以包括生成对抗网络的生成器,例如,可以包括GAN、瓦瑟斯坦生成对抗网络(Wasserstein GAN,WGAN)、瓦瑟斯坦生成对抗网络-梯度约束(Wasserstein GAN-gradient penalty,WGAN-GP)、互信息生成对抗网络(I nfoGAN)的生成器,还可以包括变分自编码器(Variational Autoencoder,VAE)、条件式变换自编码器(Conditional Variational Autoencoders,CVAE)以及其他类似的模型,对此不作限定。In this step, the first model is a model obtained by using the first test case training sample training, so that the first model can learn the value constraints between different input parameters, and input the input parameter set to the first model, the second A model can automatically generate one or more first test cases whose values of input parameters meet preset constraints, that is, a set of first test cases. Exemplarily, the first model may include a generator that generates an adversarial network, for example, may include GAN, Wasserstein GAN (Wasserstein GAN, WGAN), Wasserstein GAN-gradient penalty (Wasserstein GAN-gradient penalty , WGAN-GP), the generator of mutual information generation confrontation network (InfoGAN), and can also include variational autoencoder (Variational Autoencoder, VAE), conditional transformation autoencoder (Conditional Variational Autoencoders, CVAE) and other similar model, which is not limited.
示例性地,可以将该M个输入参数及各输入参数对应的取值范围输入到第一模型,从而利用第一模型自动生成一个或多个测试用例,每一测试用例均包括该M个输入参数的取值,各输入参数的取值均在对应的预设取值范围内,且M个输入参数的取值满足预设约束。Exemplarily, the M input parameters and the value range corresponding to each input parameter may be input into the first model, so that one or more test cases are automatically generated by using the first model, and each test case includes the M input The value of the parameter, the value of each input parameter is within the corresponding preset value range, and the values of the M input parameters meet the preset constraints.
进一步的,可以将生成的第一测试用例集合输入到芯片仿真器中运行,从而得到对应的 功率覆盖率。示例性地,可以获取预设的功能覆盖点数量,并获取第一测试用例集合在仿真环境中运行后所覆盖的功能覆盖点的数量,进而计算所覆盖的功能覆盖点的数量与预设的功能覆盖点数量的比值,得到第一测试用例集合对应的功率覆盖率。由于待测芯片设计通常涉及数量众多的输入参数,且每一输入参数取值范围通常较大,从而造成输入参数的取值空间规模庞大,此外,还存在大量且复杂的不同输入参数之间的取值约束;该步骤中第一模型学习到了不同输入参数之间的取值约束,即从规模庞大的输入参数的取值空间中筛选出有效的取值空间,从而减少了第一模型生成第一测试用例的过程中所需探索的输入参数的取值空间;同时,由于第一模型生成的第一测试用例的输入参数的取值满足预设约束,无需进行校正,保证了测试用例集合中输入参数取值的多样性,从而可以覆盖更多的功能覆盖点,这样,通过生成较小规模的测试用例集合,花费更少的测试时间,即可达到较高的功能覆盖率,有效提高了测试效率。相对于基于约束驱动的随机测试方法中随机生成测试用例的方式,在达到相同的功能覆盖率的情况下,有效减少了所需测试用例的数量。Further, the generated first test case set can be input into the chip emulator to run, so as to obtain the corresponding power coverage. Exemplarily, the preset number of function coverage points can be obtained, and the number of function coverage points covered by the first test case set running in the simulation environment can be obtained, and then the difference between the number of covered function coverage points and the preset number of function coverage points can be calculated. The ratio of the number of functional coverage points is used to obtain the power coverage rate corresponding to the first test case set. Since the design of the chip to be tested usually involves a large number of input parameters, and the value range of each input parameter is usually large, resulting in a large scale of the value space of the input parameters, in addition, there are a large number of complex differences between different input parameters. Value constraints; in this step, the first model learns the value constraints between different input parameters, that is, the effective value space is selected from the value space of the large-scale input parameters, thereby reducing the number of first model generation. The value space of the input parameters that needs to be explored in the process of a test case; at the same time, since the value of the input parameters of the first test case generated by the first model meets the preset constraints, no correction is required, ensuring that the test case set The diversity of input parameter values can cover more functional coverage points. In this way, by generating a smaller test case set and spending less testing time, a higher functional coverage rate can be achieved, which effectively improves the Test efficiency. Compared with the method of randomly generating test cases in the constraint-driven random testing method, the number of required test cases is effectively reduced while achieving the same functional coverage.
示例性地,可以重复执行将输入参数集合输入第一模型,生成第一测试用例集合的操作,直到满足预设的停止条件;例如,停止条件可以包括累积生成的测试用例的数量超过第一预设值或者功能覆盖率超过第二预设值等等。其中,第一预设值、第二预设值可以根据测试需求进行设定,对此不作限定。作为一个示例,每执行一次将输入参数集合输入第一模型的操作后,第一模型可以自动生成预设数量的第一测试用例,计算第一模型累积生成的第一测试用例数量,并与第一预设值进行比较,若累积生成的第一测试用例数量超多第一预设值,则停止上述将输入参数集合输入第一模型的操作。作为另一个示例,每执行一次将输入参数集合输入第一模型的操作后,第一模型可以自动生成预设数量的第一测试用例,第一测试用例集合中所包含的第一测试用例的数量不断增加,相应的功能覆盖率随之增加,将功能覆盖率与第二预设值进行比较,若功能覆盖率超过该第二预设值,则停止上述将输入参数集合输入第一模型的操作,从而完成测试。Exemplarily, the operation of inputting the input parameter set into the first model and generating the first test case set may be repeatedly performed until a preset stop condition is satisfied; for example, the stop condition may include that the number of cumulatively generated test cases exceeds the first preset The set value or the function coverage exceeds the second preset value and so on. Wherein, the first preset value and the second preset value can be set according to the test requirement, which is not limited. As an example, after each operation of inputting the input parameter set into the first model, the first model can automatically generate a preset number of first test cases, calculate the cumulative number of first test cases generated by the first model, and compare them with the first A preset value is compared, and if the accumulatively generated number of first test cases exceeds the first preset value, the above operation of inputting the input parameter set into the first model is stopped. As another example, after each operation of inputting the input parameter set into the first model, the first model can automatically generate a preset number of first test cases, and the number of first test cases contained in the first test case set If the function coverage rate exceeds the second preset value, the above operation of inputting the input parameter set into the first model is stopped , thus completing the test.
本申请实施例中,第一测试用例训练样本中输入参数的取值满足预设约束,第一模型为利用第一测试用例训练样本训练所得到的模型,这样,经过训练所得到的第一模型可以学习到该预设约束,即可以从输入参数全部的取值空间中筛选出有效的取值空间,从而有效减少了生成第一测试用例的过程中所需探索的输入参数的取值空间;同时,第一模型可以自动生成输入参数的取值满足预设约束的测试用例,无需进行校正,保证了第一测试用例集合中输入参数取值的多样性,从而通过生成较小规模的第一测试用例集合,即可达到较高的功能覆盖率,有效减少了测试所需时间,有效提高了测试效率,节约了测试成本。In the embodiment of the present application, the value of the input parameter in the first test case training sample satisfies the preset constraints, and the first model is a model obtained by using the first test case training sample training. In this way, the first model obtained after training The preset constraint can be learned, that is, the effective value space can be selected from all the value spaces of the input parameters, thereby effectively reducing the value space of the input parameters to be explored in the process of generating the first test case; At the same time, the first model can automatically generate test cases whose input parameters meet the preset constraints without correction, which ensures the diversity of input parameter values in the first test case set, so that by generating smaller-scale first A collection of test cases can achieve high functional coverage, effectively reducing the time required for testing, effectively improving testing efficiency, and saving testing costs.
下面对利用第一测试用例训练样本训练得到第一模型的方式进行示例性地说明。The manner of obtaining the first model through training by using the training sample of the first test case is exemplarily described below.
图6示出根据本申请一实施例的另一种芯片的测试用例生成方法的流程图。如图6所示,该方法可以包括以下步骤:Fig. 6 shows a flow chart of another chip test case generation method according to an embodiment of the present application. As shown in Figure 6, the method may include the following steps:
步骤601、获取第一测试用例训练样本。 Step 601. Obtain a training sample of a first test case.
其中,第一测试用例训练样本具体说明可参照前文相关表述,此处不再赘述。Wherein, for the specific description of the first test case training samples, reference may be made to the relevant expressions above, and details will not be repeated here.
示例性地,可以根据输入参数集合中,采用随机方式生成预设数量的测试用例,例如,可以采用随机方式生成小批量的测试用例,进而将上述随机生成的测试用例输入到约束求解器中,约束求解器可以对不满足预设约束的随机生成的测试用例中输入参数的取值进行修改,从而得到预设数量的输入参数取值满足预设约束的测试用例,即测试用例训练样本集合,第 一测试用例训练样本即为该测试用例训练样本集合中的任一个。其中,上述预设数量可以根据需求进行设置,对此不作限定。Exemplarily, according to the set of input parameters, a preset number of test cases can be randomly generated, for example, a small batch of test cases can be generated randomly, and then the above randomly generated test cases can be input into the constraint solver, The constraint solver can modify the value of the input parameters in the randomly generated test cases that do not meet the preset constraints, so as to obtain a preset number of test cases whose input parameter values meet the preset constraints, that is, the test case training sample set, The first test case training sample is any one in the test case training sample set. Wherein, the above-mentioned preset quantity can be set according to requirements, which is not limited.
步骤602、利用第一测试用例训练样本对第一预设模型进行训练,得到第一模型。Step 602: Using the training sample of the first test case to train the first preset model to obtain the first model.
示例性地,第一预设模型可以包括生成对抗网络,生成对抗网络包含生成器及判别器;例如,第一预设模型可以为GAN、WGAN、WGAN-GP,InfoGAN,Variational Autoencoder,Conditional Variational Autoencoders等等,对此不作限定。Exemplarily, the first preset model may include a generation confrontation network, and the generation confrontation network includes a generator and a discriminator; for example, the first preset model may be GAN, WGAN, WGAN-GP, InfoGAN, Variational Autoencoder, Conditional Variational Autoencoders Wait, no limit on this.
该步骤中,可以采用常规训练方式,利用上述获取的第一测试用例训练样本对第一预设模型进行训练,从而得到训练后的模型,即第一模型。In this step, a conventional training method may be used to train the first preset model by using the first test case training samples obtained above, so as to obtain a trained model, that is, the first model.
作为一个示例,上述步骤601及602可以在上述步骤501之前执行。作为另一个示例,在上述步骤502中,通过重复执行将输入参数集合输入第一模型的操作,生成第一测试用例集合的情况下,可以在执行完一次或多次操作后,利用新生成的第一测试用例对第一模型进行训练,从而进一步提高第一模型的性能。As an example, the above steps 601 and 602 may be performed before the above step 501 . As another example, in the above-mentioned step 502, when the first test case set is generated by repeatedly performing the operation of inputting the input parameter set into the first model, after performing one or more operations, the newly generated The first test case trains the first model, so as to further improve the performance of the first model.
这样,利用输入参数的取值满足预设约束的第一测试用例训练样本对第一预设模型进行训练,在训练过程中,第一预设模型可以不断学习不同输入参数之间的取值约束,在一些示例中,第一预设模型可以不断学习约束求解器对随机生成的测试用例中输入参数取值的调整,从规模庞大的输入参数的取值空间中筛选出有效的取值空间,这样,训练得到的第一模型能够生成输入参数的取值满足预设约束的第一测试用例,且生成第一测试用例的过程中所需探索的输入参数的取值空间减少,从而避免了生成冗余或无效的测试用例,无需进行校正,保证了第一测试用例集合中输入参数取值的多样性,从而可以覆盖更多的功能覆盖点,这样,通过生成较小规模的第一测试用例集合,即可达到较高的功能覆盖率,有效减少了测试所需时间,有效提高了测试效率,节约了测试成本。In this way, the first preset model is trained by using the first test case training samples whose input parameter values meet the preset constraints. During the training process, the first preset model can continuously learn the value constraints between different input parameters. , in some examples, the first preset model can continuously learn the adjustment of the input parameter values in the randomly generated test cases by the constraint solver, and select an effective value space from the large-scale input parameter value space, In this way, the trained first model can generate the first test case whose input parameter values meet the preset constraints, and the value space of the input parameters to be explored in the process of generating the first test case is reduced, thus avoiding the need to generate Redundant or invalid test cases do not need to be corrected, which ensures the diversity of input parameter values in the first test case set, so that more functional coverage points can be covered. In this way, by generating a smaller-scale first test case Aggregation can achieve high functional coverage, effectively reducing the time required for testing, effectively improving testing efficiency, and saving testing costs.
下面以第一预设模型为生成对抗网络为例,对上述步骤602中,利用第一测试用例训练样本对第一预设模型进行训练,得到第一模型的过程进行详细介绍。Taking the first preset model as an example of generating an adversarial network, the process of using the first test case training sample to train the first preset model in the above step 602 to obtain the first model will be described in detail below.
图7示出根据本申请一实施例的另一种芯片的测试用例生成方法的流程图。如图7所示,该方法可以包括以下步骤:Fig. 7 shows a flow chart of another chip test case generation method according to an embodiment of the present application. As shown in Figure 7, the method may include the following steps:
步骤701、利用第一测试用例训练样本对生成对抗网络进行多轮训练;并确定每轮训练收敛时的生成器对应的测试用例不变率。 Step 701 , using the first test case training sample to perform multiple rounds of training on the GAN; and determine the test case invariance rate corresponding to the generator when each round of training converges.
其中,测试用例不变率表示生成器生成的测试用例的M个输入参数中取值符合预设约束的输入参数的比率。示例性地,可以通过约束求解器,确定测试用例不变率;将生成器生成的测试用例输入到约束求解器中,约束求解器会对不满足预设约束的输入参数的取值进行修改,这样,测试用例的M个输入参数中取值未被修改的输入参数即为满足预设约束的输入参数,从而可以求取测试用例不变率。Among them, the test case invariance rate indicates the ratio of the input parameters whose values meet the preset constraints among the M input parameters of the test cases generated by the generator. Exemplarily, the test case invariance rate can be determined through the constraint solver; the test case generated by the generator is input into the constraint solver, and the constraint solver will modify the values of the input parameters that do not satisfy the preset constraints, In this way, the input parameter whose value has not been modified among the M input parameters of the test case is the input parameter that satisfies the preset constraint, so that the invariance rate of the test case can be obtained.
在一种可能的实现方式中,在每一轮训练中,可以将输入参数集合及各输入参数的取值范围输入到生成器中,生成目标测试用例;将目标测试用例及第一测试用例训练样本,输入到判别器中,得到目标测试用例与第一训练测试用例的相似度;根据相似度,得到损失函数值;进行根据损失函数值进行反向传播,训练生成器及判别器,直至达到收敛。进而,可以将收敛时生成器所生成的目标测试用例,输入到约束求解器中,约束求解器可以对该目标测试用例中不满足预设约束的输入参数取值进行修改;从而可以得到该目标测试用例在经过约束求解器前后取值没有被修改的输入参数数量,计算该数量与所有输入参数总数的比值,即 为本轮训练收敛时的生成器对应的测试用例不变率。可以理解的是,生成器对应的测试用例不变率越高表明生成器所生成的测试用例中取值满足预设约束的输入参数越多,即生成器的性能越好。In a possible implementation, in each round of training, the input parameter set and the value range of each input parameter can be input into the generator to generate the target test case; the target test case and the first test case are trained The sample is input into the discriminator to obtain the similarity between the target test case and the first training test case; according to the similarity, the loss function value is obtained; the backpropagation is performed according to the loss function value, and the generator and the discriminator are trained until reaching convergence. Furthermore, the target test case generated by the generator at the time of convergence can be input into the constraint solver, and the constraint solver can modify the value of the input parameters in the target test case that do not meet the preset constraints; thus the target can be obtained The test case takes the number of input parameters whose value has not been modified before and after the constraint solver, and calculates the ratio of the number to the total number of all input parameters, which is the test case invariance rate corresponding to the generator when the current round of training converges. It can be understood that the higher the test case invariance rate corresponding to the generator, the more input parameters whose values satisfy the preset constraints in the test cases generated by the generator, that is, the better the performance of the generator.
步骤702、将与最大测试用例不变率对应的生成器,作为第一模型。 Step 702, taking the generator corresponding to the maximum test case invariance rate as the first model.
示例性地,在上述每轮训练得到的生成器对应的测试用例不变率中,选取出最大测试用例不变率,可以理解的是,相对于其他轮训练得到的生成器,与最大测试用例不变率对应的生成器,可以更好地生成输入参数的取值满足预设约束的测试用例,该生成器更好地学习到了输入参数之间的取值约束,因此,将与最大测试用例不变率对应生成器作为第一模型,以用于生成输入参数的取值满足预设约束的测试用例。Exemplarily, in the test case invariance rate corresponding to the generator obtained in each round of training above, the maximum test case invariance rate is selected. It can be understood that, compared with the generator obtained in other rounds of training, the maximum test case rate The generator corresponding to the invariant rate can better generate test cases whose values of input parameters meet the preset constraints. The invariant rate corresponds to the generator as the first model, which is used to generate test cases whose values of input parameters satisfy preset constraints.
本申请实施例,利用第一测试用例训练样本对生成对抗网络中的判别器和生成器进行多轮对抗训练,在训练过程中,生成器的更新目标是生成的目标测试用例能够骗过判别器,以被识别为与相应的第一测试用例样本相同,判别器的更新目标是能够将生成器生成的目标测试用例识别出来;通过不断训练,生成器和判别器的能力越来越强,生成器可以挖掘到不同输入参数之间潜在的取值约束,从规模庞大的输入参数的取值空间中筛选出有效的取值空间,从而减少了生成测试用例的过程中所需探索的输入参数的取值空间。这样,利用第一测试用例训练样本对生成对抗网络进行多轮训练,实现了挖掘不同输入参数之间潜在的取值约束,并将与最大测试用例不变率对应的生成器作为第一模型,从而可以利用第一模型自动生成输入参数的取值满足预设约束的测试用例,在达到较高的功能覆盖率的同时,有效减少了所需生成的测试用例数量,提高了测试效率,节约了测试成本。In the embodiment of the present application, using the first test case training samples to conduct multiple rounds of confrontation training on the discriminator and generator in the generative adversarial network, during the training process, the update target of the generator is that the generated target test case can fool the discriminator , so as to be identified as the same as the corresponding first test case sample, the discriminator’s update goal is to be able to identify the target test case generated by the generator; through continuous training, the capabilities of the generator and the discriminator are getting stronger and stronger, generating The detector can mine the potential value constraints between different input parameters, and filter out the effective value space from the large-scale input parameter value space, thereby reducing the number of input parameters that need to be explored in the process of generating test cases. value space. In this way, using the first test case training samples to conduct multiple rounds of training on the generative adversarial network, the potential value constraints between different input parameters are mined, and the generator corresponding to the maximum test case invariance rate is used as the first model. Therefore, the first model can be used to automatically generate test cases whose values of input parameters meet the preset constraints. While achieving high functional coverage, it effectively reduces the number of test cases to be generated, improves test efficiency, and saves cost of testing.
进一步地,由于待测芯片设计的复杂性,基于约束驱动的随机测试方法中约束求解器对于输入参数的取值进行修改的方式是未知的,因此,约束求解器难以针对未覆盖的功能覆盖点生成对应的测试用例;在测试后期通常依然存在许多难以被覆盖的功能覆盖点,对于这些难以被覆盖的功能覆盖点,往往需要领域专家的介入,通过人工设计相关的测试用例进行测试,这会消耗大量的时间,从而大幅增加了测试成本,降低了测试效率,影响了芯片开发周期。Furthermore, due to the complexity of the chip design to be tested, the way the constraint solver modifies the value of the input parameters in the constraint-driven random testing method is unknown. Therefore, it is difficult for the constraint solver to target the uncovered functional coverage points. Generate corresponding test cases; there are usually many functional coverage points that are difficult to be covered in the later stage of the test. For these functional coverage points that are difficult to be covered, domain experts are often required to test by manually designing related test cases. It consumes a lot of time, thereby greatly increasing the test cost, reducing the test efficiency, and affecting the chip development cycle.
为此,本申请实施例在上述获取输入参数的取值满足预设约束的第一测试用例基础上,通过目标功能覆盖组与输入参数之间的关联信息,进一步缩小探索输入参数的取值空间,从而生成能够有效测试目标功能覆盖组中未测试功能的测试用例,提升功能覆盖率。For this reason, the embodiment of the present application further narrows the value space for exploring the input parameters through the correlation information between the target function coverage group and the input parameters on the basis of the above-mentioned first test case where the value of the input parameter satisfies the preset constraints. , so as to generate test cases that can effectively test the untested functions in the target functional coverage group, and improve the functional coverage.
图8示出根据本申请一实施例的另一种芯片的测试用例生成方法的流程图。如图8所示,该方法可以包括以下步骤:Fig. 8 shows a flow chart of another chip test case generation method according to an embodiment of the present application. As shown in Figure 8, the method may include the following steps:
步骤801、获取输入参数集合。 Step 801. Obtain an input parameter set.
该步骤的具体说明可参照上述步骤501中相关表述,此处不再赘述。For a specific description of this step, reference may be made to relevant expressions in the above-mentioned step 501, which will not be repeated here.
步骤802、将输入参数集合输入第一模型,生成第一测试用例集合。Step 802: Input the input parameter set into the first model to generate the first test case set.
该步骤的具体说明可参照上述步骤502中相关表述,此处不再赘述。For a specific description of this step, reference may be made to relevant expressions in the above-mentioned step 502, which will not be repeated here.
步骤803、确定目标功能覆盖组。 Step 803, determine the target function coverage group.
其中,目标功能覆盖组包括待测试的目标功能。示例性地,目标功能覆盖组可以为预设的功能覆盖组中的任一个;例如,目标功能覆盖组可以为上述表3中g1、g2…或gR;目标功能即为目标功能覆盖组中所包含的功能覆盖点所代表的需要测试的功能。Wherein, the target function coverage group includes the target function to be tested. Exemplarily, the target function coverage group can be any one of the preset function coverage groups; for example, the target function coverage group can be g1, g2... or gR in the above table 3; the target function is the target function coverage group The functionality that needs to be tested is represented by the included functional coverage points.
步骤804、根据功能覆盖组与输入参数之间的关联信息,确定输入参数集合中与目标功 能覆盖组相关联的N个目标输入参数,N为不大于M的正整数。其中,功能覆盖组与输入参数之间的关联信息为利用第二测试用例训练样本及第二测试用例训练样本对应的第一功能覆盖信息训练所得到。 Step 804. Determine N target input parameters associated with the target function coverage group in the input parameter set according to the association information between the function coverage group and the input parameters, where N is a positive integer not greater than M. Wherein, the association information between the functional coverage group and the input parameters is obtained through training using the second test case training samples and the first functional coverage information corresponding to the second test case training samples.
第二测试用例训练样本中M个输入参数的取值满足预设约束;第二测试用例训练样本可以为预先生成的测试用例;示例性地,第二测试用例训练样本可以与上述第一测试用例训练样本相同。The values of the M input parameters in the second test case training sample meet the preset constraints; the second test case training sample can be a pre-generated test case; illustratively, the second test case training sample can be the same as the above-mentioned first test case The training samples are the same.
第一功能覆盖信息表示各功能覆盖组中已被测试的功能和/或未被测试的功能。第二测试用例训练样本对应的第一功能覆盖信息可以包括目标功能覆盖组中已被第二测试用例训练样本测试到的功能和/或目标功能覆盖组中未被第二测试用例训练样本测试到的功能。其中,功能覆盖组中已被测试的功能即为该功能覆盖组中被第二测试用例训练样本所覆盖的功能覆盖点所代表的需要测试的功能,功能覆盖组中未被测试的功能即为该功能覆盖组中未被第二测试用例训练样本所覆盖的功能覆盖点所代表的需要测试的功能。示例性地,第一功能覆盖信息可以包括上述表3中功能覆盖参数c11、c12…cKT的取值;例如,若表3中测试用例x'2为第二测试用例训练样本,则对应的第一功能覆盖信息可以包括功能覆盖组g1对应的功能覆盖参数c12、c22、c23的取值,功能覆盖组g2对应的功能覆盖参数c24、c25、c26、c27的取值…等R个功能覆盖组对应的功能覆盖参数的取值。The first function coverage information indicates tested functions and/or untested functions in each function coverage group. The first function coverage information corresponding to the second test case training sample can include the functions that have been tested by the second test case training sample in the target function coverage group and/or the functions that have not been tested by the second test case training sample in the target function coverage group function. Among them, the tested functions in the functional coverage group are the functions to be tested represented by the functional coverage points covered by the second test case training sample in the functional coverage group, and the untested functions in the functional coverage group are Functions that need to be tested are represented by functional coverage points in the functional coverage group that are not covered by the training samples of the second test case. Exemplarily, the first functional coverage information may include the values of the functional coverage parameters c11, c12...cKT in Table 3 above; for example, if the test case x'2 in Table 3 is the second test case training sample, then the corresponding first A function coverage information may include the values of the function coverage parameters c12, c22, c23 corresponding to the function coverage group g1, the values of the function coverage parameters c24, c25, c26, c27 corresponding to the function coverage group g2, etc. R function coverage groups The corresponding function overrides the value of the parameter.
功能覆盖组与输入参数之间的关联信息可以指示相关联的功能覆盖组与输入参数,对于任一功能覆盖组,若一个输入参数对该功能覆盖组所包含的功能覆盖点被覆盖情况有影响或影响较大,则认为该功能覆盖组与该输入参数存在关联,否则,该功能覆盖组与该输入参数不存在关联。可以理解的是,任一功能覆盖组可以与一个或多个输入参数相关联;任一输入参数也可以与一个或多个功能覆盖组相关联。The association information between the functional coverage group and the input parameters can indicate the associated functional coverage group and input parameters. For any functional coverage group, if an input parameter has an impact on the coverage of the functional coverage points contained in the functional coverage group or the impact is relatively large, it is considered that the functional coverage group is associated with the input parameter; otherwise, the functional coverage group is not associated with the input parameter. It can be understood that any functional coverage group can be associated with one or more input parameters; any input parameter can also be associated with one or more functional coverage groups.
该步骤,功能覆盖组与输入参数之间的关联信息为利用输入参数的取值满足预设约束的第二测试用例训练样本、及第二测试用例训练样本对应的第一功能覆盖信息训练,所挖掘出的各功能覆盖组与输入参数之间的关联信息;进而根据该关联信息确定输入参数集合中与目标功能覆盖组相关联目标输入参数,该目标输入参数即为影响目标功能覆盖组所包含的功能覆盖点是否被覆盖的重要参数,即影响目标功能覆盖组中待测试的目标功能能否被测试到的重要参数。In this step, the association information between the functional coverage group and the input parameters is the training of the second test case training sample using the value of the input parameter to meet the preset constraints, and the first functional coverage information corresponding to the second test case training sample, so The association information between each function coverage group and the input parameters is excavated; and then according to the association information, the target input parameters associated with the target function coverage group in the input parameter set are determined, and the target input parameters are the factors that affect the target function coverage group. An important parameter of whether the functional coverage point of is covered, that is, an important parameter that affects whether the target function to be tested in the target functional coverage group can be tested.
步骤805、确定N个目标输入参数的至少一个第一取值组合。 Step 805. Determine at least one first value combination of N target input parameters.
其中,第一取值组合中包含N个目标输入参数的取值。示例性地,可以根据各目标输入参数对应的取值范围,确定多个第一取值组合,在任意两个第一取值组合中至少一个目标输入参数的取值不同。Wherein, the first value combination includes values of N target input parameters. Exemplarily, multiple first value combinations may be determined according to the value range corresponding to each target input parameter, and at least one target input parameter has a different value in any two first value combinations.
由于目标输入参数与目标功能覆盖组相关联,即目标输入参数对目标功能覆盖组中待测试的目标功能能否被测试到有影响,因此,可以确定一定数量的第一取值组合,以使目标输入参数的取值尽量多样化,从而在提升功能覆盖率的同时,有效提升测试效率;示例性地,可以遍布各目标输入参数的取值范围内的所有取值,从而生成多个第一取值组合。Since the target input parameter is associated with the target function coverage group, that is, the target input parameter has an impact on whether the target function to be tested in the target function coverage group can be tested, therefore, a certain number of first value combinations can be determined, so that The values of the target input parameters are as diverse as possible, so as to effectively improve the test efficiency while improving the functional coverage; for example, all the values in the value range of each target input parameter can be distributed, so as to generate multiple first Combination of values.
步骤806、利用至少一个第一取值组合中的每一个,替代第一测试用例集合中的N个目标输入参数的一个第二取值组合,得到第二测试用例集合;其中,第二测试用例包括M个输入参数的取值。 Step 806, using each of at least one first value combination to replace a second value combination of N target input parameters in the first test case set to obtain a second test case set; wherein, the second test case Including the values of M input parameters.
可以理解的是,第一取值组合与第二取值组合包括目标输入参数的取值可以相同,也可 以不同;由于第一取值组合包括与目标功能覆盖组中相关联的目标输入参数的取值,利用第一取值组合替代第二取值组合,得到的第二测试用例集合可以更加有效的覆盖目标功能覆盖组中的功能覆盖点,从而对目标功能覆盖组中待测试的目标功能进行有效测试,提升功能覆盖率。It can be understood that the values of the first value combination and the second value combination including the target input parameters may be the same or different; since the first value combination includes the values of the target input parameters associated with the target function coverage group value, using the first value combination to replace the second value combination, the obtained second test case set can more effectively cover the function coverage points in the target function coverage group, so that the target function to be tested in the target function coverage group Conduct effective testing and improve functional coverage.
示例性地,可以通过下述方式实现利用每一个第一取值组合,替代第一测试用例集合中的第二取值组合。Exemplarily, each first value combination can be used to replace the second value combination in the first test case set in the following manner.
方式一、针对每一第一取值组合,确定与该第一取值组合的相似度满足预设条件的第二取值组合,作为该第一取值组合的目标第二取值组合;利用该第一取值组合替代目标第二取值组合。示例性地,可以获取第一测试用例集合中每一第一测试用例的第二取值组合,从而得到多个第二取值组合,针对任一第一取值组合,分别计算该第一取值组合与各第二取值组合的相似度,并将最高相似度对应的第二取值组合作为目标第二取值组合,进而在目标第二取值组合所在的第一测试用例中,利用该第一取值组合替代目标第二取值组合,从而得到第二测试用例。由于第二取值组合中输入参数的取值满足预设约束,将与第一取值组合的相似度满足预设约束的第二取值组合作为目标第二取值组合,从而最大程度保证生成的包含该第一取值组合的第二测试用例中输入参数的取值满足预设约束。Method 1. For each first value combination, determine a second value combination whose similarity with the first value combination satisfies a preset condition, as the target second value combination of the first value combination; use The first combination of values replaces the target second combination of values. Exemplarily, the second value combination of each first test case in the first test case set can be obtained, thereby obtaining a plurality of second value combinations, and for any first value combination, the first value combination is calculated respectively. The similarity between the value combination and each second value combination, and the second value combination corresponding to the highest similarity is used as the target second value combination, and then in the first test case where the target second value combination is located, use The first value combination replaces the target second value combination, so as to obtain the second test case. Since the value of the input parameter in the second value combination satisfies the preset constraint, the second value combination whose similarity with the first value combination satisfies the preset constraint is taken as the target second value combination, so as to ensure the generation of The value of the input parameter in the second test case containing the first value combination satisfies the preset constraint.
方式二、针对每一第一取值组合,依次替代各第一测试用例的第二取值组合。示例性地,可以获取第一测试用例集合中每一第一测试用例的第二取值组合,从而得到多个第二取值组合,针对任一第一取值组合,依次替换各第二取值组合,从而得到多个第二测试用例,以此类推,直到针对所有第一取值组合,完成上述替代操作。Mode 2: For each first value combination, replace the second value combination of each first test case in turn. Exemplarily, the second value combination of each first test case in the first test case set can be obtained, thereby obtaining a plurality of second value combinations, and for any first value combination, each second value combination is sequentially replaced. value combination, so as to obtain multiple second test cases, and so on, until the above substitution operation is completed for all the first value combinations.
示例性地,可以重复执行上述步骤803-806,针对每次确定的目标功能覆盖组,生成对目标功能覆盖组中待测试的目标功能进行有效测试的第二测试用例,直到满足预设条件;预设条件可以包括:累积生成的测试用例的数量超过预设数量、功能覆盖率满足预设要求或者遍历了所有的预设功能覆盖点组等等。Exemplarily, the above steps 803-806 may be repeatedly executed, and for each determined target function coverage group, a second test case for effectively testing the target function to be tested in the target function coverage group is generated until the preset condition is met; The preset conditions may include: the number of accumulatively generated test cases exceeds a preset number, the function coverage meets a preset requirement, or all preset function coverage point groups have been traversed, and the like.
本申请实施例中,第一功能覆盖信息表示各功能覆盖组中已被测试的功能和/或未被测试的功能,功能覆盖组与输入参数之间的关联信息为利用输入参数的取值满足预设约束的第二测试用例训练样本、及第二测试用例训练样本对应的第一功能覆盖信息训练所得到,功能覆盖组与输入参数之间的关联信息可以指示相关联的功能覆盖组与输入参数;进而可以根据该关联信息确定输入参数集合中与目标功能覆盖组相关联的目标输入参数,该目标输入参数即为影响目标功能覆盖组中待测试的目标功能能否被测试到的重要参数,从而进一步缩小探索输入参数的取值空间,提升了测试效率;确定目标输入参数的取值组合,并生成包含该取值组合的第二测试用例集合,进而可以针对目标功能覆盖组中待测试的目标功能进行更加高效地测试,有效提升功能覆盖率。在一些示例中,针对未覆盖的功能覆盖组(或功能覆盖点),可以生成能覆盖该功能覆盖组的测试用例,从而有效提升功能覆盖率,尤其对于测试后期通常难以被覆盖的功能覆盖组(或功能覆盖点)具有更好的覆盖效果,减少了领域专家的人工介入,降低了测试成本,进一步提升了测试效率,有效缩小了芯片开发周期。In the embodiment of the present application, the first function coverage information indicates the tested functions and/or untested functions in each function coverage group, and the association information between the function coverage group and the input parameters is that the value of the input parameters satisfies The second test case training sample with preset constraints and the first functional coverage information corresponding to the second test case training sample are trained, and the association information between the functional coverage group and the input parameters can indicate the associated functional coverage group and the input parameter Parameters; furthermore, the target input parameter associated with the target function coverage group in the input parameter set can be determined according to the associated information, and the target input parameter is an important parameter that affects whether the target function to be tested in the target function coverage group can be tested , so as to further narrow the value space of the exploration input parameters and improve the test efficiency; determine the value combination of the target input parameters, and generate the second test case set containing the value combination, and then can target the target function coverage group to be tested Test the target functions more efficiently and effectively improve the functional coverage. In some examples, for an uncovered functional coverage group (or functional coverage point), test cases that can cover the functional coverage group can be generated, thereby effectively improving the functional coverage rate, especially for the functional coverage group that is usually difficult to cover in the later stage of the test (or functional coverage point) has better coverage effect, reduces the manual intervention of domain experts, reduces the test cost, further improves the test efficiency, and effectively shortens the chip development cycle.
下面对上述得到功能覆盖组与输入参数之间的关联信息的过程进行示例性地说明。The above-mentioned process of obtaining the association information between the function coverage group and the input parameters will be exemplarily described below.
图9示出根据本申请一实施例的另一种芯片的测试用例生成方法的流程图。如图9所示,该方法可以包括:FIG. 9 shows a flowchart of another method for generating test cases for a chip according to an embodiment of the present application. As shown in Figure 9, the method may include:
步骤901、获取第二测试用例训练样本及第二测试用例训练样本对应的第一功能覆盖信 息。 Step 901, obtain the second test case training sample and the first function coverage information corresponding to the second test case training sample.
其中,第二测试用例训练样本及第一功能覆盖信息的具体说明可参照前文相关表述,此处不再赘述。Wherein, for the specific description of the second test case training sample and the first function coverage information, reference may be made to the above related expressions, and details will not be repeated here.
示例性地,可以根据输入参数集合中,采用随机方式生成一定数量的测试用例,将上述随机生成的测试用例输入到约束求解器中,约束求解器可以对不满足预设约束的随机生成的测试用例中输入参数的取值进行修改,从而得到输入参数取值满足预设约束的测试用例,即测试用例训练样本集合,第二测试用例训练样本即为该测试用例训练样本集合中的任一个;进而可以将第二测试用例训练样本输入到芯片仿真器中运行,从而得到第二测试用例训练样本对应的第一功能覆盖信息。Exemplarily, a certain number of test cases can be randomly generated according to the set of input parameters, and the above randomly generated test cases can be input into the constraint solver, and the constraint solver can test the randomly generated test cases that do not satisfy the preset constraints The value of the input parameter in the test case is modified to obtain a test case whose value of the input parameter satisfies the preset constraint, that is, the test case training sample set, and the second test case training sample is any one of the test case training sample set; Furthermore, the second test case training sample can be input into the chip emulator to run, so as to obtain the first function coverage information corresponding to the second test case training sample.
步骤902、利用第二测试用例训练样本及第一功能覆盖信息对第二预设模型进行训练,得到功能覆盖组与输入参数之间的关联信息。 Step 902 , using the second test case training sample and the first function coverage information to train the second preset model to obtain the association information between the function coverage group and the input parameters.
示例性地,第二预设模型可以为随机森林模型,例如,可以为通过ID3、C4.5、CART等决策树生成算法构建的随机森林模型;还可以包括其他用于挖掘不同对象之间的关联关系的模型,对此不作限定。Exemplarily, the second preset model can be a random forest model, for example, it can be a random forest model constructed by decision tree generation algorithms such as ID3, C4.5, and CART; The model of the association relationship is not limited.
作为一个示例,以第二预设模型为随机森林模型为例,针对目标功能覆盖组,可以将第二测试用例训练样本输入到随机森林模型,并以第一功能覆盖信息作为标签,训练该随机森林模型,得到功能覆盖组与输入参数之间的关联信息。As an example, taking the random forest model as the second preset model, for the target function coverage group, the second test case training sample can be input into the random forest model, and the first function coverage information is used as a label to train the random forest model. Forest model, to obtain the association information between functional coverage groups and input parameters.
示例性地,将第二测试用例训练样本集合输入到随机森林模型中,以目标功能覆盖组中已被第二测试用例训练样本测试到的功能和目标功能覆盖组中未被第二测试用例训练样本测试到的功能作为标签,训练该随机森林模型,在训练过程中,通过不断挖掘第二测试用例训练样本中不同输入参数对分类的影响,即不同输入参数对目标功能覆盖组中功能能否被测试到影响,确定每一节点分裂时采用的输入参数,使得训练后的随机森林模型能够准确预测第二测试用例训练样本对于目标功能覆盖组中功能覆盖点的覆盖情况;在上述训练过程中,各节点分裂时采用的输入参数即为对目标功能覆盖组中功能能否被测试到有影响的输入参数,进而在训练完成后,可以确定各有影响的输入参数的重要性,并根据重要性高低从中选择N个最重要的输入参数作为与目标功能覆盖组相关联的输入参数,其中,N的数值可以根据实际需求进行设定。在预设的功能覆盖组为多个的情况下,针对任一预设功能覆盖组,均可以通过上述方式训练对应的一个随机森林模型,得到与该预设功能覆盖组相关联的输入参数,从而可以根据各预设功能覆盖组及与各功能覆盖组相关联的输入参数,确定功能覆盖组与输入参数之间的关联信息。Exemplarily, the second test case training sample set is input into the random forest model, and the functions that have been tested by the second test case training samples in the target function coverage group and the target function coverage group that have not been trained by the second test case The function tested by the sample is used as a label to train the random forest model. During the training process, the influence of different input parameters on the classification in the training sample of the second test case is continuously mined, that is, whether different input parameters can affect the functions in the target function coverage group. Influenced by the test, determine the input parameters used when each node splits, so that the trained random forest model can accurately predict the coverage of the second test case training samples for the functional coverage points in the target functional coverage group; in the above training process , the input parameters used when splitting each node are the input parameters that affect whether the functions in the target function coverage group can be tested, and then after the training is completed, the importance of each influential input parameter can be determined, and according to the importance Select the N most important input parameters as the input parameters associated with the target function coverage group, wherein the value of N can be set according to actual needs. In the case of multiple preset functional coverage groups, for any preset functional coverage group, a corresponding random forest model can be trained in the above manner to obtain the input parameters associated with the preset functional coverage group, Therefore, the association information between the function coverage groups and the input parameters can be determined according to each preset function coverage group and the input parameters associated with each function coverage group.
作为一个示例,在上述随机森林模型训练完成后,针对每一节点分裂时采用的输入参数,可以计算该输入参数的重要性评分,该重要性评分可以评估输入参数在对第二测试用例训练样本集合进行分类的过程中所起的作用,即该输入参数对目标功能覆盖组的覆盖情况的影响程度,可以理解的是,重要性评分越高,则对应的输入参数对实现第二测试用例训练样本集合的准确分类越重要,即对应的输入参数对目标功能覆盖组中的功能覆盖点被覆盖情况影响越大;例如,可以将输入参数在随机森林模型的所有决策树中节点分裂不纯度(如、基尼指数、信息熵、信息增益等)的平均改变量作为该输入参数的重要性评分;从而按照重要性评分高低进行排序,并将排列在前的N个输入参数作为与目标功能覆盖组相关联的输入参数。As an example, after the above random forest model training is completed, for each input parameter used when splitting a node, the importance score of the input parameter can be calculated, and the importance score can evaluate the effect of the input parameter on the training sample of the second test case The role played by the set in the process of classifying, that is, the degree of influence of the input parameter on the coverage of the target function coverage group. It can be understood that the higher the importance score, the corresponding input parameter is more important to the realization of the second test case training The more important the accurate classification of the sample set is, the greater the impact of the corresponding input parameters on the coverage of the functional coverage points in the target functional coverage group; for example, the input parameters can be split in all decision trees of the random forest model. Such as, Gini index, information entropy, information gain, etc.) as the importance score of the input parameter; thus sorted according to the importance score, and the top N input parameters are used as the coverage group with the target function Associated input parameters.
举例来说,以训练功能覆盖组g对应的随机森林模型为例,获取测试用例训练样本集, 测试用例训练样本集中有K个测试用例训练样本,每个测试用例训练样本对应的标签为功能覆盖组g对应的功能覆盖信息,每个样本中包含L个输入参数;在训练每一棵决策树时,首先,在测试用例训练样本集中有放回的随机取样K次,从而选择K个测试用例训练样本,利用选择的这K个测试用例训练样本训练该决策树,即作为该决策树根节点处的样本;然后,在该决策树的每个节点需要分裂时,随机从L个输入参数中选择l个输入参数,其中,l为选小于L的常数;根据功能覆盖组g对应的功能覆盖信息确定l个输入参数中各输入参数对应的评估指标值,进而从l个输入参数中选择一个评估指标值最优的输入参数作为该节点分裂时采用的特征,例如,以评估指标为基尼指数为例,对于任一输入参数,可以计算该输入参数每一可能取值对应的基尼指数,进而得到该输入参数对应的基尼指数,以此类推,得到所有输入参数对应的基尼指数,从而选择最小基尼指数所对应的输入参数,作为该节点分裂时采用的特征;同理,每个节点按照该方式确定对应的特征并进行分裂,直到节点无法继续分裂或节点数量超过预设值,则生成一棵决策树,且不进行剪枝。这样,通过重复执行上述随机取样及随机选取每一节点的特征的操作,从而生成预设数量的决策树,即完成随机森林的训练。在完成训练后,可以计算节点分裂所采用的各输入参数对应的重要性评分,并选出重要性评分最高的若干输入参数,作为与功能覆盖组g存在关联,从而得到功能覆盖组g与输入参数之间的关联信息。For example, taking the random forest model corresponding to the training function coverage group g as an example, the test case training sample set is obtained. There are K test case training samples in the test case training sample set, and the label corresponding to each test case training sample is function coverage The functional coverage information corresponding to group g, each sample contains L input parameters; when training each decision tree, first, there are K times of random sampling in the test case training sample set, so that K test cases are selected Training samples, use the selected K test case training samples to train the decision tree, that is, as samples at the root node of the decision tree; then, when each node of the decision tree needs to be split, randomly select from L input parameters Select l input parameters, where l is a constant less than L; determine the evaluation index value corresponding to each input parameter in the l input parameters according to the functional coverage information corresponding to the functional coverage group g, and then select one of the l input parameters The input parameter with the best evaluation index value is used as the feature when the node is split. For example, taking the evaluation index as the Gini index as an example, for any input parameter, the Gini index corresponding to each possible value of the input parameter can be calculated, and then Get the Gini index corresponding to the input parameter, and so on, get the Gini index corresponding to all input parameters, so as to select the input parameter corresponding to the minimum Gini index as the feature used when the node is split; similarly, each node according to the The method determines the corresponding features and splits until the node can no longer be split or the number of nodes exceeds the preset value, then a decision tree is generated without pruning. In this way, by repeatedly performing the above operations of random sampling and randomly selecting the features of each node, a preset number of decision trees are generated, that is, the training of the random forest is completed. After the training is completed, the importance scores corresponding to the input parameters used for node splitting can be calculated, and some input parameters with the highest importance scores can be selected as being associated with the functional coverage group g, so that the functional coverage group g and the input Correlation information between parameters.
这样,考虑到待测芯片设计可能包括大规模的输入参数,然而针对任一功能覆盖组,可能并非所有的输入参数对该功能覆盖组中各功能覆盖点被覆盖情况有影响,本申请实施例中,利用第二测试用例训练样本及第二测试用例训练样本对应的第一功能覆盖信息对第二预设模型进行训练,从而挖掘出各功能覆盖组与输入参数之间的关联关系,即针对任一功能覆盖组,挖掘出影响该功能覆盖组中功能能否被测试到的重要输入参数,从而得到功能覆盖组与输入参数之间的关联信息。作为一个示例,针对任一功能覆盖组,可以以第二测试用例训练样本对应的第一功能覆盖信息作为标签,利用第二测试用例训练样本对与该功能覆盖组对应的随机森林模型进行训练,从而挖掘出该功能覆盖组与测试用例的输入参数之间的关联关系,即挖掘出影响该功能覆盖组中功能能否被测试到的重要输入参数,从而得到功能覆盖组与输入参数之间的关联信息。上述关联信息可以为进一步生成测试用例地过程提供引导,以便针对性地生成能够覆盖目标功能覆盖组中功能覆盖点的测试用例,从而有效提升功能覆盖率,同时,进一步缩小了测试用例生成过程中所需探索的输入参数的取值空间,有效提高了测试效率。In this way, considering that the design of the chip to be tested may include large-scale input parameters, however, for any functional coverage group, not all input parameters may have an impact on the coverage of each functional coverage point in the functional coverage group, the embodiment of the present application In the second preset model, the second preset model is trained by using the second test case training sample and the first function coverage information corresponding to the second test case training sample, so as to dig out the correlation between each function coverage group and the input parameters, that is, for For any functional coverage group, dig out the important input parameters that affect whether the functions in the functional coverage group can be tested, so as to obtain the correlation information between the functional coverage group and the input parameters. As an example, for any functional coverage group, the first functional coverage information corresponding to the second test case training sample can be used as a label, and the second test case training sample is used to train the random forest model corresponding to the functional coverage group, In this way, the relationship between the functional coverage group and the input parameters of the test case is excavated, that is, the important input parameters that affect whether the functions in the functional coverage group can be tested are excavated, and the relationship between the functional coverage group and the input parameters is obtained. Associated information. The above association information can provide guidance for the process of further generating test cases, so that test cases that can cover the functional coverage points in the target functional coverage group can be generated in a targeted manner, thereby effectively improving the functional coverage rate. The value space of the input parameters to be explored effectively improves the test efficiency.
进一步地,在上述各实施例中,还可以基于预定义的启发式策略,高效地生成测试用例,以进一步提升测试效率。Furthermore, in each of the above embodiments, test cases can also be efficiently generated based on a predefined heuristic strategy, so as to further improve test efficiency.
作为一个示例,可以通过预定义的启发式策略,确定目标功能覆盖组,例如,在上述步骤803中,可以通过预定义的启发式策略,确定目标功能覆盖;示例性地,可以利用轮盘算法、依次选择等启发式策略确定目标功能覆盖组。As an example, the target function coverage group can be determined through a predefined heuristic strategy, for example, in the above step 803, the target function coverage can be determined through a predefined heuristic strategy; exemplarily, a roulette algorithm can be used , sequential selection and other heuristic strategies to determine the target function coverage group.
图10示出根据本申请一实施例的一种确定目标功能覆盖组的方法流程图,如图10所示,可以包括以下步骤:FIG. 10 shows a flowchart of a method for determining a target function coverage group according to an embodiment of the present application. As shown in FIG. 10 , the following steps may be included:
步骤1001、获取第一测试用例集合对应的第二功能覆盖信息。 Step 1001. Obtain second function coverage information corresponding to the first test case set.
其中,第二功能覆盖信息可以包括各功能覆盖组中未被测试的功能的个数,即各功能覆盖组中未被第一测试用例集合覆盖的功能覆盖点的个数。Wherein, the second function coverage information may include the number of untested functions in each function coverage group, that is, the number of function coverage points not covered by the first test case set in each function coverage group.
步骤1002、根据第一测试用例集合对应的第二功能覆盖信息,确定第一测试用例集合对应的各功能覆盖组的启发式分数。 Step 1002, according to the second functional coverage information corresponding to the first test case set, determine the heuristic score of each functional coverage group corresponding to the first test case set.
其中,启发式分数与功能覆盖组中未被测试的功能的个数正相关。可以理解的是,功能覆盖组中未被测试的功能的个数越多,则功能覆盖组的启发式分数越大。where the heuristic score is positively correlated with the number of untested functions in the functional coverage group. It can be understood that the greater the number of untested functions in the functional coverage group, the greater the heuristic score of the functional coverage group.
示例性地,可以根据第一测试用例集合对应的各功能覆盖组中未被测试的功能的个数,确定第一测试用例集合对应的未被测试的功能总数;根据各功能覆盖组中未被测试的功能的个数占未被测试的功能总数的比重,确定各功能覆盖组的启发式分数。Exemplarily, the total number of untested functions corresponding to the first test case set can be determined according to the number of untested functions in each function coverage group corresponding to the first test case set; The ratio of the number of tested functions to the total number of untested functions determines the heuristic score of each functional coverage group.
示例性地,功能覆盖组的启发式分数可以如下述公式(1)所示:Exemplarily, the heuristic score of the functional coverage group can be shown as the following formula (1):
Figure PCTCN2022143439-appb-000004
Figure PCTCN2022143439-appb-000004
在公式(1)中,S g为功能覆盖组g的启发式分数,u g为功能覆盖组g中未被覆盖的功能覆盖点个数,G为功能覆盖组g所在的功能覆盖组集合,u k为功能覆盖组集合G中第k个功能覆盖组中未被覆盖的功能覆盖点个数。 In the formula (1), S g is the heuristic score of the functional coverage group g, u g is the number of uncovered functional coverage points in the functional coverage group g, G is the functional coverage group set where the functional coverage group g belongs to, u k is the number of uncovered functional coverage points in the kth functional coverage group in the functional coverage group set G.
步骤1003、根据各功能覆盖组的启发式分数,确定各功能覆盖组对应的概率。 Step 1003, according to the heuristic score of each functional coverage group, determine the probability corresponding to each functional coverage group.
其中,功能覆盖组对应的概率与功能覆盖组的启发式分数正相关。可以理解的是,功能覆盖组的启发式分数越高,则对应的概率越大。Among them, the probability corresponding to the functional coverage group is positively correlated with the heuristic score of the functional coverage group. It is understandable that the higher the heuristic score for a functional coverage group, the greater the corresponding probability.
示例性地,基于上述公式(1)得到的启发式分数,功能覆盖组对应的概率可以如下述公式(2)所示:Exemplarily, based on the heuristic score obtained by the above formula (1), the probability corresponding to the functional coverage group can be shown in the following formula (2):
Figure PCTCN2022143439-appb-000005
Figure PCTCN2022143439-appb-000005
在公式(2)中,r g为功能覆盖组g对应的概率,S g为功能覆盖组g的启发式分数,G为功能覆盖组g所在的功能覆盖组集合,S k为功能覆盖组集合G中第k个功能覆盖组的启发式分数。 In formula (2), r g is the probability corresponding to the functional coverage group g, S g is the heuristic score of the functional coverage group g, G is the functional coverage group set where the functional coverage group g belongs to, and S k is the functional coverage group set Heuristic score for the kth functional coverage group in G.
步骤1004、基于各功能覆盖组对应的概率,确定至少一个目标功能覆盖组。Step 1004: Determine at least one target function coverage group based on the probability corresponding to each function coverage group.
示例性地,可以采用轮盘算法,基于各功能覆盖组对应的概率,选择一个或多个功能覆盖组作为目标功能覆盖组;功能覆盖组对应的概率越高,则越可能被选为目标功能覆盖组。Exemplarily, a roulette algorithm can be used to select one or more functional coverage groups as the target functional coverage group based on the probability corresponding to each functional coverage group; the higher the probability corresponding to the functional coverage group, the more likely it will be selected as the target function Override group.
本申请实施例中,通过启发式策略选取目标功能覆盖组,功能覆盖组中未被测试的功能的个数越多,对应的启发式分数越高,则对应的概率越大,则越可能被选为目标功能覆盖组;即针对未被覆盖的功能覆盖组,更有可能被选为目标功能覆盖组;尤其是在测试后期,难以被覆盖的功能覆盖组更有可能被选为目标功能覆盖组,进而可以针对性地生成测试用例,从而提升功能覆盖率,减少了领域专家的人工介入,降低了测试成本,提高了测试效率。In the embodiment of this application, the target function coverage group is selected through a heuristic strategy. The more untested functions in the function coverage group, the higher the corresponding heuristic score, the greater the corresponding probability, and the more likely it is to be tested. Selected as the target functional coverage group; that is, for the functional coverage group that is not covered, it is more likely to be selected as the target functional coverage group; especially in the later stage of the test, the functional coverage group that is difficult to be covered is more likely to be selected as the target functional coverage group Groups, and then can generate test cases in a targeted manner, thereby improving functional coverage, reducing manual intervention by domain experts, reducing testing costs, and improving testing efficiency.
作为一个示例,可以基于预定义的启发式策略,确定第一取值组合,例如,在上述步骤805中,可以根据启发式策略确定N个目标输入参数的至少一个第一取值组合;示例性地,可以利用基于距离采样(T-wise)算法、固定尺寸候选集(Fixed-Size-Candidate-Set,FSCS)等自适应随机采样算法作为启发式策略,确定第一取值组合。As an example, the first value combination may be determined based on a predefined heuristic strategy. For example, in the above step 805, at least one first value combination of N target input parameters may be determined according to the heuristic strategy; exemplary Specifically, an adaptive random sampling algorithm such as a distance sampling (T-wise) algorithm and a fixed-size candidate set (Fixed-Size-Candidate-Set, FSCS) can be used as a heuristic strategy to determine the first value combination.
图11示出根据本申请一实施例的一种确定第一取值组合的方法流程图,如图11所示,可以包括以下步骤:Fig. 11 shows a flowchart of a method for determining a first value combination according to an embodiment of the present application. As shown in Fig. 11, the following steps may be included:
步骤1101、根据N个目标输入参数的预设取值范围,随机生成多个候选取值组合。 Step 1101, randomly generate multiple candidate value combinations according to the preset value ranges of N target input parameters.
示例性地,可以生成较大数量的候选取值组合,例如,可以生成30*k个候选取值组合,k为预设的取值组合数量。Exemplarily, a larger number of candidate value combinations may be generated, for example, 30*k candidate value combinations may be generated, where k is a preset number of value combinations.
步骤1102、将多个候选取值组合中的任一取值组合作为初始迭代回合对应的取值组合。 Step 1102, taking any value combination among multiple candidate value combinations as the value combination corresponding to the initial iteration round.
该步骤中,在初始迭代回合,可以在上述多个候选取值组合中随机选择一个取值组合。In this step, in the initial iteration round, a value combination may be randomly selected from the above multiple candidate value combinations.
步骤1103、从多个候选取值组合中,确定当前迭代回合对应的取值组合。 Step 1103, from multiple candidate value combinations, determine the value combination corresponding to the current iteration round.
其中,当前迭代回合对应的取值组合与已确定的各迭代回合对应的取值组合的差异最大。Among them, the value combination corresponding to the current iteration round has the largest difference from the determined value combination corresponding to each iteration round.
示例性地,针对任一候选取值组合,可以计算其与已确定的先前各迭代回合对应的取值组合的总距离(如欧氏距离);进而,对各候选取值组合对应的总距离进行比较,最大总距离对应的候选取值组合即为当前迭代回合对应的取值组合;从而保证了各迭代回合对应的取值组合中目标输入参数的取值更加均匀、多样。Exemplarily, for any candidate value combination, the total distance (such as Euclidean distance) between it and the value combination corresponding to the previous iterative rounds determined can be calculated; furthermore, the total distance corresponding to each candidate value combination For comparison, the candidate value combination corresponding to the maximum total distance is the value combination corresponding to the current iteration round; thus ensuring that the values of the target input parameters in the value combinations corresponding to each iteration round are more uniform and diverse.
步骤1104、重复执行上述确定当前迭代回合对应的取值组合的操作,直到满足预设迭代条件;并将各迭代回合对应的取值组合作为至少一个第一取值组合。Step 1104: Repeat the above operation of determining the value combination corresponding to the current iteration round until the preset iteration condition is met; and use the value combination corresponding to each iteration round as at least one first value combination.
示例性地,预设迭代条件可以为所确定的各迭代回合对应的取值组合达到预设的取值组合数量K。Exemplarily, the preset iteration condition may be that the determined value combinations corresponding to each iteration round reach the preset number K of value combinations.
考虑到对于任一目标输入参数,其对应的取值范围内可以包括较多的取值,若遍历所有的取值,生成的第一取值组合数量规模太大,例如,N个目标输入参数的预设取值范围内均包含512个取值,若遍历所有取值,则存在512 N个取值组合。本申请实施例中,通过启发式策略进行采样,首先生成多个候选取值组合,进而通过多次迭代,确定每一迭代回合对应的取值组合,且每一迭代回合对应的取值组合与已确定的各迭代回合对应的取值组合的差异最大,从而保证了各迭代回合对应的取值组合中N个目标输入参数的取值更加均匀、多样;进而可以生成输入参数的取值更加均匀、多样的测试用例,在保证功能覆盖率的同时,有效减少了所需的测试用例数量,进一步提升了测试效率。 Considering that for any target input parameter, its corresponding value range can include more values, if all the values are traversed, the number of first value combinations generated is too large, for example, N target input parameters The preset value range of contains 512 values. If all the values are traversed, there are 512 N value combinations. In the embodiment of the present application, sampling is performed through a heuristic strategy, and multiple candidate value combinations are first generated, and then through multiple iterations, the value combination corresponding to each iteration round is determined, and the value combination corresponding to each iteration round is the same as The determined value combinations corresponding to each iterative round have the largest difference, thus ensuring that the values of the N target input parameters in the value combinations corresponding to each iterative round are more uniform and diverse; in turn, the values of the input parameters can be generated to be more uniform , Various test cases, while ensuring functional coverage, effectively reduce the number of required test cases and further improve test efficiency.
进一步地,考虑到第二测试用例相对于第一测试用例,部分输入参数的取值进行了修改,因此,得到的第二测试用例集合中,可能存在输入参数的取值不满足预设约束的第二测试用例;在一种可能的实现方式中,可以对上述得到第二测试用例集合中各测试用例进行后处理,过滤掉第二测试用例集合中M个输入参数的取值不满足预设约束的第二测试用例。示例性地,可以在上述步骤806之后执行上述后处理操作。Further, considering that the value of some input parameters in the second test case has been modified relative to the first test case, therefore, in the obtained second test case set, there may be values of input parameters that do not meet the preset constraints The second test case; in a possible implementation, post-processing can be performed on each test case in the second test case set obtained above, and the values of the M input parameters in the second test case set are filtered out if they do not satisfy the preset Constrained second test case. Exemplarily, the above post-processing operation may be performed after the above step 806 .
作为一个示例,可以利用在上述训练生成对抗网络的过程中收敛时的判别器,过滤掉第二测试用例集合中M个输入参数的取值不满足预设约束的第二测试用例。示例性地,可以在对生成对抗网络进行多轮训练中,确定得到与最大测试用例不变率对应的生成器的一轮训练,从而利用该轮训练收敛时的判别器,过滤掉第二测试用例集合中M个输入参数的取值不满足预设约束的第二测试用例。As an example, the discriminator converged during the above training process of generating an adversarial network may be used to filter out the second test cases whose values of M input parameters do not meet the preset constraints in the second test case set. Exemplarily, in the multi-round training of the generative confrontation network, it can be determined to obtain a round of training of the generator corresponding to the maximum test case invariance rate, so as to use the discriminator when this round of training converges to filter out the second test A second test case whose values of the M input parameters in the test case set do not satisfy the preset constraints.
作为另一个示例,可以利用上述约束求解器,过滤掉第二测试用例集合中M个输入参数不满足预设约束的第二测试用例。示例性地,将第二测试用例集合输入到约束求解器,对输入参数的取值不满足预设约束的第二测试用例进行校正,从而实现过滤掉第二测试用例集合中M个输入参数的取值不满足预设约束的第二测试用例。As another example, the above-mentioned constraint solver may be used to filter out the second test cases whose M input parameters do not satisfy the preset constraints in the second test case set. Exemplarily, the second test case set is input to the constraint solver, and the value of the input parameter does not meet the preset constraint. The second test case is corrected, thereby realizing filtering out M input parameters in the second test case set A second test case whose values do not satisfy the preset constraints.
本申请实施例中,过滤掉输入参数的取值不满足预设约束的第二测试用例,从而保证第二测试用例集合中各第二测试用例的输入参数的取值均满足预设约束。In the embodiment of the present application, the second test cases whose values of input parameters do not meet the preset constraints are filtered out, so as to ensure that the values of the input parameters of each second test case in the second test case set all meet the preset constraints.
下面以某一待测芯片设计D为例,对上述芯片的测试用例生成方法进行举例说明。该待测芯片设计D的基本信息为:输入参数集合中包括575个输入参数,功能覆盖点为7219个,对应的功能覆盖组为681个。Taking the design D of a chip to be tested as an example, the method for generating test cases for the above-mentioned chip will be described as an example. The basic information of the chip design D to be tested is: the input parameter set includes 575 input parameters, 7219 function coverage points, and 681 corresponding function coverage groups.
图12示出根据本申请一实施例的另一种芯片的测试用例生成方法的流程图,如图12所示,可以包括以下几个阶段包括:FIG. 12 shows a flow chart of another chip test case generation method according to an embodiment of the present application. As shown in FIG. 12, the following stages may be included:
1、信息获取阶段;该阶段可以获取待测芯片设计的相关信息,例如,输入参数集合、各输入参数的取值范围、功能覆盖点、功能覆盖组、功能覆盖组与功能覆盖点的对应关系等等。该阶段还可以获取测试用例集合及功能覆盖信息等,以作为下述训练生成对抗网络及随机森林模型的训练样本。1. Information acquisition stage: In this stage, relevant information about the chip design to be tested can be obtained, for example, the set of input parameters, the value range of each input parameter, function coverage points, function coverage groups, and the corresponding relationship between function coverage groups and function coverage points etc. At this stage, test case sets and functional coverage information can also be obtained as training samples for training the generated confrontation network and random forest model described below.
示例性地,使用随机方式生成小批量(例如10000个)的测试用例集合X1,将测试用例集合X1输入到约束求解器中,约束求解器会对测试用例集合X1中的输入参数的取值不满足预设约束的测试用例进行校正,并返回输入参数的取值满足预设约束的测试用例集合X2,将测试用例集合X2输入到仿真器F中运行,得到对应的功能覆盖信息,该功能覆盖信息可以为一个10000*7219的功能覆盖矩阵M cover,在M cover中,每一行表示测试用例集合X2中的一个测试用例,每一列表示一个功能覆盖点,每个元素的取值为0或1,其中,取1时表示该元素所在行对应的测试用例覆盖了该元素所在列对应的功能覆盖点,取0时表示该元素所在行对应的测试用例未覆盖了该元素所在列对应的功能覆盖点。 Exemplarily, a small batch (for example, 10,000) of test case sets X1 is generated in a random manner, and the test case set X1 is input into the constraint solver, and the constraint solver will vary the values of the input parameters in the test case set X1 Correct the test cases that meet the preset constraints, and return the test case set X2 whose input parameter values meet the preset constraints, input the test case set X2 into the emulator F to run, and obtain the corresponding function coverage information, the function coverage The information can be a 10000*7219 functional coverage matrix M cover . In M cover , each row represents a test case in the test case set X2, each column represents a functional coverage point, and the value of each element is 0 or 1 , where 1 means that the test case corresponding to the row where the element is located covers the functional coverage point corresponding to the column where the element is located, and 0 means that the test case corresponding to the row where the element is located does not cover the functional coverage point corresponding to the column where the element is located point.
2、信息挖掘阶段,该阶段用于学习测试用例的不同输入参数之间的取值约束,以及挖掘出各功能覆盖组与输入参数之间的关联关系。2. The information mining stage, which is used to learn the value constraints between different input parameters of test cases, and to mine the correlation between each function coverage group and input parameters.
示例性地,初始化生成对抗网络的生成器与判别器,并定义优化器和损失函数。将上述获取的测试用例集合X2作为训练样本,训练生成对抗网络。在训练过程中,用随机噪声作为生成器的输入,产生假样本,并用判别器判别真假样本,根据损失值对判别器和生成器进行端对端的训练;使得生成器对测试用例集合X2与测试用例集合X1之间的约束关系C(X1,X2)的建模能力越来越好,即不断学习测试用例的不同输入参数之间的取值约束。重复上述训练过程若干轮,并计算每一轮训练收敛时,生成器生成的测试用例对应的测试用例不变率,其中,最大测试用例不变率的生成器对约束关系C(X1,X2)的建模最好,保留该最大测试用例不变率对应的生成器的模型权重,从而用于下一阶段生成输入参数的取值满足预设约束的测试用例。Exemplarily, the generator and discriminator of the generative confrontation network are initialized, and the optimizer and loss function are defined. The test case set X2 obtained above is used as a training sample to train the generative confrontation network. In the training process, random noise is used as the input of the generator to generate fake samples, and the discriminator is used to distinguish true and false samples, and the discriminator and generator are trained end-to-end according to the loss value; so that the generator can compare the test case set X2 with The modeling ability of the constraint relationship C(X1, X2) between the test case sets X1 is getting better and better, that is, the value constraints between different input parameters of the test cases are continuously learned. Repeat the above training process for several rounds, and calculate the test case invariance rate corresponding to the test cases generated by the generator when each round of training converges, where the generator pair constraint relationship C(X1, X2) of the maximum test case invariance rate The modeling of is the best, and the model weight of the generator corresponding to the maximum test case invariance rate is reserved, so as to be used in the next stage to generate test cases whose input parameter values meet the preset constraints.
示例性地,对于任一功能覆盖组g,将上述获取的测试用例集合X2作为训练样本,功能覆盖矩阵M cover中功能覆盖组g对应的
Figure PCTCN2022143439-appb-000006
作为标签,以输入参数作为节点分裂的特征,训练随机森林模型,使其能够准确预测测试用例集合X2中各测试用例对于功能覆盖组g中功能覆盖点的覆盖情况;对于训练好的随机森林模型,使用各输入参数的不纯度,确定功能覆盖组g与输入参数p的关联信息R(g,p),其中,不纯度越大,对应的输入参数对功能覆盖组g中的功能覆盖点的覆盖情况影响越大,从而选取出N个对功能覆盖组g中的功能覆盖点的覆盖情况影响最大的输入参数,并将这N个输入参数集合表示为P g。这样,针对每一功能覆盖组,均通过上述方式训练对应的一个随机森林模型,挖掘功能覆盖组与输入参数之间的关联关系,从而得到各功能覆盖组与输入参数之间的关联信息;在后续阶段生成测试用例的过程中,以该关联信息作为启发式导向,快速生成覆盖效果更好的测试用例。
Exemplarily, for any functional coverage group g, the test case set X2 obtained above is used as a training sample, and the functional coverage matrix M cover corresponds to the functional coverage group g
Figure PCTCN2022143439-appb-000006
As a label, use the input parameters as the characteristics of node splitting, train the random forest model, so that it can accurately predict the coverage of each test case in the test case set X2 for the functional coverage points in the functional coverage group g; for the trained random forest model , use the impurity of each input parameter to determine the correlation information R(g, p) between the functional coverage group g and the input parameter p, where the greater the impurity, the corresponding input parameters have a greater impact on the functional coverage point in the functional coverage group g The greater the impact of the coverage, the N input parameters that have the greatest impact on the coverage of the functional coverage points in the functional coverage group g are selected, and the set of N input parameters is denoted as P g . In this way, for each functional coverage group, a corresponding random forest model is trained by the above method, and the correlation between the functional coverage group and the input parameters is mined, so as to obtain the correlation information between each functional coverage group and the input parameters; In the process of generating test cases in the subsequent stage, the associated information is used as a heuristic guide to quickly generate test cases with better coverage.
3、测试用例生成阶段,该阶段基于启发式策略,利用上述学习到的测试用例的不同输入参数之间的取值约束,以及挖掘出各功能覆盖组与输入参数之间的关联关系,指导朝着更有可能达到更高功能覆盖率的方向生成测试用例。3. The test case generation stage, which is based on the heuristic strategy, uses the value constraints between the different input parameters of the test cases learned above, and digs out the relationship between each function coverage group and the input parameters to guide the direction towards Test cases are generated in a direction that is more likely to achieve higher functional coverage.
示例性地,首先,利用上述阶段中最大测试用例不变率对应的生成器,生成输入参数的取值满足预设约束的测试用例集合X3。其次,采用启发式策略选择需要被覆盖的功能覆盖组 g,例如,对于每一功能覆盖组组,可以参照上述公式(1)计算对应的启发式分数,参照上述公式(2)计算对应的概率,进而通过轮盘算法采样功能覆盖组g;根据上述阶段得到的各功能覆盖组与输入参数之间的关联信息,确定与功能覆盖组g相关联的输入参数集合P g,并根据每个输入参数p(p∈P g)的取值范围随机生成30000条可能的取值组合,作为候选取值组合集合,并从候选取值组合集合中选取1000条输入参数的取值分布较多样、较均匀的取值组合,并将这1000条取值组合替代测试用例集合X3中的1000条测试用例中相应输入参数的取值组合,生成测试用例集合X4。最后,将上述生成的测试用例集合X4输入到仿真器F中,并得到相应的功能覆盖信息,并对是否满足测试停止条件进行判断,若不满足,则重复执行上述测试用例生成阶段,直到触发测试停止条件。 Exemplarily, first, use the generator corresponding to the maximum test case invariance rate in the above stage to generate a test case set X3 whose input parameter values satisfy preset constraints. Secondly, use a heuristic strategy to select the functional coverage group g that needs to be covered. For example, for each functional coverage group, you can refer to the above formula (1) to calculate the corresponding heuristic score, and refer to the above formula (2) to calculate the corresponding probability , and then use the roulette algorithm to sample the functional coverage group g; according to the correlation information between each functional coverage group and input parameters obtained in the above stage, determine the input parameter set P g associated with the functional coverage group g, and according to each input The value range of the parameter p(p∈P g ) randomly generates 30,000 possible value combinations as the candidate value combination set, and selects 1000 input parameter value distributions from the candidate value combination set. Uniform value combinations, and these 1000 value combinations replace the value combinations of corresponding input parameters in the 1000 test cases in the test case set X3 to generate the test case set X4. Finally, input the test case set X4 generated above into the simulator F, and obtain the corresponding function coverage information, and judge whether the test stop condition is satisfied, if not, repeat the above test case generation stage until the trigger Test the stop condition.
这样,通过上述“先建模,后生成”的方式,首先,利用生成对抗网络学习不同输入参数之间的取值约束,并利用随机森林挖掘功能覆盖组和输入参数的关联关系;进而,通过一轮或多轮迭代生成测试用例集合,其中,在每轮迭代中,利用训练好的生成器生成输入参数的取值满足预设约束的测试用例,通过启发式策略选择本轮关心的功能覆盖组,确定与该功能覆盖组相关联的一个或多个输入参数,并生成每一输入参数的多样化的取值组合;将多样化的取值组合及输入参数的取值满足预设约束的测试用例进行融合,针对性地生成测试用例集合,从而对所选择的功能覆盖组中待被测试的功能进行更加高效地测试;这样,通过生成较小规模的测试用例集合,即可达到较高的功能覆盖率,尤其对于测试后期通常难以被覆盖的功能覆盖组具有更好的覆盖效果,有效减少了领域专家的人工介入,从而可以通过自动生成测试用例实现100%功能覆盖率,降低了测试成本,减少了测试所需时间,有效缩小了芯片开发周期;同时,大幅缩减了生成测试用例时所需探索的输入参数的取值空间,大幅提升了测试效率。In this way, through the above-mentioned "model first, then generate" method, first, use the generative confrontation network to learn the value constraints between different input parameters, and use the random forest mining function to cover the relationship between the group and the input parameters; then, through One or more rounds of iterations are used to generate a set of test cases. In each round of iterations, the trained generator is used to generate test cases whose values of input parameters meet the preset constraints, and the function coverage of this round is selected through a heuristic strategy. Group, determine one or more input parameters associated with the function coverage group, and generate a variety of value combinations for each input parameter; combine the diversified value combinations and the values of the input parameters to meet the preset constraints The test cases are fused, and the test case sets are generated in a targeted manner, so as to test the functions to be tested in the selected functional coverage group more efficiently; in this way, by generating a smaller test case set, a higher The functional coverage rate, especially for the functional coverage group that is usually difficult to be covered in the later stage of the test, has a better coverage effect, effectively reducing the manual intervention of domain experts, so that 100% functional coverage can be achieved by automatically generating test cases, reducing the test cost. The cost reduces the time required for testing and effectively shortens the chip development cycle; at the same time, it greatly reduces the value space of input parameters that need to be explored when generating test cases, greatly improving test efficiency.
图13示出根据本申请一实施例的测试结果对比图,其中,虚线为采用本申请实施例中芯片的测试用例生成方法对上述待测芯片设计D进行测试得到的测试结果,实线为采用基于约束驱动的随机测试方法对上述待测芯片设计D进行测试得到的测试结果。如图13所示,在达到7176个功能覆盖点被覆盖的情况下,采用本申请实施例中方法仅需10543个测试用例,而采用基于约束驱动的随机测试方法需要20000个测试用例,即本申请实施例中方法能够节约94.57%的测试用例,可见,在覆盖相同数量的功能覆盖点时,采用本申请实施例中方法能够有效减少所需的测试用例数量。此外,在生成20000个测试用例的情况下,采用本申请实施例中方法能够覆盖7217个功能覆盖点,而采用基于约束驱动的随机测试方法仅能覆盖7176个功能覆盖点,可见,在生成相同数量的测试用例时,采用本申请实施例中方法能够有效提高功能覆盖率。Fig. 13 shows a comparison diagram of test results according to an embodiment of the present application, wherein, the dotted line is the test result obtained by testing the above-mentioned chip design D to be tested by using the test case generation method of the chip in the embodiment of the present application, and the solid line is the test result obtained by using Test results obtained by testing the above-mentioned chip design D under test based on a constraint-driven random testing method. As shown in Figure 13, when 7176 functional coverage points are covered, only 10543 test cases are required for the method in the embodiment of this application, while 20000 test cases are required for the random test method based on constraint drive, that is, this The method in the embodiment of the application can save 94.57% of test cases. It can be seen that when covering the same number of functional coverage points, the method in the embodiment of the application can effectively reduce the number of test cases required. In addition, in the case of generating 20,000 test cases, the method in the embodiment of this application can cover 7217 functional coverage points, while the constraint-driven random testing method can only cover 7176 functional coverage points. It can be seen that when generating the same When there are a large number of test cases, the method in the embodiment of the present application can effectively improve the functional coverage.
基于上述方法实施例的同一发明构思,本申请的实施例还提供了一种芯片的测试用例生成装置,该芯片的测试用例生成装置用于执行上述方法实施例所描述的技术方案。例如,可以执行上述图5-图12中任一所示方法的各步骤。Based on the same inventive concept of the above method embodiments, the embodiments of the present application also provide a chip test case generation device, the chip test case generation device is used to implement the technical solutions described in the above method embodiments. For example, each step of the method shown in any one of the above-mentioned Figs. 5-12 may be executed.
图14示出根据本申请一实施例的一种芯片的测试用例生成装置的结构图,如图14所示,该装置可以包括:传输模块1401,用于获取输入参数集合;所述输入参数集合包括芯片的M个输入参数,M为不小于1的整数;处理模块1402,用于将所述输入参数集合输入第一模型,生成第一测试用例集合;其中,第一测试用例包括:所述M个输入参数的取值,所述第一模型为利用第一测试用例训练样本训练所得到,所述第一测试用例训练样本中所述M个输入参数的取值满足预设约束。Fig. 14 shows a structural diagram of a device for generating test cases for a chip according to an embodiment of the present application. As shown in Fig. 14, the device may include: a transmission module 1401 for obtaining a set of input parameters; the set of input parameters It includes M input parameters of the chip, and M is an integer not less than 1; the processing module 1402 is configured to input the set of input parameters into the first model to generate a first set of test cases; wherein, the first test case includes: the The values of M input parameters, the first model is obtained by using the training samples of the first test case, and the values of the M input parameters in the first test case training samples satisfy the preset constraints.
在一种可能的实现方式中,所述处理模块1402,还用于:确定目标功能覆盖组,所述目标功能覆盖组包括待测试的目标功能;根据功能覆盖组与输入参数之间的关联信息,确定所述输入参数集合中与所述目标功能覆盖组相关联的N个目标输入参数,N为不大于M的正整数;其中,所述功能覆盖组与输入参数之间的关联信息为利用第二测试用例训练样本及所述第二测试用例训练样本对应的第一功能覆盖信息训练所得到;所述第二测试用例训练样本中所述M个输入参数的取值满足所述预设约束,所述第一功能覆盖信息表示各功能覆盖组中已被测试的功能和/或未被测试的功能;确定所述N个目标输入参数的至少一个第一取值组合;利用所述至少一个第一取值组合中的每一个,替代所述第一测试用例集合中的所述N个目标输入参数的一个第二取值组合,得到第二测试用例集合,其中,第二测试用例包括所述M个输入参数的取值。In a possible implementation, the processing module 1402 is further configured to: determine the target function coverage group, the target function coverage group includes the target function to be tested; according to the association information between the function coverage group and the input parameters , determine N target input parameters associated with the target function coverage group in the input parameter set, N is a positive integer not greater than M; wherein, the association information between the function coverage group and the input parameters is utilized The second test case training sample and the first function coverage information corresponding to the second test case training sample are obtained through training; the values of the M input parameters in the second test case training sample satisfy the preset constraints , the first function coverage information represents the tested functions and/or untested functions in each function coverage group; determine at least one first value combination of the N target input parameters; use the at least one Each of the first value combinations replaces a second value combination of the N target input parameters in the first test case set to obtain a second test case set, wherein the second test case includes all Describe the values of the M input parameters.
在一种可能的实现方式中,所述处理模块1402,还用于:根据所述N个目标输入参数的预设取值范围,随机生成多个候选取值组合;将所述多个候选取值组合中的任一取值组合作为初始迭代回合对应的取值组合;从所述多个候选取值组合中,确定当前迭代回合对应的取值组合;其中,所述当前迭代回合对应的取值组合与已确定的各迭代回合对应的取值组合的差异最大;重复执行上述确定当前迭代回合对应的取值组合的操作,直到满足预设迭代条件;并将各迭代回合对应的取值组合作为所述至少一个第一取值组合。In a possible implementation manner, the processing module 1402 is further configured to: randomly generate multiple candidate value combinations according to the preset value ranges of the N target input parameters; Any value combination in the value combination is used as the value combination corresponding to the initial iteration round; from the plurality of candidate value combinations, determine the value combination corresponding to the current iteration round; wherein, the value corresponding to the current iteration round The difference between the value combination and the determined value combination corresponding to each iteration round is the largest; repeat the operation of determining the value combination corresponding to the current iteration round until the preset iteration condition is satisfied; and combine the value combinations corresponding to each iteration round As the at least one first value combination.
在一种可能的实现方式中,所述处理模块1402,还用于:过滤掉所述第二测试用例集合中所述M个输入参数的取值不满足所述预设约束的第二测试用例。In a possible implementation manner, the processing module 1402 is further configured to: filter out second test cases whose values of the M input parameters in the second test case set do not satisfy the preset constraints .
在一种可能的实现方式中,所述处理模块1402,还用于:获取所述第一测试用例集合对应的第二功能覆盖信息,所述第二功能覆盖信息包括各功能覆盖组中未被测试的功能的个数;根据所述第一测试用例集合对应的第二功能覆盖信息,确定第一测试用例集合对应的各功能覆盖组的启发式分数,所述启发式分数与功能覆盖组中未被测试的功能的个数正相关;根据所述各功能覆盖组的启发式分数,确定所述各功能覆盖组对应的概率;基于各功能覆盖组对应的概率,确定至少一个目标功能覆盖组。In a possible implementation manner, the processing module 1402 is further configured to: obtain the second function coverage information corresponding to the first test case set, the second function coverage information includes The number of functions tested; according to the second function coverage information corresponding to the first test case set, determine the heuristic score of each function coverage group corresponding to the first test case set, and the heuristic score is the same as that in the function coverage group The number of untested functions is positively correlated; according to the heuristic scores of each functional coverage group, determine the probability corresponding to each functional coverage group; based on the probability corresponding to each functional coverage group, determine at least one target functional coverage group .
在一种可能的实现方式中,所述处理模块1402,还用于:根据所述第一测试用例集合对应的各功能覆盖组中未被测试的功能的个数,确定所述第一测试用例集合对应的未被测试的功能总数;根据所述各功能覆盖组中未被测试的功能的个数占所述未被测试的功能总数的比重,确定所述各功能覆盖组的启发式分数。In a possible implementation manner, the processing module 1402 is further configured to: determine the first test case according to the number of untested functions in each function coverage group corresponding to the first test case set The total number of untested functions corresponding to the set; according to the proportion of the number of untested functions in each functional coverage group to the total number of untested functions, determine the heuristic score of each functional coverage group.
在一种可能的实现方式中,所述处理模块1402,还用于:获取所述第一测试用例训练样本;利用所述第一测试用例训练样本对第一预设模型进行训练,得到所述第一模型。In a possible implementation manner, the processing module 1402 is further configured to: obtain the first test case training sample; use the first test case training sample to train the first preset model to obtain the first model.
在一种可能的实现方式中,所述第一预设模型包括生成对抗网络,所述生成对抗网络包含生成器及判别器;所述处理模块1402,还用于:利用所述第一测试用例训练样本对所述生成对抗网络进行多轮训练;并确定每轮训练收敛时的生成器对应的测试用例不变率,所述测试用例不变率表示生成器生成的测试用例的M个输入参数中取值符合所述预设约束的输入参数的比率;将与最大测试用例不变率对应的生成器,作为所述第一模型。In a possible implementation manner, the first preset model includes a generative adversarial network, and the generative adversarial network includes a generator and a discriminator; the processing module 1402 is further configured to: utilize the first test case The training samples carry out multiple rounds of training to the generation confrontation network; and determine the test case invariance rate corresponding to the generator when each round of training converges, and the test case invariance rate represents the M input parameters of the test case generated by the generator The ratio of the input parameters whose values meet the preset constraints; the generator corresponding to the maximum test case invariance rate is used as the first model.
在一种可能的实现方式中,所述处理模块1402,还用于:利用收敛时的判别器,过滤掉所述第二测试用例集合中所述M个输入参数不满足所述预设约束的第二测试用例。In a possible implementation, the processing module 1402 is further configured to: filter out the M input parameters in the second test case set that do not satisfy the preset constraints by using the discriminator during convergence. Second test case.
在一种可能的实现方式中,所述处理模块1402,还用于:获取所述第二测试用例训练样本及所述第二测试用例训练样本对应的第一功能覆盖信息;利用所述第二测试用例训练样本 及所述第一功能覆盖信息对第二预设模型进行训练,得到所述功能覆盖组与输入参数之间的关联信息。In a possible implementation manner, the processing module 1402 is further configured to: obtain the second test case training sample and the first function coverage information corresponding to the second test case training sample; use the second The test case training sample and the first function coverage information train the second preset model to obtain the association information between the function coverage group and the input parameters.
在一种可能的实现方式中,所述第二预设模型包括随机森林模型;所述处理模块1402,还用于:针对所述目标功能覆盖组,将所述第二测试用例训练样本输入到所述随机森林模型,并以所述第一功能覆盖信息作为标签,训练所述随机森林模型,得到所述功能覆盖组与输入参数之间的关联信息。In a possible implementation manner, the second preset model includes a random forest model; the processing module 1402 is further configured to: for the target function coverage group, input the second test case training sample into The random forest model uses the first functional coverage information as a label to train the random forest model to obtain association information between the functional coverage group and input parameters.
在一种可能的实现方式中,所述处理模块1402,还用于:针对每一第一取值组合,确定与该第一取值组合的相似度满足预设条件的第二取值组合,作为该第一取值组合的目标第二取值组合;利用该第一取值组合替代所述目标第二取值组合。In a possible implementation manner, the processing module 1402 is further configured to: for each first value combination, determine a second value combination whose similarity with the first value combination satisfies a preset condition, A target second value combination as the first value combination; using the first value combination to replace the target second value combination.
上述图14所示的芯片的测试用例生成装置及其各种可能的实现方式的技术效果及具体描述可参见上述芯片的测试用例生成方法,此处不再赘述。For the technical effects and specific descriptions of the device for generating test cases for the chip shown in FIG. 14 and its various possible implementations, please refer to the method for generating test cases for the chip above, which will not be repeated here.
需要说明的是,应理解以上芯片的测试用例生成装置的各个模块的划分仅仅是一种逻辑功能的划分,实际实现时可以全部或部分集成到一个物理实体上,也可以物理上分开。且这些模块可以全部以软件通过处理元件调度的形式实现;也可以全部以硬件的形式实现;还可以部分模块通过处理元件调度软件的形式实现,部分模块通过硬件的形式实现。It should be noted that it should be understood that the division of each module of the test case generation device for the above chip is only a division of logical functions, and may be fully or partially integrated into a physical entity or physically separated during actual implementation. And these modules can all be implemented in the form of software through scheduling of processing elements; they can also be implemented in the form of hardware; some modules can also be implemented in the form of processing element scheduling software, and some modules can be implemented in the form of hardware.
本申请的实施例提供了一种芯片的测试用例生成装置,包括:处理器以及用于存储处理器可执行指令的存储器;其中,所述处理器被配置为执行所述指令时实现上述方法。示例性地,可以实现上述图5-图12中任一所示的芯片的测试用例生成方法。An embodiment of the present application provides a device for generating test cases for a chip, including: a processor and a memory for storing instructions executable by the processor; wherein the processor is configured to implement the above method when executing the instructions. Exemplarily, the test case generation method for the chip shown in any one of the above-mentioned FIGS. 5-12 can be implemented.
图15示出根据本申请一实施例的一种芯片的测试用例生成装置的结构示意图,如图15所示,该芯片的测试用例生成装置可以包括:至少一个处理器1501,通信线路1502,存储器1503以及至少一个通信接口1504。Fig. 15 shows a schematic structural diagram of a test case generation device for a chip according to an embodiment of the present application. As shown in Fig. 15, the test case generation device for the chip may include: at least one processor 1501, a communication line 1502, and a memory 1503 and at least one communication interface 1504.
处理器1501可以是一个通用中央处理器(central processing unit,CPU),微处理器,特定应用集成电路(application-specific integrated circuit,ASIC),或一个或多个用于控制本申请方案程序执行的集成电路。The processor 1501 can be a general-purpose central processing unit (central processing unit, CPU), a microprocessor, a specific application integrated circuit (application-specific integrated circuit, ASIC), or one or more for controlling the execution of the application program program integrated circuit.
通信线路1502可包括一通路,在上述组件之间传送信息。Communication line 1502 may include a pathway for communicating information between the above-described components.
通信接口1504,使用任何收发器一类的装置,用于与其他设备或通信网络通信,如以太网,RAN,无线局域网(wireless local area networks,WLAN)等。The communication interface 1504 uses any device such as a transceiver to communicate with other devices or communication networks, such as Ethernet, RAN, wireless local area networks (wireless local area networks, WLAN) and so on.
存储器1503可以是只读存储器(read-only memory,ROM)或可存储静态信息和指令的其他类型的静态存储设备,随机存取存储器(random access memory,RAM)或者可存储信息和指令的其他类型的动态存储设备,也可以是电可擦可编程只读存储器(electrically erasable programmable read-only memory,EEPROM)、只读光盘(compact disc read-only memory,CD-ROM)或其他光盘存储、光碟存储(包括压缩光碟、激光碟、光碟、数字通用光碟、蓝光光碟等)、磁盘存储介质或者其他磁存储设备、或者能够用于携带或存储具有指令或数据结构形式的期望的程序代码并能够由计算机存取的任何其他介质,但不限于此。存储器可以是独立存在,通过通信线路1502与处理器相连接。存储器也可以和处理器集成在一起。本申请实施例提供的存储器通常可以具有非易失性。其中,存储器1503用于存储执行本申请方案的计算机执行指令,并由处理器1501来控制执行。处理器1501用于执行存储器1503中存储的计算机执行指令,从而实现本申请上述实施例中提供的方法。示例性地,可以实现上述图5-图12中任一所示方法的各步骤。The memory 1503 can be a read-only memory (read-only memory, ROM) or other types of static storage devices that can store static information and instructions, random access memory (random access memory, RAM) or other types that can store information and instructions It can also be an electrically erasable programmable read-only memory (EEPROM), compact disc read-only memory (CD-ROM) or other optical disc storage, optical disc storage (including compact discs, laser discs, optical discs, digital versatile discs, Blu-ray discs, etc.), magnetic disk storage media or other magnetic storage devices, or can be used to carry or store desired program code in the form of instructions or data structures and can be programmed by a computer Any other medium accessed, but not limited to. The memory may exist independently and be connected to the processor through the communication line 1502 . Memory can also be integrated with the processor. The memory provided by the embodiment of the present application may generally be non-volatile. Wherein, the memory 1503 is used to store computer-executed instructions for implementing the solutions of the present application, and the execution is controlled by the processor 1501 . The processor 1501 is configured to execute computer-executed instructions stored in the memory 1503, so as to implement the methods provided in the foregoing embodiments of the present application. Exemplarily, each step of the method shown in any one of the above-mentioned Figs. 5-12 can be implemented.
可选的,本申请实施例中的计算机执行指令也可以称之为应用程序代码,本申请实施例对此不作具体限定。Optionally, the computer-executed instructions in the embodiments of the present application may also be referred to as application program codes, which is not specifically limited in the embodiments of the present application.
示例性地,处理器1501可以包括一个或多个CPU,例如图15中的CPU0和CPU1。Exemplarily, the processor 1501 may include one or more CPUs, such as CPU0 and CPU1 in FIG. 15 .
示例性地,芯片的测试用例生成装置可以包括多个处理器,例如图15中的处理器1501和处理器1507。这些处理器中的每一个可以是一个单核(single-CPU)处理器,也可以是一个多核(multi-CPU)处理器。这里的处理器可以指一个或多个设备、电路、和/或用于处理数据(例如计算机程序指令)的处理核。Exemplarily, the device for generating test cases of a chip may include multiple processors, such as processor 1501 and processor 1507 in FIG. 15 . Each of these processors may be a single-core (single-CPU) processor or a multi-core (multi-CPU) processor. A processor herein may refer to one or more devices, circuits, and/or processing cores for processing data (eg, computer program instructions).
在具体实现中,作为一种实施例,芯片的测试用例生成装置还可以包括输出设备1505和输入设备1506。输出设备1505和处理器1501通信,可以以多种方式来显示信息。例如,输出设备1505可以是液晶显示器(liquid crystal display,LCD),发光二级管(light emitting diode,LED)显示设备,阴极射线管(cathode ray tube,CRT)显示设备,或投影仪(projector)等。输入设备1506和处理器1501通信,可以以多种方式接收用户的输入。例如,输入设备1506可以是鼠标、键盘、触摸屏设备或传感设备等。In a specific implementation, as an embodiment, the device for generating test cases for a chip may further include an output device 1505 and an input device 1506 . Output device 1505 is in communication with processor 1501 and can display information in a variety of ways. For example, the output device 1505 may be a liquid crystal display (liquid crystal display, LCD), a light emitting diode (light emitting diode, LED) display device, a cathode ray tube (cathode ray tube, CRT) display device, or a projector (projector) wait. The input device 1506 communicates with the processor 1501 and can receive user input in various ways. For example, the input device 1506 may be a mouse, a keyboard, a touch screen device, or a sensory device, among others.
作为一个示例,结合图15所示的芯片的测试用例生成装置,上述图14中的传输模块1401可以由图15中的通信接口1504来实现;上述图14中的处理模块1402可以由图15中的处理器1501来实现。As an example, combined with the test case generating device of the chip shown in FIG. 15, the transmission module 1401 in FIG. 14 above can be realized by the communication interface 1504 in FIG. The processor 1501 is implemented.
本申请的实施例提供了一种非易失性计算机可读存储介质,其上存储有计算机程序指令,所述计算机程序指令被处理器执行时实现上述方法。示例性地,可以实现上述图5-图12中任一所示方法的各步骤。An embodiment of the present application provides a non-volatile computer-readable storage medium, on which computer program instructions are stored, and when the computer program instructions are executed by a processor, the foregoing method is realized. Exemplarily, each step of the method shown in any one of the above-mentioned Figs. 5-12 can be implemented.
本申请的实施例提供了一种计算机程序产品,包括计算机可读代码,或者承载有计算机可读代码的非易失性计算机可读存储介质,当所述计算机可读代码在电子设备的处理器中运行时,所述电子设备中的处理器执行上述方法。示例性地,可以实现上述图5-图12中任一所示方法的各步骤。An embodiment of the present application provides a computer program product, including computer-readable codes, or a non-volatile computer-readable storage medium bearing computer-readable codes, when the computer-readable codes are stored in a processor of an electronic device When running in the electronic device, the processor in the electronic device executes the above method. Exemplarily, each step of the method shown in any one of the above-mentioned Figs. 5-12 can be implemented.
计算机可读存储介质可以是可以保持和存储由指令执行设备使用的指令的有形设备。计算机可读存储介质例如可以是――但不限于――电存储设备、磁存储设备、光存储设备、电磁存储设备、半导体存储设备或者上述的任意合适的组合。计算机可读存储介质的更具体的例子(非穷举的列表)包括:便携式计算机盘、硬盘、随机存取存储器(Random Access Memory,RAM)、只读存储器(Read Only Memory,ROM)、可擦式可编程只读存储器(Electrically Programmable Read-Only-Memory,EPROM或闪存)、静态随机存取存储器(Static Random-Access Memory,SRAM)、便携式压缩盘只读存储器(Compact Disc Read-Only Memory,CD-ROM)、数字多功能盘(Digital Video Disc,DVD)、记忆棒、软盘、机械编码设备、例如其上存储有指令的打孔卡或凹槽内凸起结构、以及上述的任意合适的组合。A computer readable storage medium may be a tangible device that can retain and store instructions for use by an instruction execution device. A computer readable storage medium may be, for example, but is not limited to, an electrical storage device, a magnetic storage device, an optical storage device, an electromagnetic storage device, a semiconductor storage device, or any suitable combination of the foregoing. More specific examples (non-exhaustive list) of computer-readable storage media include: portable computer disk, hard disk, random access memory (Random Access Memory, RAM), read only memory (Read Only Memory, ROM), erasable Electrically Programmable Read-Only-Memory (EPROM or flash memory), Static Random-Access Memory (Static Random-Access Memory, SRAM), Portable Compression Disk Read-Only Memory (Compact Disc Read-Only Memory, CD - ROM), Digital Video Disc (DVD), memory sticks, floppy disks, mechanically encoded devices such as punched cards or raised structures in grooves with instructions stored thereon, and any suitable combination of the foregoing .
这里所描述的计算机可读程序指令或代码可以从计算机可读存储介质下载到各个计算/处理设备,或者通过网络、例如因特网、局域网、广域网和/或无线网下载到外部计算机或外部存储设备。网络可以包括铜传输电缆、光纤传输、无线传输、路由器、防火墙、交换机、网关计算机和/或边缘服务器。每个计算/处理设备中的网络适配卡或者网络接口从网络接收计算机可读程序指令,并转发该计算机可读程序指令,以供存储在各个计算/处理设备中的计算机可读存储介质中。Computer readable program instructions or codes described herein may be downloaded from a computer readable storage medium to a respective computing/processing device, or downloaded to an external computer or external storage device over a network, such as the Internet, local area network, wide area network, and/or wireless network. The network may include copper transmission cables, fiber optic transmission, wireless transmission, routers, firewalls, switches, gateway computers, and/or edge servers. A network adapter card or a network interface in each computing/processing device receives computer-readable program instructions from the network and forwards the computer-readable program instructions for storage in a computer-readable storage medium in each computing/processing device .
用于执行本申请操作的计算机程序指令可以是汇编指令、指令集架构(Instruction Set  Architecture,ISA)指令、机器指令、机器相关指令、微代码、固件指令、状态设置数据、或者以一种或多种编程语言的任意组合编写的源代码或目标代码,所述编程语言包括面向对象的编程语言—诸如Smalltalk、C++等,以及常规的过程式编程语言—诸如“C”语言或类似的编程语言。计算机可读程序指令可以完全地在用户计算机上执行、部分地在用户计算机上执行、作为一个独立的软件包执行、部分在用户计算机上部分在远程计算机上执行、或者完全在远程计算机或服务器上执行。在涉及远程计算机的情形中,远程计算机可以通过任意种类的网络—包括局域网(Local Area Network,LAN)或广域网(Wide Area Network,WAN)—连接到用户计算机,或者,可以连接到外部计算机(例如利用因特网服务提供商来通过因特网连接)。在一些实施例中,通过利用计算机可读程序指令的状态信息来个性化定制电子电路,例如可编程逻辑电路、现场可编程门阵列(Field-Programmable Gate Array,FPGA)或可编程逻辑阵列(Programmable Logic Array,PLA),该电子电路可以执行计算机可读程序指令,从而实现本申请的各个方面。Computer program instructions for performing the operations of the present application may be assembly instructions, instruction set architecture (Instruction Set Architecture, ISA) instructions, machine instructions, machine-related instructions, microcode, firmware instructions, state setting data, or in one or more source or object code written in any combination of programming languages, including object-oriented programming languages—such as Smalltalk, C++, etc., and conventional procedural programming languages—such as the “C” language or similar programming languages. Computer readable program instructions may execute entirely on the user's computer, partly on the user's computer, as a stand-alone software package, partly on the user's computer and partly on a remote computer, or entirely on the remote computer or server implement. In cases involving a remote computer, the remote computer can be connected to the user's computer through any kind of network, including a Local Area Network (LAN) or a Wide Area Network (WAN), or it can be connected to an external computer such as use an Internet service provider to connect via the Internet). In some embodiments, electronic circuits, such as programmable logic circuits, field-programmable gate arrays (Field-Programmable Gate Array, FPGA) or programmable logic arrays (Programmable Logic Array, PLA), the electronic circuit can execute computer-readable program instructions, thereby realizing various aspects of the present application.
这里参照根据本申请实施例的方法、装置(系统)和计算机程序产品的流程图和/或框图描述了本申请的各个方面。应当理解,流程图和/或框图的每个方框以及流程图和/或框图中各方框的组合,都可以由计算机可读程序指令实现。Aspects of the present application are described herein with reference to flowchart illustrations and/or block diagrams of methods, apparatus (systems) and computer program products according to embodiments of the application. It should be understood that each block of the flowcharts and/or block diagrams, and combinations of blocks in the flowcharts and/or block diagrams, can be implemented by computer-readable program instructions.
这些计算机可读程序指令可以提供给通用计算机、专用计算机或其它可编程数据处理装置的处理器,从而生产出一种机器,使得这些指令在通过计算机或其它可编程数据处理装置的处理器执行时,产生了实现流程图和/或框图中的一个或多个方框中规定的功能/动作的装置。也可以把这些计算机可读程序指令存储在计算机可读存储介质中,这些指令使得计算机、可编程数据处理装置和/或其他设备以特定方式工作,从而,存储有指令的计算机可读介质则包括一个制造品,其包括实现流程图和/或框图中的一个或多个方框中规定的功能/动作的各个方面的指令。These computer-readable program instructions may be provided to a processor of a general purpose computer, special purpose computer, or other programmable data processing apparatus to produce a machine such that when executed by the processor of the computer or other programmable data processing apparatus , producing an apparatus for realizing the functions/actions specified in one or more blocks in the flowchart and/or block diagram. These computer-readable program instructions can also be stored in a computer-readable storage medium, and these instructions cause computers, programmable data processing devices and/or other devices to work in a specific way, so that the computer-readable medium storing instructions includes An article of manufacture comprising instructions for implementing various aspects of the functions/acts specified in one or more blocks in flowcharts and/or block diagrams.
也可以把计算机可读程序指令加载到计算机、其它可编程数据处理装置、或其它设备上,使得在计算机、其它可编程数据处理装置或其它设备上执行一系列操作步骤,以产生计算机实现的过程,从而使得在计算机、其它可编程数据处理装置、或其它设备上执行的指令实现流程图和/或框图中的一个或多个方框中规定的功能/动作。It is also possible to load computer-readable program instructions into a computer, other programmable data processing device, or other equipment, so that a series of operational steps are performed on the computer, other programmable data processing device, or other equipment to produce a computer-implemented process , so that instructions executed on computers, other programmable data processing devices, or other devices implement the functions/actions specified in one or more blocks in the flowcharts and/or block diagrams.
附图中的流程图和框图显示了根据本申请的多个实施例的装置、系统、方法和计算机程序产品的可能实现的体系架构、功能和操作。在这点上,流程图或框图中的每个方框可以代表一个模块、程序段或指令的一部分,所述模块、程序段或指令的一部分包含一个或多个用于实现规定的逻辑功能的可执行指令。在有些作为替换的实现中,方框中所标注的功能也可以以不同于附图中所标注的顺序发生。例如,两个连续的方框实际上可以基本并行地执行,它们有时也可以按相反的顺序执行,这依所涉及的功能而定。The flowchart and block diagrams in the figures show the architecture, functions and operations of possible implementations of apparatuses, systems, methods and computer program products according to various embodiments of the present application. In this regard, each block in a flowchart or block diagram may represent a module, a portion of a program segment, or an instruction that includes one or more Executable instructions. In some alternative implementations, the functions noted in the block may occur out of the order noted in the figures. For example, two blocks in succession may, in fact, be executed substantially concurrently, or they may sometimes be executed in the reverse order, depending upon the functionality involved.
也要注意的是,框图和/或流程图中的每个方框、以及框图和/或流程图中的方框的组合,可以用执行相应的功能或动作的硬件(例如电路或ASIC(Application Specific Integrated Circuit,专用集成电路))来实现,或者可以用硬件和软件的组合,如固件等来实现。It should also be noted that each block in the block diagrams and/or flowcharts, and combinations of blocks in the block diagrams and/or flowcharts, can be implemented with hardware (such as circuits or ASIC (Application Specific Integrated Circuit, application-specific integrated circuit)), or it can be realized by a combination of hardware and software, such as firmware.
尽管在此结合各实施例对本发明进行了描述,然而,在实施所要求保护的本发明过程中,本领域技术人员通过查看所述附图、公开内容、以及所附权利要求书,可理解并实现所述公开实施例的其它变化。在权利要求中,“包括”(comprising)一词不排除其他组成部分或步骤,“一”或“一个”不排除多个的情况。单个处理器或其它单元可以实现权利要求中列 举的若干项功能。相互不同的从属权利要求中记载了某些措施,但这并不表示这些措施不能组合起来产生良好的效果。Although the present invention has been described in conjunction with various embodiments herein, in the process of implementing the claimed invention, those skilled in the art can understand and Other variations of the disclosed embodiments are implemented. In the claims, the word "comprising" does not exclude other components or steps, and "a" or "an" does not exclude a plurality. A single processor or other unit may fulfill the functions of several items recited in the claims. The mere fact that certain measures are recited in mutually different dependent claims does not indicate that these measures cannot be combined to advantage.
以上已经描述了本申请的各实施例,上述说明是示例性的,并非穷尽性的,并且也不限于所披露的各实施例。在不偏离所说明的各实施例的范围的情况下,对于本技术领域的普通技术人员来说许多修改和变更都是显而易见的。本文中所用术语的选择,旨在最好地解释各实施例的原理、实际应用或对市场中的技术的改进,或者使本技术领域的其它普通技术人员能理解本文披露的各实施例。Having described various embodiments of the present application above, the foregoing description is exemplary, not exhaustive, and is not limited to the disclosed embodiments. Many modifications and alterations will be apparent to those of ordinary skill in the art without departing from the scope of the described embodiments. The terminology used herein is chosen to best explain the principle of each embodiment, practical application or improvement of technology in the market, or to enable other ordinary skilled in the art to understand each embodiment disclosed herein.

Claims (27)

  1. 一种芯片的测试用例生成方法,其特征在于,所述方法包括:A test case generation method for a chip, characterized in that the method comprises:
    获取输入参数集合;所述输入参数集合包括芯片的M个输入参数,M为不小于1的整数;Obtain an input parameter set; the input parameter set includes M input parameters of the chip, and M is an integer not less than 1;
    将所述输入参数集合输入第一模型,生成第一测试用例集合;其中,第一测试用例包括:所述M个输入参数的取值,所述第一模型为利用第一测试用例训练样本训练所得到,所述第一测试用例训练样本中所述M个输入参数的取值满足预设约束。The input parameter set is input into the first model to generate a first test case set; wherein, the first test case includes: the values of the M input parameters, and the first model uses the first test case training sample training As a result, the values of the M input parameters in the training samples of the first test case satisfy preset constraints.
  2. 根据权利要求1所述的方法,其特征在于,所述方法还包括:The method according to claim 1, further comprising:
    确定目标功能覆盖组,所述目标功能覆盖组包括待测试的目标功能;determining a target function coverage group, the target function coverage group including the target function to be tested;
    根据功能覆盖组与输入参数之间的关联信息,确定所述输入参数集合中与所述目标功能覆盖组相关联的N个目标输入参数,N为不大于M的正整数;其中,所述功能覆盖组与输入参数之间的关联信息为利用第二测试用例训练样本及所述第二测试用例训练样本对应的第一功能覆盖信息训练所得到;所述第二测试用例训练样本中所述M个输入参数的取值满足所述预设约束,所述第一功能覆盖信息表示各功能覆盖组中已被测试的功能和/或未被测试的功能;According to the association information between the function coverage group and the input parameters, determine N target input parameters associated with the target function coverage group in the input parameter set, N is a positive integer not greater than M; wherein the function The association information between the coverage group and the input parameters is obtained by using the second test case training sample and the first function coverage information corresponding to the second test case training sample; the M in the second test case training sample The value of each input parameter satisfies the preset constraint, and the first function coverage information indicates the tested functions and/or untested functions in each function coverage group;
    确定所述N个目标输入参数的至少一个第一取值组合;determining at least one first value combination of the N target input parameters;
    利用所述至少一个第一取值组合中的每一个,替代所述第一测试用例集合中的所述N个目标输入参数的一个第二取值组合,得到第二测试用例集合,其中,第二测试用例包括所述M个输入参数的取值。Using each of the at least one first value combination to replace one second value combination of the N target input parameters in the first test case set to obtain a second test case set, wherein the first test case set The second test case includes the values of the M input parameters.
  3. 根据权利要求2所述的方法,其特征在于,所述确定所述N个目标输入参数的至少一个第一取值组合,包括:The method according to claim 2, wherein said determining at least one first value combination of said N target input parameters comprises:
    根据所述N个目标输入参数的预设取值范围,随机生成多个候选取值组合;Randomly generate multiple candidate value combinations according to the preset value ranges of the N target input parameters;
    将所述多个候选取值组合中的任一取值组合作为初始迭代回合对应的取值组合;Using any value combination in the plurality of candidate value combinations as the value combination corresponding to the initial iteration round;
    从所述多个候选取值组合中,确定当前迭代回合对应的取值组合;其中,所述当前迭代回合对应的取值组合与已确定的各迭代回合对应的取值组合的差异最大;From the plurality of candidate value combinations, determine the value combination corresponding to the current iteration round; wherein, the value combination corresponding to the current iteration round has the largest difference from the determined value combination corresponding to each iteration round;
    重复执行上述确定当前迭代回合对应的取值组合的操作,直到满足预设迭代条件;并将各迭代回合对应的取值组合作为所述至少一个第一取值组合。The above operation of determining the value combination corresponding to the current iteration round is repeatedly performed until the preset iteration condition is met; and the value combination corresponding to each iteration round is used as the at least one first value combination.
  4. 根据权利要求2或3所述的方法,其特征在于,所述方法还包括:The method according to claim 2 or 3, characterized in that the method further comprises:
    过滤掉所述第二测试用例集合中所述M个输入参数的取值不满足所述预设约束的第二测试用例。Filtering out second test cases whose values of the M input parameters do not satisfy the preset constraints in the second test case set.
  5. 根据权利要求2-4中任一项所述的方法,其特征在于,所述确定目标功能覆盖组,包括:The method according to any one of claims 2-4, wherein said determining the target function coverage group comprises:
    获取所述第一测试用例集合对应的第二功能覆盖信息,所述第二功能覆盖信息包括各功能覆盖组中未被测试的功能的个数;Obtaining the second function coverage information corresponding to the first test case set, the second function coverage information including the number of untested functions in each function coverage group;
    根据所述第一测试用例集合对应的第二功能覆盖信息,确定第一测试用例集合对应的各功能覆盖组的启发式分数,所述启发式分数与功能覆盖组中未被测试的功能的个数正相关;According to the second functional coverage information corresponding to the first test case set, determine the heuristic score of each functional coverage group corresponding to the first test case set, and the heuristic score is consistent with the number of untested functions in the functional coverage group. number positive correlation;
    根据所述各功能覆盖组的启发式分数,确定所述各功能覆盖组对应的概率;determining the probability corresponding to each functional coverage group according to the heuristic score of each functional coverage group;
    基于各功能覆盖组对应的概率,确定至少一个目标功能覆盖组。Based on the probability corresponding to each functional coverage group, at least one target functional coverage group is determined.
  6. 根据权利要求5所述的方法,其特征在于,所述根据所述第一测试用例集合对应的第二功能覆盖信息,确定第一测试用例集合对应的各功能覆盖组的启发式分数,包括:The method according to claim 5, wherein, according to the second functional coverage information corresponding to the first test case set, determining the heuristic score of each functional coverage group corresponding to the first test case set comprises:
    根据所述第一测试用例集合对应的各功能覆盖组中未被测试的功能的个数,确定所述第一测试用例集合对应的未被测试的功能总数;Determine the total number of untested functions corresponding to the first test case set according to the number of untested functions in each function coverage group corresponding to the first test case set;
    根据所述各功能覆盖组中未被测试的功能的个数占所述未被测试的功能总数的比重,确定所述各功能覆盖组的启发式分数。The heuristic score of each function coverage group is determined according to the ratio of the number of untested functions in each function coverage group to the total number of untested functions.
  7. 根据权利要求1-6中任一项所述的方法,其特征在于,所述方法还包括:The method according to any one of claims 1-6, wherein the method further comprises:
    获取所述第一测试用例训练样本;Obtain the first test case training sample;
    利用所述第一测试用例训练样本对第一预设模型进行训练,得到所述第一模型。The first preset model is trained by using the first test case training samples to obtain the first model.
  8. 根据权利要求7所述的方法,其特征在于,所述第一预设模型包括生成对抗网络,所述生成对抗网络包含生成器及判别器;The method according to claim 7, wherein the first preset model includes a generative confrontation network, and the generative confrontation network includes a generator and a discriminator;
    所述利用所述第一测试用例训练样本对第一预设模型进行训练,得到所述第一模型,包 括:The first preset model is trained using the first test case training sample to obtain the first model, including:
    利用所述第一测试用例训练样本对所述生成对抗网络进行多轮训练;并确定每轮训练收敛时的生成器对应的测试用例不变率,所述测试用例不变率表示生成器生成的测试用例的M个输入参数中取值符合所述预设约束的输入参数的比率;Use the first test case training sample to carry out multiple rounds of training to the generation confrontation network; and determine the test case invariance rate corresponding to the generator when each round of training converges, and the test case invariance rate represents the generator generated by the test case. Among the M input parameters of the test case, the ratio of the input parameters whose values meet the preset constraints;
    将与最大测试用例不变率对应的生成器,作为所述第一模型。The generator corresponding to the maximum test case invariance rate is used as the first model.
  9. 根据权利要求8所述的方法,其特征在于,所述方法还包括:利用收敛时的判别器,过滤掉所述第二测试用例集合中所述M个输入参数不满足所述预设约束的第二测试用例。The method according to claim 8, characterized in that, the method further comprises: using a convergent discriminator to filter out the M input parameters in the second test case set that do not satisfy the preset constraints Second test case.
  10. 根据权利要求2-9中任一项所述的方法,其特征在于,所述方法还包括:The method according to any one of claims 2-9, wherein the method further comprises:
    获取所述第二测试用例训练样本及所述第二测试用例训练样本对应的第一功能覆盖信息;Acquiring the second test case training samples and the first function coverage information corresponding to the second test case training samples;
    利用所述第二测试用例训练样本及所述第一功能覆盖信息对第二预设模型进行训练,得到所述功能覆盖组与输入参数之间的关联信息。The second preset model is trained by using the second test case training sample and the first function coverage information to obtain the association information between the function coverage group and the input parameters.
  11. 根据权利要求10所述的方法,其特征在于,所述第二预设模型包括随机森林模型;The method according to claim 10, wherein the second preset model comprises a random forest model;
    所述利用所述第二测试用例训练样本及所述第一功能覆盖信息对所述第二预设模型进行训练,得到所述功能覆盖组与输入参数之间的关联信息,包括:The step of using the second test case training sample and the first function coverage information to train the second preset model to obtain the association information between the function coverage group and input parameters includes:
    针对所述目标功能覆盖组,将所述第二测试用例训练样本输入到所述随机森林模型,并以所述第一功能覆盖信息作为标签,训练所述随机森林模型,得到所述功能覆盖组与输入参数之间的关联信息。For the target functional coverage group, input the second test case training sample into the random forest model, and use the first functional coverage information as a label to train the random forest model to obtain the functional coverage group Correlation information with input parameters.
  12. 根据权利要求2-11中任一项所述的方法,其特征在于,利用所述至少一个第一取值组合中的每一个,替代所述第一测试用例集合中的所述N个目标输入参数的一个第二取值组合,包括:The method according to any one of claims 2-11, wherein each of the at least one first value combination is used to replace the N target inputs in the first test case set A second combination of values for the parameter, including:
    针对每一第一取值组合,确定与该第一取值组合的相似度满足预设条件的第二取值组合,作为该第一取值组合的目标第二取值组合;For each first value combination, determine a second value combination whose similarity with the first value combination satisfies a preset condition, as the target second value combination of the first value combination;
    利用该第一取值组合替代所述目标第二取值组合。Using the first value combination to replace the target second value combination.
  13. 一种芯片的测试用例生成装置,其特征在于,所述装置包括:A test case generation device for a chip, characterized in that the device comprises:
    传输模块,用于获取输入参数集合;所述输入参数集合包括芯片的M个输入参数,M为不小于1的整数;The transmission module is used to obtain an input parameter set; the input parameter set includes M input parameters of the chip, and M is an integer not less than 1;
    处理模块,用于将所述输入参数集合输入第一模型,生成第一测试用例集合;其中,第一测试用例包括:所述M个输入参数的取值,所述第一模型为利用第一测试用例训练样本训练所得到,所述第一测试用例训练样本中所述M个输入参数的取值满足预设约束。A processing module, configured to input the set of input parameters into a first model to generate a first set of test cases; wherein, the first test case includes: the values of the M input parameters, and the first model uses the first The values of the M input parameters in the first test case training sample satisfy preset constraints.
  14. 根据权利要求13所述的装置,其特征在于,所述处理模块,还用于:确定目标功能覆盖组,所述目标功能覆盖组包括待测试的目标功能;根据功能覆盖组与输入参数之间的关联信息,确定所述输入参数集合中与所述目标功能覆盖组相关联的N个目标输入参数,N为不大于M的正整数;其中,所述功能覆盖组与输入参数之间的关联信息为利用第二测试用例训练样本及所述第二测试用例训练样本对应的第一功能覆盖信息训练所得到;所述第二测试用例训练样本中所述M个输入参数的取值满足所述预设约束,所述第一功能覆盖信息表示各功能覆盖组中已被测试的功能和/或未被测试的功能;确定所述N个目标输入参数的至少一个第一取值组合;利用所述至少一个第一取值组合中的每一个,替代所述第一测试用例集合中的所述N个目标输入参数的一个第二取值组合,得到第二测试用例集合,其中,第二测试用例包括所述M个输入参数的取值。The device according to claim 13, wherein the processing module is further configured to: determine the target function coverage group, the target function coverage group includes the target function to be tested; according to the relationship between the function coverage group and the input parameters The associated information, determine the N target input parameters associated with the target function coverage group in the input parameter set, N is a positive integer not greater than M; wherein, the association between the function coverage group and the input parameters The information is obtained by using the second test case training sample and the first function coverage information corresponding to the second test case training sample; the values of the M input parameters in the second test case training sample satisfy the Preset constraints, the first function coverage information indicates the tested functions and/or untested functions in each function coverage group; determine at least one first value combination of the N target input parameters; use the For each of the at least one first value combination, replace a second value combination of the N target input parameters in the first test case set to obtain a second test case set, wherein the second test case The use case includes the values of the M input parameters.
  15. 根据权利要求14所述的装置,其特征在于,所述处理模块,还用于:根据所述N个目标输入参数的预设取值范围,随机生成多个候选取值组合;将所述多个候选取值组合中的任一取值组合作为初始迭代回合对应的取值组合;从所述多个候选取值组合中,确定当前迭代回合对应的取值组合;其中,所述当前迭代回合对应的取值组合与已确定的各迭代回合对应的取值组合的差异最大;重复执行上述确定当前迭代回合对应的取值组合的操作,直到满足预设迭代条件;并将各迭代回合对应的取值组合作为所述至少一个第一取值组合。The device according to claim 14, wherein the processing module is further configured to: randomly generate a plurality of candidate value combinations according to the preset value ranges of the N target input parameters; Any value combination in the candidate value combination is used as the value combination corresponding to the initial iteration round; from the plurality of candidate value combinations, determine the value combination corresponding to the current iteration round; wherein, the current iteration round The difference between the corresponding value combination and the determined value combination corresponding to each iteration round is the largest; repeat the above-mentioned operation of determining the value combination corresponding to the current iteration round until the preset iteration condition is satisfied; A combination of values is used as the at least one first combination of values.
  16. 根据权利要求14或15所述的装置,其特征在于,所述处理模块,还用于:过滤掉所述第二测试用例集合中所述M个输入参数的取值不满足所述预设约束的第二测试用例。The device according to claim 14 or 15, wherein the processing module is further configured to: filter out values of the M input parameters in the second test case set that do not satisfy the preset constraints The second test case for .
  17. 根据权利要求14-16中任一项所述的装置,其特征在于,所述处理模块,还用于:获取所述第一测试用例集合对应的第二功能覆盖信息,所述第二功能覆盖信息包括各功能覆盖组中未被测试的功能的个数;根据所述第一测试用例集合对应的第二功能覆盖信息,确定第一测试用例集合对应的各功能覆盖组的启发式分数,所述启发式分数与功能覆盖组中未被测试的功能的个数正相关;根据所述各功能覆盖组的启发式分数,确定所述各功能覆盖组对 应的概率;基于各功能覆盖组对应的概率,确定至少一个目标功能覆盖组。The device according to any one of claims 14-16, wherein the processing module is further configured to: obtain the second function coverage information corresponding to the first test case set, the second function coverage The information includes the number of untested functions in each function coverage group; according to the second function coverage information corresponding to the first test case set, determine the heuristic score of each function coverage group corresponding to the first test case set, so The heuristic score is positively correlated with the number of untested functions in the functional coverage group; according to the heuristic scores of the functional coverage groups, the probability corresponding to each functional coverage group is determined; based on the corresponding probability of each functional coverage group probabilistically, at least one target functional coverage group is identified.
  18. 根据权利要求17所述的装置,其特征在于,所述处理模块,还用于:根据所述第一测试用例集合对应的各功能覆盖组中未被测试的功能的个数,确定所述第一测试用例集合对应的未被测试的功能总数;根据所述各功能覆盖组中未被测试的功能的个数占所述未被测试的功能总数的比重,确定所述各功能覆盖组的启发式分数。The device according to claim 17, wherein the processing module is further configured to: determine the second function according to the number of untested functions in each function coverage group corresponding to the first test case set The total number of untested functions corresponding to a test case set; according to the ratio of the number of untested functions in each of the functional coverage groups to the total number of untested functions, determine the heuristic of each functional coverage group formula score.
  19. 根据权利要求13-18中任一项所述的装置,其特征在于,所述处理模块,还用于:获取所述第一测试用例训练样本;利用所述第一测试用例训练样本对第一预设模型进行训练,得到所述第一模型。The device according to any one of claims 13-18, wherein the processing module is further configured to: obtain the first test case training sample; use the first test case training sample to pair the first The preset model is trained to obtain the first model.
  20. 根据权利要求19所述的装置,其特征在于,所述第一预设模型包括生成对抗网络,所述生成对抗网络包含生成器及判别器;The device according to claim 19, wherein the first preset model includes a generative confrontation network, and the generative confrontation network includes a generator and a discriminator;
    所述处理模块,还用于:利用所述第一测试用例训练样本对所述生成对抗网络进行多轮训练;并确定每轮训练收敛时的生成器对应的测试用例不变率,所述测试用例不变率表示生成器生成的测试用例的M个输入参数中取值符合所述预设约束的输入参数的比率;将与最大测试用例不变率对应的生成器,作为所述第一模型。The processing module is also used to: use the first test case training sample to perform multiple rounds of training on the generative confrontation network; and determine the test case invariance rate corresponding to the generator when each round of training converges, the test The use case invariance rate represents the ratio of the input parameters whose values meet the preset constraints among the M input parameters of the test cases generated by the generator; the generator corresponding to the maximum test case invariance rate is used as the first model .
  21. 根据权利要求20所述的装置,其特征在于,所述处理模块,还用于:利用收敛时的判别器,过滤掉所述第二测试用例集合中所述M个输入参数不满足所述预设约束的第二测试用例。The device according to claim 20, wherein the processing module is further configured to: use a convergent discriminator to filter out the M input parameters in the second test case set that do not satisfy the predetermined A second test case with constraints.
  22. 根据权利要求14-21中任一项所述的装置,其特征在于,所述处理模块,还用于:获取所述第二测试用例训练样本及所述第二测试用例训练样本对应的第一功能覆盖信息;利用所述第二测试用例训练样本及所述第一功能覆盖信息对第二预设模型进行训练,得到所述功能覆盖组与输入参数之间的关联信息。The device according to any one of claims 14-21, wherein the processing module is further configured to: obtain the second test case training sample and the first test case corresponding to the second test case training sample. Functional coverage information: using the second test case training sample and the first functional coverage information to train a second preset model to obtain the correlation information between the functional coverage group and input parameters.
  23. 根据权利要求22所述的装置,其特征在于,所述第二预设模型包括随机森林模型;所述处理模块,还用于:针对所述目标功能覆盖组,将所述第二测试用例训练样本输入到所述随机森林模型,并以所述第一功能覆盖信息作为标签,训练所述随机森林模型,得到所述功能覆盖组与输入参数之间的关联信息。The device according to claim 22, wherein the second preset model includes a random forest model; and the processing module is further configured to train the second test case for the target function coverage group Samples are input into the random forest model, and the random forest model is trained by using the first functional coverage information as a label to obtain association information between the functional coverage group and input parameters.
  24. 根据权利要求14-23中任一项所述的装置,其特征在于,所述处理模块,还用于:针对每一第一取值组合,确定与该第一取值组合的相似度满足预设条件的第二取值组合,作为该第一取值组合的目标第二取值组合;利用该第一取值组合替代所述目标第二取值组合。The device according to any one of claims 14-23, wherein the processing module is further configured to: for each first value combination, determine that the similarity with the first value combination satisfies a predetermined Set the second value combination of the condition as the target second value combination of the first value combination; use the first value combination to replace the target second value combination.
  25. 一种芯片的测试用例生成装置,其特征在于,包括:A test case generation device for a chip, characterized in that it comprises:
    处理器;processor;
    用于存储处理器可执行指令的存储器;memory for storing processor-executable instructions;
    其中,所述处理器被配置为执行所述指令时实现权利要求1-12任意一项所述的方法。Wherein, the processor is configured to implement the method according to any one of claims 1-12 when executing the instructions.
  26. 一种计算机可读存储介质,其上存储有计算机程序指令,其特征在于,所述计算机程序指令被处理器执行时实现权利要求1-12中任意一项所述的方法。A computer-readable storage medium, on which computer program instructions are stored, wherein the computer program instructions implement the method according to any one of claims 1-12 when executed by a processor.
  27. 一种计算机程序产品,其特征在于,当所述计算机程序产品在计算机上运行时,使得所述计算机执行权利要求1-12中任一项所述的方法。A computer program product, characterized in that, when the computer program product is run on a computer, the computer is made to execute the method according to any one of claims 1-12.
PCT/CN2022/143439 2021-12-31 2022-12-29 Chip test case generation method and apparatus, and storage medium WO2023125821A1 (en)

Applications Claiming Priority (2)

Application Number Priority Date Filing Date Title
CN202111663515.6A CN116432570A (en) 2021-12-31 2021-12-31 Method and device for generating test case of chip and storage medium
CN202111663515.6 2021-12-31

Publications (1)

Publication Number Publication Date
WO2023125821A1 true WO2023125821A1 (en) 2023-07-06

Family

ID=86998018

Family Applications (1)

Application Number Title Priority Date Filing Date
PCT/CN2022/143439 WO2023125821A1 (en) 2021-12-31 2022-12-29 Chip test case generation method and apparatus, and storage medium

Country Status (2)

Country Link
CN (1) CN116432570A (en)
WO (1) WO2023125821A1 (en)

Cited By (4)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN116825169A (en) * 2023-08-31 2023-09-29 悦芯科技股份有限公司 Abnormal memory chip detection method based on test equipment
CN116932403A (en) * 2023-07-25 2023-10-24 太初(无锡)电子科技有限公司 Test case generation method
CN117291132A (en) * 2023-11-27 2023-12-26 上海小厘科技有限公司 Chip verification system, method and storage medium
CN118313174A (en) * 2024-06-11 2024-07-09 中国空气动力研究与发展中心计算空气动力研究所 Design method for separation parameters of suspension and carrier separation test

Citations (3)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN113076250A (en) * 2021-04-14 2021-07-06 南京大学 Dynamic random test method and device with constraint test model
CN113297060A (en) * 2020-05-11 2021-08-24 阿里巴巴集团控股有限公司 Data testing method and device
CN113407393A (en) * 2021-05-25 2021-09-17 鹏城实验室 Chip verification method, terminal device, verification platform and storage medium

Patent Citations (3)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN113297060A (en) * 2020-05-11 2021-08-24 阿里巴巴集团控股有限公司 Data testing method and device
CN113076250A (en) * 2021-04-14 2021-07-06 南京大学 Dynamic random test method and device with constraint test model
CN113407393A (en) * 2021-05-25 2021-09-17 鹏城实验室 Chip verification method, terminal device, verification platform and storage medium

Cited By (7)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN116932403A (en) * 2023-07-25 2023-10-24 太初(无锡)电子科技有限公司 Test case generation method
CN116932403B (en) * 2023-07-25 2024-06-11 太初(无锡)电子科技有限公司 Test case generation method
CN116825169A (en) * 2023-08-31 2023-09-29 悦芯科技股份有限公司 Abnormal memory chip detection method based on test equipment
CN116825169B (en) * 2023-08-31 2023-11-24 悦芯科技股份有限公司 Abnormal memory chip detection method based on test equipment
CN117291132A (en) * 2023-11-27 2023-12-26 上海小厘科技有限公司 Chip verification system, method and storage medium
CN117291132B (en) * 2023-11-27 2024-02-20 上海小厘科技有限公司 Chip verification system, method and storage medium
CN118313174A (en) * 2024-06-11 2024-07-09 中国空气动力研究与发展中心计算空气动力研究所 Design method for separation parameters of suspension and carrier separation test

Also Published As

Publication number Publication date
CN116432570A (en) 2023-07-14

Similar Documents

Publication Publication Date Title
WO2023125821A1 (en) Chip test case generation method and apparatus, and storage medium
Singh et al. Napel: Near-memory computing application performance prediction via ensemble learning
Sun et al. A re-evaluation of knowledge graph completion methods
Kostopoulos et al. Semi-supervised regression: A recent review
Wang et al. Reform: Error-aware few-shot knowledge graph completion
Xu et al. GoodFloorplan: Graph convolutional network and reinforcement learning-based floorplanning
AU2020427921B2 (en) Automated generation of explainable machine learning
Lai et al. Chipformer: Transferable chip placement via offline decision transformer
CN108875053A (en) A kind of knowledge mapping data processing method and device
Layton Learning data mining with python
CN117236278B (en) Chip production simulation method and system based on digital twin technology
EP4075292A1 (en) Method and apparatus for processing database
Montazeri et al. A novel memetic feature selection algorithm
Liu et al. Neural architecture search on efficient transformers and beyond
Zhou et al. Heterogeneous graph neural network-based imitation learning for gate sizing acceleration
Wang et al. GP-based approach to comprehensive quality-aware automated semantic web service composition
Jin et al. A novel multi-stage ensemble model with multiple K-means-based selective undersampling: An application in credit scoring
CN116868207A (en) Decision tree of original graph database
US20200019654A1 (en) Verification algorithm engine selection
US11244099B1 (en) Machine-learning based prediction method for iterative clustering during clock tree synthesis
Huang et al. Diagnosis outcome prediction on limited data via transferred random forest
Li et al. Pruning SMAC search space based on key hyperparameters
Qiuju PERSONAL CREDIT SCORING MODEL RESEARCHBASED ON THE RF-GA-SVM MODEL
Sun et al. An efficient local search algorithm for minimum positive influence dominating set problem
Nie et al. Machine Learning Framework Using Complex Network Features to Predict Wire-length

Legal Events

Date Code Title Description
121 Ep: the epo has been informed by wipo that ep was designated in this application

Ref document number: 22915070

Country of ref document: EP

Kind code of ref document: A1

NENP Non-entry into the national phase

Ref country code: DE