WO2016202157A2 - 一种随机测试程序生成方法及装置、设备、存储介质 - Google Patents
一种随机测试程序生成方法及装置、设备、存储介质 Download PDFInfo
- Publication number
- WO2016202157A2 WO2016202157A2 PCT/CN2016/083560 CN2016083560W WO2016202157A2 WO 2016202157 A2 WO2016202157 A2 WO 2016202157A2 CN 2016083560 W CN2016083560 W CN 2016083560W WO 2016202157 A2 WO2016202157 A2 WO 2016202157A2
- Authority
- WO
- WIPO (PCT)
- Prior art keywords
- instruction
- random test
- test program
- modifying
- legal
- Prior art date
Links
Images
Definitions
- the present invention relates to the field of processor design, and in particular, to a method, device, and storage medium for generating a random test program.
- the random test program generation method needs to adopt uncontrolled full randomness, which causes problems in the legality of the generated random test program, and the purpose of the random test program is poor and it is difficult to ensure the functional coverage of the processor;
- There are techniques in the random test program generation method that need to write a program segment or write a complex random program constraint template, resulting in random random test program randomness, and it is difficult to effectively complement the artificial design program.
- Other random test program generation methods in the prior art improve a certain point or aspect of the random test program, for example, improve the legality of the floating point random number, improve the weight control of the random instruction, and improve the branch jump instruction. Control and improve pipeline interference.
- embodiments of the present invention are directed to providing a random test program generation method, apparatus, device, and storage medium, which can not only automatically generate a random test program required for processor verification, Moreover, the legality and functional coverage of the random test program can be effectively controlled, thereby improving the efficiency of the processor verification.
- an embodiment of the present invention provides a method for generating a random test program, including:
- the modifying the random test procedure comprises:
- the instruction package includes a function call instruction or a software interrupt instruction
- an instruction to save and restore in the field is added.
- the modifying the ARTPG status comprises:
- the random weight is adjusted according to the function coverage feedback information.
- the modifying the legal instruction set includes:
- the instruction packet includes the function call instruction or the software interrupt instruction
- the current return address is pressed to the stack, and the on-site saved instruction is added before the function call instruction or the software interrupt instruction.
- the method further comprises: performing an instruction partial simulation or performing an instruction global simulation.
- the method further includes:
- the embodiment of the present invention further provides a random test program generating apparatus, including:
- the first determining module is configured to randomly select the instruction packet in the legal instruction set and generate the instruction packet, and determine whether the instruction packet includes a branch jump instruction;
- a second determining module configured to determine, when the instruction packet includes the branch jump instruction, whether the random test program has a first endless loop risk
- the third determining module is configured to modify the random test program to determine whether the random test program has a second loop risk when the random test program has the first endless loop risk.
- modifying the module configured to modify the automatic random test program generator ARTPG state, the processor state, and the legal instruction set when the random test program does not have a second loop risk.
- the third determining module configured to modify the random test program, includes:
- the instruction package includes a function call instruction or a software interrupt instruction
- an instruction to save and restore in the field is added.
- the modifying module configured to modify the ARTPG status, includes:
- the random weight is adjusted according to the function coverage feedback information.
- the modifying module configured to modify the legal instruction set, includes:
- the instruction packet includes the function call instruction or the software interrupt instruction
- the current return address is pressed to the stack, and the on-site saved instruction is added before the function call instruction or the software interrupt instruction.
- the third determining module is further configured to execute the instruction part after the modifying the random test program and before determining whether the random test program has a second loop risk Simulate or execute a global simulation of instructions.
- the method further includes:
- an output module configured to output the random test program and the random test program execution result when the first transmit instruction number generated by the random test program is equal to the randomly selected second transmit instruction number and the random test program satisfies the termination condition And coverage analysis report.
- an embodiment of the present invention provides a computer storage medium, where the computer stores The computer-executable instructions are stored in the medium for executing the random test program generation method provided by the embodiment of the first aspect of the present invention.
- an embodiment of the present invention provides a random test program generating device, where the device includes:
- a storage medium configured to store computer executable instructions
- a processor configured to execute computer executable instructions stored on the storage medium, the computer executable instructions comprising:
- the random test program generating method, apparatus, device, and storage medium provided by the embodiment of the present invention randomly select an instruction packet in a legal instruction set by the random test program generating device, and generate the instruction packet, and determine whether the instruction packet includes a branch hop. a transfer instruction; when the instruction packet includes the branch jump instruction, the random test program generating means determines whether the random test program has a first endless loop risk; when the random test program exists the first dead When the risk is cyclically, the random test program generating means modifies the random test program to determine whether the random test program has a second loop risk; and when the random test program does not have a second loop risk, the random test program
- the generating device modifies an Automatic Random Test Program Generator (ARTPG) state, a processor state, and the legal instruction set.
- ARTPG Automatic Random Test Program Generator
- Random test program generation and legality detection The random test program can be performed simultaneously; thus, not only can the random test program required for processor verification be fully automated, but also the legality and function coverage of the random test program can be effectively controlled. Rate, which in turn improves the efficiency of processor verification.
- FIG. 1 is a schematic flowchart of an implementation process of a random test program generation method according to Embodiment 1 of the present invention
- FIG. 2 is a schematic structural diagram of a register file data according to Embodiment 1 of the present invention.
- FIG. 3 is a schematic structural diagram of data of an instruction generator according to Embodiment 1 of the present invention.
- FIG. 4 is a schematic structural diagram of data of a function unit list according to Embodiment 1 of the present invention.
- FIG. 5 is a schematic structural diagram of data of an instruction list according to Embodiment 1 of the present invention.
- FIG. 6 is a schematic structural diagram of data of an operand linked list according to Embodiment 1 of the present invention.
- FIG. 7 is a schematic structural diagram of a data structure of a legal instruction set tree linked list according to Embodiment 1 of the present invention.
- FIG. 8 is a schematic flowchart showing an implementation process of a random test program generation method according to Embodiments 2 to 6 of the present invention.
- FIG. 9 is a schematic structural diagram of a random test program generating apparatus according to Embodiment 7 of the present invention.
- the random test program generating device randomly selects an instruction packet in a legal instruction set and generates an instruction packet, and determines whether the instruction packet includes a branch jump instruction; when the instruction packet includes the branch jump instruction
- the random test program generating means determines whether the random test program has a first endless loop risk; and when the random test program has the first endless loop risk, the random test program generating means modifies the random test a program determining whether the random test program has a second loop risk; and when the random test program does not have a second loop risk, the random test program generating device modifies the ARTPG state, the processor state, and The legal instruction set.
- FIG. 1 is a schematic flowchart of a method for generating a random test program according to Embodiment 1 of the present invention. As shown in FIG. 1 , the method includes: Step 110: randomly selecting an instruction packet in a legal instruction set and generating an instruction packet, and determining an instruction packet. Whether to include branch jump instructions.
- the process of randomly selecting a packet and generating an instruction packet in the legal instruction set includes: the random test program generating device generates a random number that is not greater than a preset maximum number of instructions of the processor; and according to the random number from the legal instruction set tree list Select a random instruction and randomly select the random operands required by the instruction.
- Step 120 When the instruction packet includes a branch jump instruction, determine whether the random test program has a first endless loop risk.
- step 120 when the branch jump instruction is included in the instruction packet, the declaration of the branch jump instruction condition variable is first traced, where the register is loaded. After that, the random test program generating device combines the branch jump instruction to determine whether the random test program has the first endless loop risk. Judging criteria include:
- the forward jump is a jump to the part where the program is not executed;
- the backward jump is risky, where the backward jump is a jump to the executed part of the program. ;
- the risk of the dead loop is an infinite backward jump of the program.
- Step 130 When the random test program has the risk of the first endless loop, modify the random test procedure to determine whether the random test procedure has a second loop risk.
- step 130 the modifying the random test procedure includes:
- the instruction package includes a function call instruction or a software interrupt instruction
- an instruction to save and restore in the field is added.
- the instructions for adding live save and resume include:
- the instruction packet includes a function call instruction or a software interrupt instruction
- a field saved instruction or instruction package is directly added in front of the instruction.
- step 130 the modifying the random test program further includes:
- an on-site restored instruction or instruction packet is directly added after the instruction.
- step 130 after the modifying the random test procedure and before determining whether the random test procedure has a second loop risk, the method further comprises: performing an instruction partial simulation or performing an instruction global simulation.
- instruction simulation is divided into instruction local simulation and instruction global simulation.
- the instruction local simulation simulates the instruction from the variable declaration to the branch jump. After assigning a random value to the undetermined operand, the simulation jumps to the branch jump instruction. Tracking the direction of the jump, the forward jump can be resolved within the specified number of times.
- Instruction global simulation is a simulation from the beginning, mainly used when opening a direct jump instruction when generating a random test program.
- the second endless loop risk is an infinite loop risk that the program address jumps back to the same address.
- Step 140 Modify the ARTPG state, the processor state, and the legal instruction set when the random test procedure does not have a second loop risk.
- the modifying the ARTPG state includes: modifying the code size of the generated program according to the generated instruction or the size of the instruction packet; modifying the generated program to be executed according to the generated instruction or the number of cycles that the instruction package needs to be executed.
- the number of cycles, the number of cycles is an estimate, and the cycle is modified according to the previous detection and simulation results; the coverage is calculated and modified according to the number of times the command generator and the processor state are used; and the randomness is adjusted according to the function coverage feedback information Weights.
- the modifying the processor state comprises: calculating an instruction execution result according to a function pointed to by the selected random instruction; modifying the processor state according to the execution result.
- step 140 the modifying the legal instruction set includes:
- the instruction packet includes the function call instruction or the software interrupt instruction
- the current return address is pressed to the stack, and the on-site saved instruction is added before the function call instruction or the software interrupt instruction.
- the method further includes:
- the method further includes:
- Step 101 Initialize the initial state of the processor.
- step 101 the random test program generating means initializes the initial state of the processor corresponding to the instruction emulator in the ARTPG according to the processor state description provided by the verifier.
- the initial state of the processor is a data structure in a random test program, similar to another data structure, that is, a processor state, but there are mainly two differences between the two: first, the initial state of the processor There is no current value and the value of the current cycle instruction or the execution of the instruction packet.
- the two states; second, the initial state of the processor does not need to initialize all register files and status registers, wherein unspecified content may default to the reset value of the processor.
- the instruction level precision instruction emulator is a processor state.
- the processor state includes all register files corresponding to the processor, the current value of the status register, the current cycle instruction or the value after the execution of the instruction packet, and the instruction level precision instruction emulator adds the value of the partial pipeline register.
- Figure 2 shows the register file data structure. The status register and the register file are basically the same. The difference is that the entry list of the status register is an array of structures, and the Entry List in the register file is a structure.
- Step 102 Initialize the legal instruction set.
- the random test program generating device initializes the legal instruction set according to the processor state corresponding to the instruction emulator in the ARTPG; the initialization legal instruction set is consistent with the subsequent standard for modifying the legal instruction set.
- the legal instruction set is a dynamic tree linked list, and the legal instruction set tree list can be dynamically modified after each selection and generation of random instructions. It should be noted that other data structure types are equally applicable.
- Step 103 Initialize the ARTPG state.
- step 103 the random test program generation device initializes the ARTPG state using a random program constraint.
- the random program constraint includes two constraints:
- the first constraint condition is a termination condition, and the termination condition includes a termination condition generated by the random test program; the termination condition generated by the random test program is set to: the program size reaches a certain standard; the program execution cycle number reaches a certain value; and the function of the test program Coverage reaches a certain standard.
- the function coverage rate can be described hierarchically. When all levels of function coverage meet the standard, the program size and program execution cycle number have higher priority than the coverage rate setting. When the function coverage is used as the termination condition, the program size and the number of program execution cycles are set to zero.
- the second constraint is the legality detection condition, and the legality detection condition is to describe the infinite loop. judgement standard.
- Step 104 Determine whether the generated random test program satisfies the termination condition.
- the determination criterion includes whether the number of program execution cycles satisfies the termination condition; whether the program size satisfies the termination condition; and whether the function coverage rate satisfies the termination condition.
- Step 105 When the random test procedure does not satisfy the termination condition, randomly select the second number of transmit instructions of the random test procedure.
- the random test program generation device randomly selects the number of second transmit instructions that need to be transmitted in parallel for the current period.
- Step 106 Determine whether the number of first transmission instructions generated by the random test program is equal to the number of randomly selected second transmission instructions.
- Step 107 Select a functional unit when the number of first transmission instructions generated by the random test program is equal to the number of randomly selected second transmission instructions.
- the functional unit belongs to the coverage collection, that is, the data structure of the feedback control random weight, and the data structure collected by the coverage belongs to the instruction generator state.
- the command generator state includes the current code size, the Cycle Count, and the Coverage State.
- the instruction generator state also includes data structures for processor hardware architecture and ISA (Instruction Set Architecture) coverage collection related to coverage status.
- the data structure of the coverage collection includes a functional unit list, an instruction list, and an operand linked list.
- the function pointer in the instruction list points to the processing function corresponding to the instruction function to support the instruction simulation.
- first transmit instruction number and the function unit selected in steps 101-107 are required in steps 110 to 140 to select the instruction packet according to the first transmit instruction number and the function unit. At this point, the process of generating the random test program is complete.
- FIG. 8 is a schematic flowchart of a method for generating a random test program according to Embodiment 2 of the present invention. As shown in FIG. 8, the method includes:
- Step 201 Initialize the initial state of the processor.
- Step 202 Initialize a legal instruction set.
- Step 203 Initialize the ARTPG state.
- Step 204 Determine whether the random test procedure satisfies the termination condition.
- step 218 is performed.
- Step 218 Output a random test program, a random test program execution result, and a coverage analysis report.
- Step 219 Free up space and exit.
- FIG. 8 is a schematic flowchart of a method for generating a random test program according to Embodiment 3 of the present invention. As shown in FIG. 8, the method includes:
- Step 201 Initialize the initial state of the processor.
- Step 202 Initialize a legal instruction set.
- Step 203 Initialize the ARTPG state.
- Step 204 Determine whether the random test procedure satisfies the termination condition.
- Step 205 Randomly select the second number of transmission instructions of the random test program.
- Step 206 Determine whether the number of first transmission instructions generated by the random test program is equal to the number of randomly selected second transmission instructions.
- step 204 is performed.
- Step 204 Determine whether the random test procedure satisfies the termination condition.
- Step 218 Output a random test program, a random test program execution result, and a coverage analysis report.
- Step 219 Free up space and exit.
- the present embodiment is a random test program generation method provided when the number of first transmission instructions generated by the random test program is equal to the number of randomly selected second transmission instructions and the termination condition is satisfied.
- FIG. 8 is a schematic flowchart of a method for generating a random test program according to Embodiment 4 of the present invention. As shown in FIG. 8, the method includes:
- Step 201 Initialize the initial state of the processor.
- Step 202 Initialize a legal instruction set.
- Step 203 Initialize the ARTPG state.
- Step 204 Determine whether the random test procedure satisfies the termination condition.
- Step 205 Randomly select the second number of transmission instructions of the random test program.
- Step 206 Determine whether the number of first transmission instructions generated by the random test program is equal to the number of randomly selected second transmission instructions.
- Step 207 Select a functional unit.
- Step 208 Select an instruction packet in the legal instruction set.
- Step 209 Determine whether the instruction packet includes a branch jump instruction.
- step 214 is performed.
- Step 214 Select a normal instruction operand.
- Step 215 Modify the ARTPG status.
- Step 216 Modify the processor state.
- Step 217 Modify the legal instruction set.
- Step 206 Determine whether the number of first transmission instructions generated by the random test program is equal to the number of randomly selected second transmission instructions.
- step 204 is performed.
- Step 204 Determine whether the random test procedure satisfies the termination condition.
- step 218 is performed.
- Step 218 Output a random test program, a random test program execution result, and a coverage analysis report.
- Step 219 Free up space and exit.
- This embodiment is a random test program generation method provided when the instruction packet of the random test program does not include the branch jump instruction.
- FIG. 8 is a schematic flowchart of a method for generating a random test program according to Embodiment 5 of the present invention. As shown in FIG. 8, the method includes:
- Step 201 Initialize the initial state of the processor.
- Step 202 Initialize a legal instruction set.
- Step 203 Initialize the ARTPG state.
- Step 204 Determine whether the random test procedure satisfies the termination condition.
- Step 205 Randomly select the second number of transmission instructions of the random test program.
- Step 206 Determine whether the number of first transmission instructions generated by the random test program is equal to the number of randomly selected second transmission instructions.
- Step 207 Select a functional unit.
- Step 208 Select an instruction packet in the legal instruction set.
- Step 209 Determine whether the instruction packet includes a branch jump instruction.
- Step 210 Select a branch jump instruction operand.
- Step 211 Determine whether the random test procedure has a first endless loop risk.
- Step 212 Modify the random test procedure.
- Step 213 Determine whether the random test procedure has a second loop risk.
- step 208 is performed.
- Step 208 Select an instruction packet in the legal instruction set.
- Step 209 Determine whether the instruction packet includes a branch jump instruction.
- step 214 is performed.
- Step 214 Select a normal instruction operand.
- Step 215 Modify the ARTPG status.
- Step 216 Modify the processor state.
- Step 217 Modify the legal instruction set.
- Step 206 Determine whether the number of first transmission instructions generated by the random test program is equal to the number of randomly selected second transmission instructions.
- step 204 is performed.
- Step 204 Determine whether the random test procedure satisfies the termination condition.
- step 218 is performed.
- Step 218 Output a random test program, a random test program execution result, and a coverage analysis report.
- Step 219 Free up space and exit.
- This embodiment is a random test program generation method provided when the random test program has the first dead loop risk and the second loop risk.
- FIG. 8 is a schematic flowchart of a method for generating a random test program according to Embodiment 6 of the present invention. As shown in FIG. 8, the method includes:
- Step 201 Initialize the initial state of the processor.
- Step 202 Initialize a legal instruction set.
- Step 203 Initialize the ARTPG state.
- Step 204 Determine whether the random test procedure satisfies the termination condition.
- Step 205 Randomly select the second number of transmission instructions of the random test program.
- Step 206 Determine whether the number of first transmission instructions generated by the random test program is equal to the number of randomly selected second transmission instructions.
- Step 207 Select a functional unit.
- Step 208 Select an instruction packet in the legal instruction set.
- Step 209 Determine whether the instruction packet includes a branch jump instruction.
- Step 210 Select a branch jump instruction operand.
- Step 211 Determine whether the random test procedure has a first endless loop risk.
- step 215 is performed.
- Step 215 Modify the ARTPG status.
- Step 216 Modify the processor state.
- Step 217 Modify the legal instruction set.
- Step 206 Determine whether the number of first transmission instructions generated by the random test program is equal to the number of randomly selected second transmission instructions.
- step 204 is performed.
- Step 204 Determine whether the random test procedure satisfies the termination condition.
- step 218 is performed.
- Step 218 Output a random test program, a random test program execution result, and a coverage analysis report.
- Step 219 Free up space and exit.
- This embodiment is a random test program generation method provided when the random test program has the risk of the first endless loop.
- FIG. 9 is a schematic structural diagram of a random test program generating apparatus according to Embodiment 7 of the present invention. As shown in FIG. 9, the apparatus includes:
- the first determining module 310 is configured to randomly select an instruction packet in a legal instruction set and generate the instruction packet, and determine whether the instruction packet includes a branch jump instruction;
- the second determining module 320 is configured to determine, when the instruction packet includes the branch jump instruction, whether the random test program has a first endless loop risk
- the third determining module 330 is configured to: when the random test program exists, the first dead loop wind In case of danger, the random test procedure is modified to determine whether the random test procedure has a second loop risk.
- the modification module 340 is configured to modify the ARTPG state, the processor state, and the legal instruction set when the random test procedure does not have a second loop risk.
- the third determining module 330 is configured to modify the random test program to include:
- the instruction package includes a function call instruction or a software interrupt instruction
- an instruction to save and restore in the field is added.
- the modifying module 340 is configured to modify the ARTPG status, including:
- the random weight is adjusted according to the function coverage feedback information.
- the modifying module 340 is configured to modify the legal instruction set to include:
- the instruction packet includes the function call instruction or the software interrupt instruction
- the current return address is pressed to the stack, and the on-site saved instruction is added before the function call instruction or the software interrupt instruction.
- the third determining module 330 is further configured to execute the instruction local simulation or the execution instruction globally after the modifying the random test program and before determining whether the random test program has a second loop risk simulation.
- the device further includes:
- the output module 350 is configured to output the random test program and the random test program execution when the first transmit instruction number generated by the random test program is equal to the randomly selected second transmit instruction number and the random test program satisfies the termination condition Results and coverage analysis report.
- the first determining module 310, the second determining module 320, the third determining module 330, the modifying module 340, and the output module 350 can all be implemented by any programming language based on any software or hardware platform.
- the random test program generation method can generate a random test program for any target processor directly or with simple modification.
- the first determining module 310, the second determining module 320, the third determining module 330, the modifying module 340, and the output module 350 may each be a central processing unit (CPU) located in any computer device. , Digital Signal Processor (DSP), Microprocessor (MPU), or Field Programmable Gate Array (FPGA) implementation.
- DSP Digital Signal Processor
- MPU Microprocessor
- FPGA Field Programmable Gate Array
- the random test program generation method described above is implemented in the form of a software function module and sold or used as a stand-alone product, it may also be stored in a computer readable storage medium.
- the technical solution of the embodiments of the present invention may be embodied in the form of a software product in essence or in the form of a software product stored in a storage medium, including a plurality of instructions.
- a computer device (which may be a personal computer, server, or network device, etc.) is caused to perform all or part of the methods described in various embodiments of the present invention.
- the foregoing storage medium includes various media that can store program codes, such as a USB flash drive, a mobile hard disk, a read only memory (ROM), a magnetic disk, or an optical disk.
- program codes such as a USB flash drive, a mobile hard disk, a read only memory (ROM), a magnetic disk, or an optical disk.
- the embodiment of the present invention further provides a computer storage medium, where the computer storage medium stores computer executable instructions, and the computer executable instructions are used to execute a random test program generation method in the embodiment of the present invention.
- the embodiment of the present invention further provides a random test program generating device (computer device), where the device includes:
- a storage medium configured to store computer executable instructions
- a processor configured to execute computer executable instructions stored on the storage medium, the computer executable instructions comprising: randomly selecting an instruction package in a legal instruction set and generating the instruction package, determining whether the instruction package includes a branch a jump instruction; when the instruction packet includes the branch jump instruction, determining whether the random test program has a first endless loop risk; and when the random test program has the first endless loop risk, modifying the a random test procedure for determining whether the random test program has a second loop risk; modifying the fully automatic random test program generator ARTPG state, the processor state, and the legality when the random test program does not have a second loop risk Instruction Set.
- the disclosed apparatus and method may be implemented in other manners.
- the device embodiments described above are merely illustrative.
- the division of the unit is only a logical function division.
- there may be another division manner such as: multiple units or components may be combined, or Can be integrated into another system, or some features can be ignored or not executed.
- the coupling, or direct coupling, or communication connection of the components shown or discussed may be indirect coupling or communication connection through some interfaces, devices or units, and may be electrical, mechanical or other forms. of.
- the units described above as separate components may or may not be physically separated, and the components displayed as the unit may or may not be physical units; they may be located in one place or distributed on multiple network units; Some or all of the units may be selected according to actual needs to achieve the purpose of the solution of the embodiment.
- each functional unit in each embodiment of the present invention may be integrated into one processing unit, or each unit may be separately used as one unit, or two or more units may be integrated into one unit;
- the unit can be implemented in the form of hardware or in the form of hardware plus software functional units.
- the foregoing program may be stored in a computer readable storage medium, and when executed, the program includes The foregoing steps of the method embodiment; and the foregoing storage medium includes: a removable storage device, a read only memory (ROM), a magnetic disk, or an optical disk, and the like, which can store program codes.
- ROM read only memory
- the above-described integrated unit of the present invention may be stored in a computer readable storage medium if it is implemented in the form of a software function module and sold or used as a standalone product.
- the technical solution of the embodiments of the present invention may be embodied in the form of a software product in essence or in the form of a software product stored in a storage medium, including a plurality of instructions.
- Make a computer device can be a personal computing The machine, server, or network device, etc.) performs all or part of the methods described in various embodiments of the present invention.
- the foregoing storage medium includes various media that can store program codes, such as a mobile storage device, a ROM, a magnetic disk, or an optical disk.
- the generation of the random test program and the legality detection of the random test program can be simultaneously performed; Fully automatic generation of random test procedures required for processor verification, and effective control of the legality and functional coverage of random test procedures, thereby improving the efficiency of processor verification.
Landscapes
- Test And Diagnosis Of Digital Computers (AREA)
- Debugging And Monitoring (AREA)
Abstract
本发明公开了一种随机测试程序生成方法,包括:在合法指令集中随机选择指令包并生成指令包,判断所述指令包是否包括分支跳转指令;当所述指令包包括所述分支跳转指令时,判断所述随机测试程序是否存在第一死循环风险;当所述随机测试程序存在所述第一死循环风险时,修改所述随机测试程序,判断所述随机测试程序是否存在第二循环风险;当所述随机测试程序不存在第二循环风险时,修改全自动随机测试程序生成器(ARTPG)状态、处理器状态和所述合法指令集。本发明还同时公开了一种随机测试程序生成装置、设备、存储介质。
Description
本发明涉及处理器设计领域,尤其涉及一种随机测试程序生成方法及装置、设备、存储介质。
现有技术中,在进行处理器设计时,对处理器的功能验证是一个重点和难点,如何能够完整的覆盖处理器的功能及保证处理器验证的质量成为处理器设计的关键。目前,纯粹靠验证人员手动编写处理器验证所需要的程序和数据容易漏掉对某些处理器功能点的验证。因此,如果采用高效生成随机汇编测试程序或者随机机器测试程序的方式可以改善或解决上述技术问题。
现有技术中,随机测试程序生成方法需要采用不受控的全随机,导致生成的随机测试程序合法性存在问题,同时随机测试程序的目的性差且难以保证处理器的功能覆盖率;此外,现有技术中的随机测试程序生成方法需要编写程序段或者编写复杂的随机程序约束模版,导致生成的随机测试程序随机性差,并难以做到对人工设计程序的有效补充。现有技术中其它的随机测试程序生成方法对随机测试程序中某点或某方面进行了改善,例如,改善浮点随机数的合法性,改善权重对随机指令的控制,改善对分支跳转指令的控制,及改善流水线干扰。
发明内容
有鉴于此,本发明实施例期望提供一种随机测试程序生成方法及装置、设备、存储介质,不仅能全自动的生成处理器验证所需的随机测试程序,
而且能有效的控制随机测试程序的合法性和功能覆盖率,从而能提升处理器验证的效率。
为达到上述目的,本发明实施例的技术方案是这样实现的:
第一方面,本发明实施例提供了一种随机测试程序生成方法,包括:
在合法指令集中随机选择指令包并生成所述指令包,判断所述指令包是否包括分支跳转指令;
当所述指令包包括所述分支跳转指令时,判断所述随机测试程序是否存在第一死循环风险;
当所述随机测试程序存在所述第一死循环风险时,修改所述随机测试程序,判断所述随机测试程序是否存在第二循环风险;
当所述随机测试程序不存在第二循环风险时,修改全自动随机测试程序生成器ARTPG状态、处理器状态和所述合法指令集。
在本发明的其他实施例中,所述修改所述随机测试程序包括:
当分支跳转地址超过程序空间界限时,修改所述分支跳转地址使其不超过所述程序空间界限;
当分支跳转判定条件在声明到使用之间没有修改操作时,增加修改指令;
当所述修改操作的收敛方向与所述分支跳转判定条件不一致时,修改所述修改操作的收敛方向使其与所述分支跳转判定条件一致;
当所述指令包包括函数调用指令或软件中断指令时,添加现场保存及恢复的指令。
在本发明的其他实施例中,所述修改所述ARTPG状态包括:
根据功能覆盖率反馈信息调整随机权重。
在本发明的其他实施例中,所述修改所述合法指令集包括:
将修改后的输出寄存器添加到对应的合法输入操作数;
将所述合法输入操作数对应的指令添加到所述合法指令集;
当所述指令包包括所述函数调用指令或所述软件中断指令时,将当前返回地址压至堆栈,在所述函数调用指令或所述软件中断指令前添加所述现场保存的指令。
在本发明的其他实施例中,在所述修改所述随机测试程序之后及在所述判断所述随机测试程序是否存在第二循环风险之前,还包括:执行指令局部仿真或者执行指令全局仿真。
在本发明的其他实施例中,所述修改ARTPG状态、处理器状态和所述合法指令集之后,还包括:
当所述随机测试程序生成的第一发射指令数等于随机选择的第二发射指令数且所述随机测试程序满足终止条件时,输出所述随机测试程序、随机测试程序执行结果和覆盖率分析报告。
第二方面,本发明实施例还提供了一种随机测试程序生成装置,包括:
第一判断模块,配置为在合法指令集中随机选择指令包并生成所述指令包,判断所述指令包是否包括分支跳转指令;
第二判断模块,配置为当所述指令包包括所述分支跳转指令时,判断所述随机测试程序是否存在第一死循环风险;
第三判断模块,配置为当所述随机测试程序存在所述第一死循环风险时,修改所述随机测试程序,判断所述随机测试程序是否存在第二循环风险。
修改模块,配置为当所述随机测试程序不存在第二循环风险时,修改全自动随机测试程序生成器ARTPG状态、处理器状态和所述合法指令集。
在本发明的其他实施例中,所述第三判断模块,配置为修改所述随机测试程序包括:
当分支跳转地址超过程序空间界限时,修改所述分支跳转地址使其不
超过所述程序空间界限;
当分支跳转判定条件在声明到使用之间没有修改操作时,增加修改指令;
当所述修改操作的收敛方向与所述分支跳转判定条件不一致时,修改所述修改操作的收敛方向使其与所述分支跳转判定条件一致;
当所述指令包包括函数调用指令或软件中断指令时,添加现场保存及恢复的指令。
在本发明的其他实施例中,所述修改模块,配置为修改所述ARTPG状态包括:
根据功能覆盖率反馈信息调整随机权重。
在本发明的其他实施例中,所述修改模块,配置为修改所述合法指令集包括:
将修改后的输出寄存器添加到对应的合法输入操作数;
将所述合法输入操作数对应的指令添加到所述合法指令集;
当所述指令包包括所述函数调用指令或所述软件中断指令时,将当前返回地址压至堆栈,在所述函数调用指令或所述软件中断指令前添加所述现场保存的指令。
在本发明的其他实施例中,所述第三判断模块,还配置为在所述修改所述随机测试程序之后及在所述判断所述随机测试程序是否存在第二循环风险之前,执行指令局部仿真或者执行指令全局仿真。
在本发明的其他实施例中,还包括:
输出模块,配置为当所述随机测试程序生成的第一发射指令数等于随机选择的第二发射指令数且所述随机测试程序满足终止条件时,输出所述随机测试程序、随机测试程序执行结果和覆盖率分析报告。
第三方面,本发明实施例提供一种计算机存储介质,所述计算机存储
介质中存储有计算机可执行指令,该计算机可执行指令用于执行本发明第一方面实施例提供的随机测试程序生成方法。
第四方面,本发明实施例提供一种随机测试程序生成设备,所述设备包括:
存储介质,配置为存储计算机可执行指令;
处理器,配置为执行存储在所述存储介质上的计算机可执行指令,所述计算机可执行指令包括:
在合法指令集中随机选择指令包并生成所述指令包,判断所述指令包是否包括分支跳转指令;
当所述指令包包括所述分支跳转指令时,判断所述随机测试程序是否存在第一死循环风险;
当所述随机测试程序存在所述第一死循环风险时,修改所述随机测试程序,判断所述随机测试程序是否存在第二循环风险;
当所述随机测试程序不存在第二循环风险时,修改全自动随机测试程序生成器ARTPG状态、处理器状态和所述合法指令集。
本发明实施例所提供的随机测试程序生成方法及装置、设备、存储介质,由随机测试程序生成装置在合法指令集中随机选择指令包并生成所述指令包,判断所述指令包是否包括分支跳转指令;当所述指令包包括所述分支跳转指令时,所述随机测试程序生成装置判断所述随机测试程序是否存在第一死循环风险;当所述随机测试程序存在所述第一死循环风险时,所述随机测试程序生成装置修改所述随机测试程序,判断所述随机测试程序是否存在第二循环风险;当所述随机测试程序不存在第二循环风险时,所述随机测试程序生成装置修改全自动随机测试程序生成器(ARTPG,Automatic Random Test Program Generator)状态、处理器状态和所述合法指令集。由于本发明实施例可以动态更新合法指令集和处理器状态,也使得
随机测试程序的生成与合法性检测所述随机测试程序能够同时进行;这样,不但能全自动的生成处理器验证所需的随机测试程序,而且能有效的控制随机测试程序的合法性和功能覆盖率,进而能提升处理器验证的效率。
图1为本发明实施例1提供的随机测试程序生成方法的实现流程示意图;
图2为本发明实施例1提供的寄存器文件数据结构示意图;
图3为本发明实施例1提供的指令生成器数据结构示意图;
图4为本发明实施例1提供的功能单元列表数据结构示意图;
图5为本发明实施例1提供的指令列表数据结构示意图;
图6为本发明实施例1提供的操作数链表数据结构示意图;
图7为本发明实施例1提供的合法指令集树状链表数据结构示意图;
图8为本发明实施例2至6提供的随机测试程序生成方法的实现流程示意图;
图9为本发明实施例7提供的随机测试程序生成装置的组成结构示意图。
本发明实施例中,由随机测试程序生成装置在合法指令集中随机选择指令包并生成指令包,判断所述指令包是否包括分支跳转指令;当所述指令包包括所述分支跳转指令时,所述随机测试程序生成装置判断所述随机测试程序是否存在第一死循环风险;当所述随机测试程序存在所述第一死循环风险时,所述随机测试程序生成装置修改所述随机测试程序,判断所述随机测试程序是否存在第二循环风险;当所述随机测试程序不存在第二循环风险时,所述随机测试程序生成装置修改ARTPG状态、处理器状态和
所述合法指令集。
下面结合附图及具体实施例对本发明再做进一步详细的说明。
实施例1
图1为本发明实施例1提供的随机测试程序生成方法的实现流程示意图,如图1所示,所述方法包括:步骤110:在合法指令集中随机选择指令包并生成指令包,判断指令包是否包括分支跳转指令。
这里,所述在合法指令集中随机选择包并生成指令包的过程包括:随机测试程序生成装置生成不大于预设的处理器最大指令数的随机数;根据随机数从合法指令集树状链表中选择随机的指令,并随机选择指令所需的随机操作数。
步骤120:当指令包包括分支跳转指令时,判断随机测试程序是否存在第一死循环风险。
步骤120中,当指令包中包括分支跳转指令时,首先追朔到分支跳转指令条件变量的声明,这里,寄存器被加载(Load)。之后,随机测试程序生成装置结合分支跳转指令,判断随机测试程序是否存在第一死循环风险。判断准则包括:
前向跳转不存在风险,这里,所述前向跳转为跳转到程序未执行的部分;后向跳转存在风险,这里,所述后向跳转为跳转到程序已执行的部分;
后向跳转时,从条件变量声明到分支跳转指令间,条件变量被修改,修改操作的收敛方向与所述分支跳转的判定条件一致。
这里,所述死循环风险为程序无限次的后向跳转。
步骤130:当随机测试程序存在第一死循环风险时,修改随机测试程序,判断随机测试程序是否存在第二循环风险。
在步骤130中,所述修改所述随机测试程序包括:
当分支跳转地址超过程序空间界限时,修改所述分支跳转地址使其不
超过所述程序空间界限;
当分支跳转判定条件在声明到使用之间没有修改操作时,增加修改指令;
当所述修改操作的收敛方向与所述分支跳转判定条件不一致时,修改所述修改操作的收敛方向,使其与所述分支跳转判定条件一致;
当所述指令包包括函数调用指令或软件中断指令时,添加现场保存及恢复的指令。
这里,所述当所述指令包包括函数调用指令或软件中断指令时,添加现场保存及恢复的指令包括:
当所述指令包包括函数调用指令或软件中断指令时,直接在该指令前面添加现场保存的指令或指令包。
在步骤130中,所述修改所述随机测试程序还包括:
当所述指令包包括函数返回指令或中断返回指令时,直接在该指令后面添加现场恢复的指令或指令包。
在步骤130中,在所述修改所述随机测试程序之后及在所述判断所述随机测试程序是否存在第二循环风险之前,所述方法还包括:执行指令局部仿真或者执行指令全局仿真。
这里,指令仿真分为指令局部仿真和指令全局仿真,指令局部仿真为从变量声明到分支跳转之间的指令进行仿真,对所遇未定操作数赋予随机值后,仿真到分支跳转指令,跟踪跳转方向,指定次数内可以前向跳转则风险解决。指令全局仿真为从头开始仿真,主要用于当生成随机测试程序时开放直接跳转指令时使用。
这里,所述第二死循环风险为程序地址跳转回同一地址的死循环风险。
步骤140:当随机测试程序不存在第二循环风险时,修改ARTPG状态、处理器状态和合法指令集。
在步骤140中,所述修改ARTPG状态包括:根据生成的指令或指令包的大小,修改已生成程序的代码大小;根据生成的指令或指令包需要执行的周期数,修改已生成程序需要执行的周期数,所述周期数为预估,循环时根据前面的检测和仿真结果修改;根据指令生成器和处理器状态的各个项被使用次数计算和修改覆盖率;根据功能覆盖率反馈信息调整随机权重。
在步骤140中,所述修改处理器状态包括:根据所选的随机指令所指向的函数计算指令执行结果;根据执行结果修改处理器状态。
在步骤140中,所述修改所述合法指令集包括:
将修改后的输出寄存器添加到对应的合法输入操作数;
将所述合法输入操作数对应的指令添加到所述合法指令集;
当所述指令包包括所述函数调用指令或所述软件中断指令时,将当前返回地址压至堆栈,在所述函数调用指令或所述软件中断指令前添加所述现场保存的指令。
在步骤140之后,即在所述修改ARTPG状态、处理器状态和所述合法指令集之后,所述方法还包括:
当所述随机测试程序生成的第一发射指令数等于随机选择的第二发射指令数且所述随机测试程序满足终止条件时,输出所述随机测试程序、随机测试程序执行结果和覆盖率分析报告。
在步骤110之前,所述方法还包括:
步骤101:初始化处理器初始状态。
在步骤101中,随机测试程序生成装置根据验证人员提供的处理器状态描述初始化ARTPG中指令仿真器对应的处理器初始状态。
这里,所述处理器初始状态是随机测试程序中的一种数据结构,与另一种数据结构,即处理器状态类似,但是二者主要有两个区别:第一,所述处理器初始状态并没有当前值和当前周期指令或指令包执行结束后的值
这两种状态;第二,所述处理器初始状态不需要初始化所有的寄存器文件和状态寄存器,其中,未指定的内容可默认为处理器的复位值。
具体地,指令级精准的指令仿真器是一种处理器状态。处理器状态包括处理器对应的所有寄存器文件、状态寄存器的当前值、当前周期指令或指令包执行结束后的值,指令级精准的指令仿真器添加部分流水线寄存器的值。图2为寄存器文件数据结构,状态寄存器和寄存器文件基本相同,不同的是状态寄存器的进入列表(Entry List)为结构体数组,而寄存器文件中的Entry List为结构体。
步骤102:初始化合法指令集。
这里,随机测试程序生成装置根据ARTPG中指令仿真器对应的处理器状态,初始化合法指令集;初始化合法指令集与后面的修改合法指令集的标准一致。如图7所示,合法指令集为一个动态树状链表,在每一次选择和生成随机指令后可以动态修改合法指令集树状链表。需要说明的是,采用其它的数据结构类型同样适用。
步骤103:初始化ARTPG状态。
在步骤103中,随机测试程序生成装置使用随机程序约束初始化ARTPG状态。
这里,所述随机程序约束包括两个约束条件:
第一个约束条件为终止条件,终止条件包括描述随机测试程序生成的终止条件;随机测试程序生成的终止条件设置为:程序大小达到一定标准;程序执行周期数达到一定数值;及测试程序的功能覆盖率达到一定标准。其中,功能覆盖率可以分级描述,所有级别的功能覆盖率满足标准时终止,程序大小和程序执行周期数比覆盖率的设置具有更高优先级。当功能覆盖率作为终止条件时,程序大小和程序执行周期数被设置为0。
第二个约束条件为合法性检测条件,合法性检测条件为描述死循环的
判定标准。
步骤104:判断生成的随机测试程序是否满足终止条件。
这里,所述判定标准包括:程序执行周期数是否满足终止条件;程序大小是否满足终止条件;及功能覆盖率是否满足终止条件。
步骤105:当所述随机测试程序不满足终止条件时,随机选择所述随机测试程序的第二发射指令数。随机测试程序生成装置随机选择当前周期需要并行发射的第二发射指令数。
步骤106:判断所述随机测试程序生成的第一发射指令数是否等于随机选择的第二发射指令数。
步骤107:当所述随机测试程序生成的第一发射指令数等于随机选择的第二发射指令数时,选择功能单元。
这里,如图4所示,功能单元属于覆盖率收集,即反馈控制随机权重的数据结构,覆盖率收集的数据结构属于指令生成器状态。如图3所示,指令生成器状态包含当前的代码大小(Code Size)、周期数(Cycle Count)、覆盖率状态(Coverage State)。指令生成器状态还包括与覆盖率状态相关的对于处理器硬件结构和指令集架构(ISA,Instruction Set Architecture)覆盖率收集的数据结构。其中,如图5和6所示,覆盖率收集的数据结构包括功能单元列表、指令列表和操作数链表。指令列表中的函数指针指向指令功能对应的处理函数,用来支持指令仿真。
需要说明的是,步骤110至步骤140中需要步骤101-107中选择的第一发射指令数和功能单元,以便根据第一发射指令数和功能单元选择指令包。至此,随机测试程序生成的过程就完成了。
实施例2
图8为本发明实施例2提供的随机测试程序生成方法的实现流程示意图,如图8所示,所述方法包括:
步骤201:初始化处理器初始状态。
步骤202:初始化合法指令集。
步骤203:初始化ARTPG状态。
步骤204:判断随机测试程序是否满足终止条件。
步骤204判断为是后,执行步骤218。
步骤218:输出随机测试程序、随机测试程序执行结果和覆盖率分析报告。
步骤219:释放空间并退出。
实施例3
图8为本发明实施例3提供的随机测试程序生成方法的实现流程示意图,如图8所示,所述方法包括:
步骤201:初始化处理器初始状态。
步骤202:初始化合法指令集。
步骤203:初始化ARTPG状态。
步骤204:判断随机测试程序是否满足终止条件。
步骤205:随机选择所述随机测试程序的第二发射指令数。
步骤206:判断随机测试程序生成的第一发射指令数是否等于随机选择的第二发射指令数。
步骤206判断为是后,执行步骤204。
步骤204:判断随机测试程序是否满足终止条件。
步骤218:输出随机测试程序、随机测试程序执行结果和覆盖率分析报告。
步骤219:释放空间并退出。
本实施例是当随机测试程序生成的第一发射指令数等于随机选择的第二发射指令数且满足终止条件时提供的随机测试程序生成方法。
实施例4
图8为本发明实施例4提供的随机测试程序生成方法的实现流程示意图,如图8所示,所述方法包括:
步骤201:初始化处理器初始状态。
步骤202:初始化合法指令集。
步骤203:初始化ARTPG状态。
步骤204:判断随机测试程序是否满足终止条件。
步骤205:随机选择所述随机测试程序的第二发射指令数。
步骤206:判断随机测试程序生成的第一发射指令数是否等于随机选择的第二发射指令数。
步骤207:选择功能单元。
步骤208:在合法指令集中选择指令包。
步骤209:判断指令包是否包括分支跳转指令。
步骤209判断为否后,执行步骤214。
步骤214:选择普通指令操作数。
步骤215:修改ARTPG状态。
步骤216:修改处理器状态。
步骤217:修改合法指令集。
步骤206:判断随机测试程序生成的第一发射指令数是否等于随机选择的第二发射指令数。
步骤206判断为是后,执行步骤204。
步骤204:判断随机测试程序是否满足终止条件。
步骤204判断为是后,执行步骤218。
步骤218:输出随机测试程序、随机测试程序执行结果和覆盖率分析报告。
步骤219:释放空间并退出。
本实施例是当随机测试程序的指令包不包括分支跳转指令时提供的随机测试程序生成方法。
实施例5
图8为本发明实施例5提供的随机测试程序生成方法的实现流程示意图,如图8所示,所述方法包括:
步骤201:初始化处理器初始状态。
步骤202:初始化合法指令集。
步骤203:初始化ARTPG状态。
步骤204:判断随机测试程序是否满足终止条件。
步骤205:随机选择所述随机测试程序的第二发射指令数。
步骤206:判断随机测试程序生成的第一发射指令数是否等于随机选择的第二发射指令数。
步骤207:选择功能单元。
步骤208:在合法指令集中选择指令包。
步骤209:判断指令包是否包括分支跳转指令。
步骤210:选择分支跳转指令操作数。
步骤211:判断随机测试程序是否存在第一死循环风险。
步骤212:修改随机测试程序。
步骤213:判断随机测试程序是否存在第二循环风险。
步骤213判断为是后,执行步骤208。
步骤208:在合法指令集中选择指令包。
步骤209:判断指令包是否包括分支跳转指令。
步骤209判断为否后,执行步骤214。
步骤214:选择普通指令操作数。
步骤215:修改ARTPG状态。
步骤216:修改处理器状态。
步骤217:修改合法指令集。
步骤206:判断随机测试程序生成的第一发射指令数是否等于随机选择的第二发射指令数。
步骤206判断为是后,执行步骤204。
步骤204:判断随机测试程序是否满足终止条件。
步骤204判断为是后,执行步骤218。
步骤218:输出随机测试程序、随机测试程序执行结果和覆盖率分析报告。
步骤219:释放空间并退出。
本实施例是当随机测试程序存在第一死循环风险和第二循环风险时提供的随机测试程序生成方法。
实施例6
图8为本发明实施例6提供的随机测试程序生成方法的实现流程示意图,如图8所示,所述方法包括:
步骤201:初始化处理器初始状态。
步骤202:初始化合法指令集。
步骤203:初始化ARTPG状态。
步骤204:判断随机测试程序是否满足终止条件。
步骤205:随机选择所述随机测试程序的第二发射指令数。
步骤206:判断随机测试程序生成的第一发射指令数是否等于随机选择的第二发射指令数。
步骤207:选择功能单元。
步骤208:在合法指令集中选择指令包。
步骤209:判断指令包是否包括分支跳转指令。
步骤210:选择分支跳转指令操作数。
步骤211:判断随机测试程序是否存在第一死循环风险。
步骤211判断为否后,执行步骤215。
步骤215:修改ARTPG状态。
步骤216:修改处理器状态。
步骤217:修改合法指令集。
步骤206:判断随机测试程序生成的第一发射指令数是否等于随机选择的第二发射指令数。
步骤206判断为是后,执行步骤204。
步骤204:判断随机测试程序是否满足终止条件。
步骤204判断为是后,执行步骤218。
步骤218:输出随机测试程序、随机测试程序执行结果和覆盖率分析报告。
步骤219:释放空间并退出。
本实施例是当随机测试程序存在第一死循环风险时提供的随机测试程序生成方法。
实施例7
图9为本发明实施例7提供的随机测试程序生成装置的组成结构示意图,如图9所示,所述装置包括:
第一判断模块310,配置为在合法指令集中随机选择指令包并生成所述指令包,判断所述指令包是否包括分支跳转指令;
第二判断模块320,配置为当所述指令包包括所述分支跳转指令时,判断所述随机测试程序是否存在第一死循环风险;
第三判断模块330,配置为当所述随机测试程序存在所述第一死循环风
险时,修改所述随机测试程序,判断所述随机测试程序是否存在第二循环风险。
修改模块340,配置为当所述随机测试程序不存在第二循环风险时,修改ARTPG状态、处理器状态和所述合法指令集。
具体地,所述第三判断模块330,配置为修改所述随机测试程序包括:
当分支跳转地址超过程序空间界限时,修改所述分支跳转地址使其不超过所述程序空间界限;
当分支跳转判定条件在声明到使用之间没有修改操作时,增加修改指令;
当所述修改操作的收敛方向与所述分支跳转判定条件不一致时,修改所述修改操作的收敛方向使其与所述分支跳转判定条件一致;
当所述指令包包括函数调用指令或软件中断指令时,添加现场保存及恢复的指令。
具体地,所述修改模块340,配置为修改所述ARTPG状态包括:
根据功能覆盖率反馈信息调整随机权重。具体地,所述修改模块340,配置为修改所述合法指令集包括:
将修改后的输出寄存器添加到对应的合法输入操作数;
将所述合法输入操作数对应的指令添加到所述合法指令集;
当所述指令包包括所述函数调用指令或所述软件中断指令时,将当前返回地址压至堆栈,在所述函数调用指令或所述软件中断指令前添加所述现场保存的指令。
进一步地,所述第三判断模块330,还配置为在所述修改所述随机测试程序之后及在所述判断所述随机测试程序是否存在第二循环风险之前,执行指令局部仿真或者执行指令全局仿真。
进一步地,所述装置还包括:
输出模块350,配置为当所述随机测试程序生成的第一发射指令数等于随机选择的第二发射指令数且所述随机测试程序满足终止条件时,输出所述随机测试程序、随机测试程序执行结果和覆盖率分析报告。
在实际应用中,所述第一判断模块310、第二判断模块320、第三判断模块330、修改模块340和输出模块350均可由任何编程语言基于任何软件或硬件平台编程实现。同时,所述随机测试程序生成方法可以直接或者经简单修改后生成针对任何目标处理器的随机测试程序。
在实际应用中,所述第一判断模块310、第二判断模块320、第三判断模块330、修改模块340和输出模块350均可由位于任意计算机设备中的中央处理器(CPU,Central Processing Unit)、数字信号处理器(DSP,Digital Signal Processor)、微处理器(MPU)、或可编程逻辑阵列(FPGA,Field Programmable Gate Array)实现。
需要说明的是,本发明实施例中,如果以软件功能模块的形式实现上述的随机测试程序生成方法,并作为独立的产品销售或使用时,也可以存储在一个计算机可读取存储介质中。基于这样的理解,本发明实施例的技术方案本质上或者说对现有技术做出贡献的部分可以以软件产品的形式体现出来,该计算机软件产品存储在一个存储介质中,包括若干指令用以使得一台计算机设备(可以是个人计算机、服务器、或者网络设备等)执行本发明各个实施例所述方法的全部或部分。而前述的存储介质包括:U盘、移动硬盘、只读存储器(ROM,Read Only Memory)、磁碟或者光盘等各种可以存储程序代码的介质。这样,本发明实施例不限制于任何特定的硬件和软件结合。
相应地,本发明实施例再提供一种计算机存储介质,所述计算机存储介质中存储有计算机可执行指令,该计算机可执行指令用于执行本发明实施例中随机测试程序生成方法。
相应地,本发明实施例再提供一种随机测试程序生成设备(计算机设备),所述设备包括:
存储介质,配置为存储计算机可执行指令;
处理器,配置为执行存储在所述存储介质上的计算机可执行指令,所述计算机可执行指令包括:在合法指令集中随机选择指令包并生成所述指令包,判断所述指令包是否包括分支跳转指令;当所述指令包包括所述分支跳转指令时,判断所述随机测试程序是否存在第一死循环风险;当所述随机测试程序存在所述第一死循环风险时,修改所述随机测试程序,判断所述随机测试程序是否存在第二循环风险;当所述随机测试程序不存在第二循环风险时,修改全自动随机测试程序生成器ARTPG状态、处理器状态和所述合法指令集。
应理解,说明书通篇中提到的“一个实施例”或“一实施例”意味着与实施例有关的特定特征、结构或特性包括在本发明的至少一个实施例中。因此,在整个说明书各处出现的“在一个实施例中”或“在一实施例中”未必一定指相同的实施例。此外,这些特定的特征、结构或特性可以任意适合的方式结合在一个或多个实施例中。应理解,在本发明的各种实施例中,上述各过程的序号的大小并不意味着执行顺序的先后,各过程的执行顺序应以其功能和内在逻辑确定,而不应对本发明实施例的实施过程构成任何限定。上述本发明实施例序号仅仅为了描述,不代表实施例的优劣。
需要说明的是,在本文中,术语“包括”、“包含”或者其任何其他变体意在涵盖非排他性的包含,从而使得包括一系列要素的过程、方法、物品或者装置不仅包括那些要素,而且还包括没有明确列出的其他要素,或者是还包括为这种过程、方法、物品或者装置所固有的要素。在没有更多限制的情况下,由语句“包括一个……”限定的要素,并不排除在包括该要素的过程、方法、物品或者装置中还存在另外的相同要素。
在本申请所提供的几个实施例中,应该理解到,所揭露的设备和方法,可以通过其它的方式实现。以上所描述的设备实施例仅仅是示意性的,例如,所述单元的划分,仅仅为一种逻辑功能划分,实际实现时可以有另外的划分方式,如:多个单元或组件可以结合,或可以集成到另一个系统,或一些特征可以忽略,或不执行。另外,所显示或讨论的各组成部分相互之间的耦合、或直接耦合、或通信连接可以是通过一些接口,设备或单元的间接耦合或通信连接,可以是电性的、机械的或其它形式的。
上述作为分离部件说明的单元可以是、或也可以不是物理上分开的,作为单元显示的部件可以是、或也可以不是物理单元;既可以位于一个地方,也可以分布到多个网络单元上;可以根据实际的需要选择其中的部分或全部单元来实现本实施例方案的目的。
另外,在本发明各实施例中的各功能单元可以全部集成在一个处理单元中,也可以是各单元分别单独作为一个单元,也可以两个或两个以上单元集成在一个单元中;上述集成的单元既可以采用硬件的形式实现,也可以采用硬件加软件功能单元的形式实现。
本领域普通技术人员可以理解:实现上述方法实施例的全部或部分步骤可以通过程序指令相关的硬件来完成,前述的程序可以存储于计算机可读取存储介质中,该程序在执行时,执行包括上述方法实施例的步骤;而前述的存储介质包括:移动存储设备、只读存储器(Read Only Memory,ROM)、磁碟或者光盘等各种可以存储程序代码的介质。
或者,本发明上述集成的单元如果以软件功能模块的形式实现并作为独立的产品销售或使用时,也可以存储在一个计算机可读取存储介质中。基于这样的理解,本发明实施例的技术方案本质上或者说对现有技术做出贡献的部分可以以软件产品的形式体现出来,该计算机软件产品存储在一个存储介质中,包括若干指令用以使得一台计算机设备(可以是个人计算
机、服务器、或者网络设备等)执行本发明各个实施例所述方法的全部或部分。而前述的存储介质包括:移动存储设备、ROM、磁碟或者光盘等各种可以存储程序代码的介质。
以上所述,仅为本发明的具体实施方式,但本发明的保护范围并不局限于此,任何熟悉本技术领域的技术人员在本发明揭露的技术范围内,可轻易想到变化或替换,都应涵盖在本发明的保护范围之内。因此,本发明的保护范围应以所述权利要求的保护范围为准。
本发明实施例提供的技术方案中,由于本发明实施例可以动态更新合法指令集和处理器状态,也使得随机测试程序的生成与合法性检测所述随机测试程序能够同时进行;这样,不但能全自动的生成处理器验证所需的随机测试程序,而且能有效的控制随机测试程序的合法性和功能覆盖率,进而能提升处理器验证的效率。
Claims (14)
- 一种随机测试程序生成方法,所述方法包括:在合法指令集中随机选择指令包并生成所述指令包,判断所述指令包是否包括分支跳转指令;当所述指令包包括所述分支跳转指令时,判断所述随机测试程序是否存在第一死循环风险;当所述随机测试程序存在所述第一死循环风险时,修改所述随机测试程序,判断所述随机测试程序是否存在第二循环风险;当所述随机测试程序不存在第二循环风险时,修改全自动随机测试程序生成器ARTPG状态、处理器状态和所述合法指令集。
- 根据权利要求1所述的方法,其中,所述修改所述随机测试程序包括:当分支跳转地址超过程序空间界限时,修改所述分支跳转地址使其不超过所述程序空间界限;当分支跳转判定条件在声明到使用之间没有修改操作时,增加修改指令;当所述修改操作的收敛方向与所述分支跳转判定条件不一致时,修改所述修改操作的收敛方向使其与所述分支跳转判定条件一致;当所述指令包包括函数调用指令或软件中断指令时,添加现场保存及恢复的指令。
- 根据权利要求1所述的方法,其中,所述修改所述ARTPG状态包括:根据功能覆盖率反馈信息调整随机权重。
- 根据权利要求1所述的方法,其中,所述修改所述合法指令集包括:将修改后的输出寄存器添加到对应的合法输入操作数;将所述合法输入操作数对应的指令添加到所述合法指令集;当所述指令包包括所述函数调用指令或所述软件中断指令时,将当前返回地址压至堆栈,在所述函数调用指令或所述软件中断指令前添加所述现场保存的指令。
- 根据权利要求1至4任一项所述的方法,其中,在所述修改所述随机测试程序之后及在所述判断所述随机测试程序是否存在第二循环风险之前,所述方法还包括:执行指令局部仿真或者执行指令全局仿真。
- 根据权利要求5所述的方法,其中,所述修改ARTPG状态、处理器状态和所述合法指令集之后,所述方法还包括:当所述随机测试程序生成的第一发射指令数等于随机选择的第二发射指令数且所述随机测试程序满足终止条件时,输出所述随机测试程序、随机测试程序执行结果和覆盖率分析报告。
- 一种随机测试程序生成装置,所述装置包括:第一判断模块,配置为在合法指令集中随机选择指令包并生成所述指令包,判断所述指令包是否包括分支跳转指令;第二判断模块,配置为当所述指令包包括所述分支跳转指令时,判断所述随机测试程序是否存在第一死循环风险;第三判断模块,配置为当所述随机测试程序存在所述第一死循环风险时,修改所述随机测试程序,判断所述随机测试程序是否存在第二循环风险。修改模块,配置为当所述随机测试程序不存在第二循环风险时,修改全自动随机测试程序生成器ARTPG状态、处理器状态和所述合法指令集。
- 根据权利要求7所述的装置,其中,所述第三判断模块,配置为 修改所述随机测试程序包括:当分支跳转地址超过程序空间界限时,修改所述分支跳转地址使其不超过所述程序空间界限;当分支跳转判定条件在声明到使用之间没有修改操作时,增加修改指令;当所述修改操作的收敛方向与所述分支跳转判定条件不一致时,修改所述修改操作的收敛方向使其与所述分支跳转判定条件一致;当所述指令包包括函数调用指令或软件中断指令时,添加现场保存及恢复的指令。
- 根据权利要求7所述的装置,其中,所述修改模块,配置为修改所述ARTPG状态包括:根据功能覆盖率反馈信息调整随机权重。
- 根据权利要求7所述的装置,其中,所述修改模块,配置为修改所述合法指令集包括:将修改后的输出寄存器添加到对应的合法输入操作数;将所述合法输入操作数对应的指令添加到所述合法指令集;当所述指令包包括所述函数调用指令或所述软件中断指令时,将当前返回地址压至堆栈,在所述函数调用指令或所述软件中断指令前添加所述现场保存的指令。
- 根据权利要求7至10任一项所述的装置,其中,所述第三判断模块,还配置为在所述修改所述随机测试程序之后及在所述判断所述随机测试程序是否存在第二循环风险之前,执行指令局部仿真或者执行指令全局仿真。
- 根据权利要求11所述的装置,其中,所述装置还包括:输出模块,配置为当所述随机测试程序生成的第一发射指令数等于 随机选择的第二发射指令数且所述随机测试程序满足终止条件时,输出所述随机测试程序、随机测试程序执行结果和覆盖率分析报告。
- 一种计算机存储介质,所述计算机存储介质中存储有计算机可执行指令,该计算机可执行指令用于执行权利要求1至6任一项所述的随机测试程序生成方法。
- 一种随机测试程序生成设备,所述设备包括:存储介质,配置为存储计算机可执行指令;处理器,配置为执行存储在所述存储介质上的计算机可执行指令,所述计算机可执行指令包括:在合法指令集中随机选择指令包并生成所述指令包,判断所述指令包是否包括分支跳转指令;当所述指令包包括所述分支跳转指令时,判断所述随机测试程序是否存在第一死循环风险;当所述随机测试程序存在所述第一死循环风险时,修改所述随机测试程序,判断所述随机测试程序是否存在第二循环风险;当所述随机测试程序不存在第二循环风险时,修改全自动随机测试程序生成器ARTPG状态、处理器状态和所述合法指令集。
Applications Claiming Priority (2)
Application Number | Priority Date | Filing Date | Title |
---|---|---|---|
CN201510334812.4 | 2015-06-16 | ||
CN201510334812.4A CN106325827B (zh) | 2015-06-16 | 2015-06-16 | 一种随机测试程序生成方法及装置 |
Publications (2)
Publication Number | Publication Date |
---|---|
WO2016202157A2 true WO2016202157A2 (zh) | 2016-12-22 |
WO2016202157A3 WO2016202157A3 (zh) | 2017-02-09 |
Family
ID=57544910
Family Applications (1)
Application Number | Title | Priority Date | Filing Date |
---|---|---|---|
PCT/CN2016/083560 WO2016202157A2 (zh) | 2015-06-16 | 2016-05-26 | 一种随机测试程序生成方法及装置、设备、存储介质 |
Country Status (2)
Country | Link |
---|---|
CN (1) | CN106325827B (zh) |
WO (1) | WO2016202157A2 (zh) |
Cited By (3)
Publication number | Priority date | Publication date | Assignee | Title |
---|---|---|---|---|
CN110275818A (zh) * | 2018-03-13 | 2019-09-24 | 龙芯中科技术有限公司 | 测试程序生成方法、装置及存储介质 |
CN111523283A (zh) * | 2020-04-16 | 2020-08-11 | 北京百度网讯科技有限公司 | 一种验证处理器的方法、装置、电子设备及存储介质 |
CN113760700A (zh) * | 2020-08-06 | 2021-12-07 | 北京京东振世信息技术有限公司 | 程序死循环检测方法、装置、电子设备及存储介质 |
Families Citing this family (4)
Publication number | Priority date | Publication date | Assignee | Title |
---|---|---|---|---|
CN108875369B (zh) * | 2017-05-15 | 2020-07-07 | 中国移动通信有限公司研究院 | 一种控制流完整性校验方法、装置和计算机存储介质 |
CN109240859B (zh) * | 2017-07-11 | 2021-11-19 | 展讯通信(上海)有限公司 | 处理器验证系统及方法 |
CN112416666B (zh) * | 2019-08-21 | 2022-07-12 | 无锡江南计算技术研究所 | 自检随机测试方法及随机循环测试装置 |
CN117112033B (zh) * | 2023-08-28 | 2024-04-12 | 海光信息技术(成都)有限公司 | 随机指令生成方法、装置、设备以及存储介质 |
Family Cites Families (9)
Publication number | Priority date | Publication date | Assignee | Title |
---|---|---|---|---|
JP2001222442A (ja) * | 2000-02-08 | 2001-08-17 | Fujitsu Ltd | パイプライン試験方法、パイプライン試験命令生成方法及びその記憶媒体 |
US6948096B2 (en) * | 2001-07-31 | 2005-09-20 | Intel Corporation | Functional random instruction testing (FRIT) method for complex devices such as microprocessors |
CN100336032C (zh) * | 2004-12-24 | 2007-09-05 | 清华大学 | 基于边界条件和自检查随机测试的cpu约束生成验证法 |
CN100468357C (zh) * | 2006-05-30 | 2009-03-11 | 上海科泰世纪科技有限公司 | 图形用户界面程序的自动测试接口及其自动测试方法 |
CN102567169B (zh) * | 2010-12-29 | 2014-02-26 | 无锡江南计算技术研究所 | 微处理器的测试方法及测试装置 |
CN102736973A (zh) * | 2011-04-07 | 2012-10-17 | 中国科学技术大学 | 不变量指导的随机测试用例自动化生成方法 |
CN102508780B (zh) * | 2011-11-21 | 2014-08-20 | 电子科技大学 | 一种用于软件测试的交叉式动态法和装置 |
CN103150228B (zh) * | 2013-02-22 | 2014-06-04 | 中国人民解放军国防科学技术大学 | 面向高速缓冲存储器的可综合伪随机验证方法及装置 |
US10061672B2 (en) * | 2013-03-07 | 2018-08-28 | International Business Machines Corporation | Implementing random content of program loops in random test generation for processor verification |
-
2015
- 2015-06-16 CN CN201510334812.4A patent/CN106325827B/zh active Active
-
2016
- 2016-05-26 WO PCT/CN2016/083560 patent/WO2016202157A2/zh active Application Filing
Cited By (5)
Publication number | Priority date | Publication date | Assignee | Title |
---|---|---|---|---|
CN110275818A (zh) * | 2018-03-13 | 2019-09-24 | 龙芯中科技术有限公司 | 测试程序生成方法、装置及存储介质 |
CN110275818B (zh) * | 2018-03-13 | 2024-04-30 | 龙芯中科技术股份有限公司 | 硅后验证方法、装置及存储介质 |
CN111523283A (zh) * | 2020-04-16 | 2020-08-11 | 北京百度网讯科技有限公司 | 一种验证处理器的方法、装置、电子设备及存储介质 |
CN111523283B (zh) * | 2020-04-16 | 2023-05-26 | 北京百度网讯科技有限公司 | 一种验证处理器的方法、装置、电子设备及存储介质 |
CN113760700A (zh) * | 2020-08-06 | 2021-12-07 | 北京京东振世信息技术有限公司 | 程序死循环检测方法、装置、电子设备及存储介质 |
Also Published As
Publication number | Publication date |
---|---|
WO2016202157A3 (zh) | 2017-02-09 |
CN106325827A (zh) | 2017-01-11 |
CN106325827B (zh) | 2019-07-19 |
Similar Documents
Publication | Publication Date | Title |
---|---|---|
WO2016202157A2 (zh) | 一种随机测试程序生成方法及装置、设备、存储介质 | |
KR102026662B1 (ko) | 프로세서 검증을 위한 테스트 케이스 생성 장치 및 방법과, 검증장치 | |
CN103927187B (zh) | 嵌入式系统程序执行方法 | |
US20150074647A1 (en) | Testing system for an integrated software system | |
CN103649907B (zh) | 高度并发处理任务的记录和执行 | |
CN113626324B (zh) | 一种面向Move语言虚拟机的模糊测试方法 | |
EP3769244A1 (en) | A method and system for detecting and preventing issues in smart contracts based on historical behavior analysis | |
US11023366B2 (en) | Diminution of test templates in test suites | |
US11275661B1 (en) | Test generation of a distributed system | |
US20160171141A1 (en) | Verification environments utilzing hardware description languages | |
JP2015219906A (ja) | ソフトウェア確認方法およびプロセッサ | |
CN113849405A (zh) | 基于fpga的智能应用在线设计评估系统及方法 | |
KR20150047007A (ko) | 복수의 프로세서들을 병렬적으로 이용하여 시뮬레이션을 수행하는 방법 및 장치 | |
WO2014139395A1 (en) | Early generation of individuals to accelerate genetic algorithms | |
CN107665169B (zh) | 处理器程序的测试方法和装置 | |
Yu et al. | Simlatte: A framework to support testing for worst-case interrupt latencies in embedded software | |
US20130283238A1 (en) | Testing system for an integrated software system | |
Faravelon et al. | Fast and accurate branch predictor simulation | |
US9727735B2 (en) | Method and system for simulating the effects of an attack on a computer code | |
CN108021792B (zh) | 镜像软件的生成方法、装置及相应终端 | |
CN114661477A (zh) | 一种低能耗的区块资源证明方法、装置和电子设备 | |
CN115328772A (zh) | 激励组合与模块相关性的学习方法与测试脚本产生方法 | |
Mohammadi et al. | Machine learning assisted stochastic unit commitment: A feasibility study | |
Melesse Vergara et al. | A step towards the final frontier: Lessons learned from acceptance testing of the first HPE/Cray EX 3000 system at ORNL | |
White et al. | Comparison of security models: Attack graphs versus petri nets |
Legal Events
Date | Code | Title | Description |
---|---|---|---|
NENP | Non-entry into the national phase in: |
Ref country code: DE |
|
122 | Ep: pct application non-entry in european phase |
Ref document number: 16810898 Country of ref document: EP Kind code of ref document: A2 |