CN115718685A - CPU test method, device, electronic equipment and storage medium - Google Patents
CPU test method, device, electronic equipment and storage medium Download PDFInfo
- Publication number
- CN115718685A CN115718685A CN202211486589.1A CN202211486589A CN115718685A CN 115718685 A CN115718685 A CN 115718685A CN 202211486589 A CN202211486589 A CN 202211486589A CN 115718685 A CN115718685 A CN 115718685A
- Authority
- CN
- China
- Prior art keywords
- random
- test
- cpu
- test case
- running
- Prior art date
- Legal status (The legal status 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 status listed.)
- Pending
Links
Images
Landscapes
- Test And Diagnosis Of Digital Computers (AREA)
Abstract
本发明的实施例提供了一种CPU测试方法、装置、电子设备及存储介质,涉及测试技术领域。包括:根据验证场景构建基础测试用例;为基础测试用例配置外源随机激励,得到随机测试用例;控制CPU执行随机测试用例,生成测试结果;读取状态寄存器的状态值,根据状态值判断运行测试是否完成;若运行测试完成,则根据测试结果判断随机测试用例是否执行成功,并在确定随机测试用例执行成功时结束此次运行测试。通过接入外源随机激励来丰富测试场景;仅用C语言进行仿真环境,复杂度不高;同时采用真实的CPU确保测试场景的完备性以及测试结果的可靠性。
Embodiments of the present invention provide a CPU testing method, device, electronic equipment and storage medium, and relate to the technical field of testing. Including: building basic test cases according to verification scenarios; configuring external random stimulus for basic test cases to obtain random test cases; controlling the CPU to execute random test cases to generate test results; reading the state value of the status register, and judging the running test according to the state value Whether it is completed; if the running test is completed, judge whether the random test case is successfully executed according to the test result, and end the running test when it is determined that the random test case is successfully executed. The test scenarios are enriched by accessing external random excitations; the simulation environment is only used in C language, and the complexity is not high; at the same time, a real CPU is used to ensure the completeness of the test scenarios and the reliability of the test results.
Description
技术领域technical field
本发明涉及测试技术领域,具体而言,涉及一种CPU测试方法、装置、电子设备及存储介质。The present invention relates to the technical field of testing, in particular to a CPU testing method, device, electronic equipment and storage medium.
背景技术Background technique
随着半导体产业的发展,SOC(System On Chip,系统级芯片)的功能越来越复杂,提高CPU(Central Processing Unit,中央处理器)子系统的验证效率及可靠性对SOC开发具有重要意义。With the development of the semiconductor industry, the functions of SOC (System On Chip, System-on-Chip) are becoming more and more complex. Improving the verification efficiency and reliability of the CPU (Central Processing Unit, central processing unit) subsystem is of great significance to the development of SOC.
现有的CPU子系统一般通过仿真环境来测试,可以采用虚拟组件替换真实的CPU,但是这一测试方式可靠性不高。若是在真实的CPU下进行仿真验证,采用较为简单的C语言/C++产生驱动程序和激励,但是CPU本身没有有效的生成随机激励的机制,因此这种仿真环境下的测试场景单一。Existing CPU subsystems are generally tested through a simulation environment, and virtual components can be used to replace the real CPU, but the reliability of this test method is not high. If the simulation verification is carried out under the real CPU, the relatively simple C language/C++ is used to generate the driver and stimulus, but the CPU itself does not have an effective mechanism for generating random stimulus, so the test scenarios in this simulation environment are single.
因此,亟需一种可靠性高且测试场景更多的CPU测试方法。Therefore, there is an urgent need for a CPU testing method with high reliability and more test scenarios.
发明内容Contents of the invention
为了解决上述技术问题,本申请实施例提供了一种CPU测试方法、装置、电子设备及存储介质。In order to solve the above technical problems, the embodiments of the present application provide a CPU testing method, device, electronic equipment, and storage medium.
第一方面,本申请实施例提供了一种CPU测试方法,所述方法包括:In the first aspect, the embodiment of the present application provides a CPU testing method, the method comprising:
根据验证场景构建基础测试用例;Build basic test cases based on verification scenarios;
为所述基础测试用例配置外源随机激励,得到随机测试用例;Configuring an external source random stimulus for the basic test case to obtain a random test case;
控制CPU执行所述随机测试用例,生成测试结果;Control CPU to carry out described random test case, generate test result;
读取状态寄存器的状态值,根据所述状态值判断运行测试是否完成;Read the status value of the status register, and judge whether the running test is completed according to the status value;
若所述运行测试完成,则根据所述测试结果判断所述随机测试用例是否执行成功,并在确定所述随机测试用例执行成功时结束此次运行测试。If the running test is completed, judge whether the random test case is executed successfully according to the test result, and end the running test when it is determined that the random test case is executed successfully.
在一实施方式中,所述为所述基础测试用例配置外源随机激励,得到随机测试用例,包括:In one embodiment, the configuration of external random stimulus for the basic test case to obtain a random test case includes:
为所述基础测试用例配置预设种子号,得到验证测试用例;Configuring a preset seed number for the basic test case to obtain a verification test case;
对所述验证测试用例进行验证;Verifying the verification test case;
若所述验证通过,使用外部的local(time)函数生成随机种子号,为所述基础测试用例配置所述随机种子号,得到所述随机测试用例。If the verification is passed, an external local(time) function is used to generate a random seed number, and the random seed number is configured for the basic test case to obtain the random test case.
在一实施方式中,所述使用外部的local(time)函数生成随机种子号,包括:In one embodiment, the use of an external local (time) function to generate a random seed number includes:
获取当前时刻对应的第一系统时间;Obtain the first system time corresponding to the current moment;
使用所述local(time)函数将所述第一系统时间转换为所述随机种子号。Using the local(time) function to convert the first system time into the random seed number.
在一实施方式中,所述方法还包括:In one embodiment, the method also includes:
更新所述随机种子号;update the random seed number;
生成新的测试用例,并用新的测试用例执行运行测试。Generate new test cases, and execute running tests with the new test cases.
在一实施方式中,所述更新所述随机种子号,包括:In one embodiment, the updating of the random seed number includes:
获取当前时刻对应的第二系统时间;Obtain the second system time corresponding to the current moment;
使用所述local(time)函数将所述第二系统时间转换为更新种子号;Using the local(time) function to convert the second system time into an update seed number;
使用所述更新种子号替换所述随机种子号。The random seed number is replaced with the updated seed number.
在一实施方式中,所述控制CPU执行所述随机测试用例,包括:In one embodiment, the execution of the random test case by the control CPU includes:
从所述CPU外部的静态存储器中获取操作码,以使所述CPU根据所述操作码执行所述随机测试用例。Obtaining an operation code from a static memory outside the CPU, so that the CPU executes the random test case according to the operation code.
在一实施方式中,述控制CPU执行所述随机测试用例之前的步骤,还包括:In one embodiment, the steps before the control CPU executes the random test case also include:
对所述随机测试用例进行编译,得到编译结果并生成编译日志;Compiling the random test case, obtaining a compilation result and generating a compilation log;
将所述编译结果存储至所述静态存储器中;storing the compilation result in the static memory;
若所述随机测试用例执行失败,根据所述编译日志和所述测试结果进行错误排查。If the execution of the random test case fails, error checking is performed according to the compilation log and the test result.
第二方面,本申请实施例提供了一种CPU测试装置,所述CPU测试装置包括:In a second aspect, the embodiment of the present application provides a CPU testing device, the CPU testing device comprising:
构建模块,用于根据验证场景构建基础测试用例;Building blocks for building basic test cases based on verification scenarios;
配置模块,用于为所述基础测试用例配置外源随机激励,得到随机测试用例;A configuration module, configured to configure an external source random stimulus for the basic test case to obtain a random test case;
执行模块,用于控制CPU执行所述随机测试用例,生成测试结果;Execution module, is used for controlling CPU to carry out described random test case, generates test result;
判断模块,用于读取状态寄存器的状态值,根据所述状态值判断运行测试是否完成;Judging module, for reading the status value of the status register, and judging whether the running test is completed according to the status value;
确定模块,用于若所述运行测试完成,则根据所述测试结果判断所述随机测试用例是否执行成功,并在确定所述随机测试用例执行成功时结束此次运行测试。The determining module is configured to judge whether the random test case is executed successfully according to the test result if the running test is completed, and end the running test when it is determined that the random test case is executed successfully.
第三方面,本申请实施例提供了一种电子设备,包括存储器以及处理器,所述存储器用于存储计算机程序,所述计算机程序在所述处理器运行时执行第一方面提供的CPU测试方法。In a third aspect, an embodiment of the present application provides an electronic device, including a memory and a processor, the memory is used to store a computer program, and the computer program executes the CPU testing method provided in the first aspect when the processor is running .
第四方面,本申请实施例提供了一种计算机可读存储介质,其存储有计算机程序,所述计算机程序在处理器上运行时执行第一方面提供的CPU测试方法。In a fourth aspect, the embodiment of the present application provides a computer-readable storage medium, which stores a computer program, and the computer program executes the CPU testing method provided in the first aspect when running on a processor.
上述本申请提供的CPU测试方法,根据验证场景构建基础测试用例;为基础测试用例配置外源随机激励,得到随机测试用例;控制CPU执行随机测试用例,生成测试结果;读取状态寄存器的状态值,根据状态值判断运行测试是否完成;若运行测试完成,则根据测试结果判断随机测试用例是否执行成功,并在确定随机测试用例执行成功时结束此次运行测试。通过接入外源随机激励来丰富测试场景;仅用C语言进行仿真环境,复杂度不高;同时采用真实的CPU确保测试场景的完备性以及测试结果的可靠性。The CPU test method provided by the above-mentioned application constructs a basic test case according to the verification scenario; configures an external source random stimulus for the basic test case to obtain a random test case; controls the CPU to execute a random test case to generate test results; reads the state value of the status register , judge whether the running test is completed according to the state value; if the running test is completed, judge whether the random test case is successfully executed according to the test result, and end the running test when it is determined that the random test case is successfully executed. The test scenarios are enriched by accessing external random excitations; the simulation environment is only used in C language, and the complexity is not high; at the same time, a real CPU is used to ensure the completeness of the test scenarios and the reliability of the test results.
附图说明Description of drawings
为了更清楚地说明本申请的技术方案,下面将对实施例中所需要使用的附图作简单地介绍,应当理解,以下附图仅示出了本申请的某些实施例,因此不应被看作是对本申请保护范围的限定。在各个附图中,类似的构成部分采用类似的编号。In order to illustrate the technical solution of the present application more clearly, the accompanying drawings used in the embodiments will be briefly introduced below. It should be understood that the following drawings only show some embodiments of the application, and therefore should not be regarded It is regarded as a limitation on the scope of protection of the present application. In the respective drawings, similar components are given similar reference numerals.
图1示出了本申请实施例提供的CPU测试方法的一流程示意图;Fig. 1 shows a schematic flow chart of the CPU testing method provided by the embodiment of the present application;
图2示出了本申请实施例提供的仿真环境的一结构示意图;Fig. 2 shows a schematic structural diagram of the simulation environment provided by the embodiment of the present application;
图3示出了本申请实施例提供的CPU测试装置的一结构示意图。FIG. 3 shows a schematic structural diagram of a CPU testing device provided by an embodiment of the present application.
具体实施方式Detailed ways
下面将结合本申请实施例中附图,对本申请实施例中的技术方案进行清楚、完整地描述,显然,所描述的实施例仅仅是本申请一部分实施例,而不是全部的实施例。The following will clearly and completely describe the technical solutions in the embodiments of the present application with reference to the accompanying drawings in the embodiments of the present application. Obviously, the described embodiments are only some of the embodiments of the present application, not all of them.
通常在此处附图中描述和示出的本申请实施例的组件可以以各种不同的配置来布置和设计。因此,以下对在附图中提供的本申请的实施例的详细描述并非旨在限制要求保护的本申请的范围,而是仅仅表示本申请的选定实施例。基于本申请的实施例,本领域技术人员在没有做出创造性劳动的前提下所获得的所有其他实施例,都属于本申请保护的范围。The components of the embodiments of the application generally described and illustrated in the figures herein may be arranged and designed in a variety of different configurations. Accordingly, the following detailed description of the embodiments of the application provided in the accompanying drawings is not intended to limit the scope of the claimed application, but merely represents selected embodiments of the application. Based on the embodiments of the present application, all other embodiments obtained by those skilled in the art without making creative efforts belong to the scope of protection of the present application.
在下文中,可在本申请的各种实施例中使用的术语“包括”、“具有”及其同源词仅意在表示特定特征、数字、步骤、操作、元件、组件或前述项的组合,并且不应被理解为首先排除一个或更多个其它特征、数字、步骤、操作、元件、组件或前述项的组合的存在或增加一个或更多个特征、数字、步骤、操作、元件、组件或前述项的组合的可能性。Hereinafter, the terms "comprising", "having" and their cognates that may be used in various embodiments of the present application are only intended to represent specific features, numbers, steps, operations, elements, components or combinations of the foregoing, And it should not be understood as first excluding the existence of one or more other features, numbers, steps, operations, elements, components or combinations of the foregoing or adding one or more features, numbers, steps, operations, elements, components or a combination of the foregoing possibilities.
此外,术语“第一”、“第二”、“第三”等仅用于区分描述,而不能理解为指示或暗示相对重要性。In addition, the terms "first", "second", "third", etc. are only used for distinguishing descriptions, and should not be construed as indicating or implying relative importance.
除非另有限定,否则在这里使用的所有术语(包括技术术语和科学术语)具有与本申请的各种实施例所属领域普通技术人员通常理解的含义相同的含义。所述术语(诸如在一般使用的词典中限定的术语)将被解释为具有与在相关技术领域中的语境含义相同的含义并且将不被解释为具有理想化的含义或过于正式的含义,除非在本申请的各种实施例中被清楚地限定。Unless otherwise defined, all terms (including technical terms and scientific terms) used herein have the same meaning as commonly understood by one of ordinary skill in the art to which various embodiments of the application belong. The terms (such as those defined in commonly used dictionaries) will be interpreted as having the same meaning as the contextual meaning in the relevant technical field and will not be interpreted as having an idealized meaning or an overly formal meaning, Unless clearly defined in the various embodiments of the present application.
实施例1Example 1
随着半导体产业的发展,SOC(System On Chip,系统级芯片)的功能越来越复杂,提高CPU子系统的验证效率及可靠性对SOC开发具有重要意义。基于此,本公开实施例提供了一种CPU测试方法。With the development of the semiconductor industry, the functions of SOC (System On Chip, system-on-chip) are becoming more and more complex. Improving the verification efficiency and reliability of the CPU subsystem is of great significance to the development of SOC. Based on this, an embodiment of the present disclosure provides a CPU testing method.
具体的,参见图1,CPU测试方法包括:Specifically, referring to Figure 1, the CPU testing method includes:
本申请实施例提供的CPU测试方法,主要应用在CPU测试的仿真环境中,主要用于测试CPU的子系统。其中,如图2所示,所述仿真环境包括5个组件:DUT、驱动程序存储SRAM、驱动程序和监控信息。The CPU testing method provided in the embodiment of the present application is mainly applied in a simulation environment of CPU testing, and is mainly used for testing a subsystem of the CPU. Wherein, as shown in FIG. 2 , the simulation environment includes five components: DUT, driver program storage SRAM, driver program and monitoring information.
其中,DUT(Design under Test,待测设计)也就是本申请实施例需要测试的部分,包括CPU、IP核和外设的RTL(Register Transfer Level、寄存器转换级电路)。其中外设中的一个SRAM(Static Random Access Memory、静态随机存储器)会划分固定区域用作CPU的启动ROM(Read-Only Memory,只读存储器)。Wherein, the DUT (Design under Test, design under test) is the part that needs to be tested in the embodiment of the present application, including the RTL (Register Transfer Level, register transfer level circuit) of the CPU, IP core and peripherals. A SRAM (Static Random Access Memory, static random access memory) in the peripheral device will divide a fixed area and use it as a boot ROM (Read-Only Memory, read-only memory) of the CPU.
SRAM用于缓存testcase(测试用例)。当驱动程序写入SRAM后,仿真环境会将SRAM中的驱动程序读取出来放入CPU的启动ROM中,CPU将驱动程序解析,和对应外设完成命令的执行。SRAM is used to cache testcase (test cases). After the driver program is written into the SRAM, the simulation environment will read the driver program in the SRAM and put it into the boot ROM of the CPU. The CPU will analyze the driver program and complete the command execution with the corresponding peripherals.
驱动程序包括CPU的启动程序和testcase(测试用例)。其中CPU启动程序由汇编语言实现。testcase则是一个可执行文件C文件,用来实现需要仿真的测试场景,它通过调用外部的随机程序产生随机激励。同时testcase中也实现了checker(判断)的功能。The driver program includes the CPU startup program and testcase (test case). Among them, the CPU startup program is realized by assembly language. testcase is an executable C file, which is used to realize the test scenario that needs to be simulated. It generates random stimulus by calling an external random program. At the same time, the checker (judgment) function is also implemented in the testcase.
checker的作用是监控仿真是否符合预期。在testcase执行过程中,checker通过读取状态寄存器来判断testcase执行是否出现错误或异常;在命令执行完后,checker进行数据比对来判断testcase中是否执行成功。最后将判断结果作为仿真的监控信息输出。The role of the checker is to monitor whether the simulation meets expectations. During the execution of the testcase, the checker judges whether there is an error or abnormality in the execution of the testcase by reading the status register; after the command is executed, the checker compares the data to judge whether the execution of the testcase is successful. Finally, the judgment result is output as the monitoring information of the simulation.
该仿真环境的监控信息分为两个部分。第一部分是CPU启动程序和testcase的汇编日志文件,用来记录testcase的汇编信息。在Debug过程中,可通过CPU的PC地址得到对应的指令信息。第二部分是testcase仿真产生的日志信息,包含随机激励的信息和checker的结果。The monitoring information of the simulation environment is divided into two parts. The first part is the compilation log file of the CPU startup program and testcase, which is used to record the compilation information of the testcase. During the debugging process, the corresponding instruction information can be obtained through the PC address of the CPU. The second part is the log information generated by the testcase simulation, including random incentive information and checker results.
基于上述组件及其功能,开始仿真。步骤S110,根据验证场景构建基础测试用例;其中,基础测试用例是一个可执行文件。Based on the above components and their functions, start the simulation. Step S110, building a basic test case according to the verification scenario; wherein, the basic test case is an executable file.
步骤S120,为所述基础测试用例配置外源随机激励,得到随机测试用例;外源随机激励用于提升场景的覆盖率,可以通过调用外部的task_rand程序生成。这时,可以从CPU外设SRAM中划分一段区域用作CPU的启动ROM。Step S120, configuring an external random stimulus for the basic test case to obtain a random test case; the external random stimulus is used to improve the coverage of the scenario and can be generated by calling an external task_rand program. At this time, a section of area can be divided from the CPU peripheral SRAM to be used as the boot ROM of the CPU.
基于RISCV架构的CPU自身指令集没有随机函数,因此本实施例复现C语言的rand随机函数,如算法一所示:The instruction set of the CPU itself based on the RISCV architecture does not have a random function, so this embodiment reproduces the rand random function of the C language, as shown in Algorithm 1:
算法一:Algorithm one:
C语言的rand随机函数通过srand函数将系统时间转换为种子号,如算法二所示:The rand random function of the C language converts the system time into a seed number through the srand function, as shown in Algorithm 2:
算法二:Algorithm 2:
void srand(unsigned int seed){void srand(unsigned int seed){
next=seed;next=seed;
}}
但是嵌入式CPU没有有效的随机种子生成机制,因此本申请实施例采用外部程序产生随机激励,请参见算法三:However, the embedded CPU does not have an effective random seed generation mechanism, so the embodiment of this application uses an external program to generate random incentives, please refer to Algorithm 3:
算法三:Algorithm three:
需要注意的是,首先需要对各基础测试用例进行初步的仿真验证,确认每一个testcase实现了对应的验证场景(feature),待每个testcase流程确认无误且仿真结果符合预期之后,才能进行下一步验证。It should be noted that, firstly, it is necessary to perform preliminary simulation verification on each basic test case to confirm that each test case has realized the corresponding verification scenario (feature), and the next step can only be carried out after each test case process is confirmed to be correct and the simulation results meet expectations verify.
基于此,在一实施方式中,为所述基础测试用例配置预设种子号,得到验证测试用例;对所述验证测试用例进行验证;其中,预设种子号可以为0。Based on this, in one embodiment, a preset seed number is configured for the basic test case to obtain a verification test case; the verification test case is verified; wherein, the preset seed number may be 0.
若所述验证通过,使用外部的local(time)函数生成随机种子号,为所述基础测试用例配置所述随机种子号,得到所述随机测试用例。If the verification is passed, an external local(time) function is used to generate a random seed number, and the random seed number is configured for the basic test case to obtain the random test case.
生成随机种子号的过程称为回归验证,在每次回归验证过程中,采用不同的种子号为基础测试用例配置随机激励,来保证验证覆盖率的提升。The process of generating random seed numbers is called regression verification. In each regression verification process, different seed numbers are used as basic test cases to configure random incentives to ensure the improvement of verification coverage.
在一次的运行测试中,在一实施方式中,获取当前时刻对应的第一系统时间;使用所述local(time)函数将所述第一系统时间转换为所述随机种子号。In one running test, in one embodiment, the first system time corresponding to the current moment is acquired; the first system time is converted into the random seed number by using the local(time) function.
进入下次运行测试时,在一实施方式中,更新所述随机种子号;生成新的测试用例,并用新的测试用例执行运行测试。When entering the next running test, in one embodiment, update the random seed number; generate a new test case, and use the new test case to execute the running test.
在一实施方式中,本仿真环境采用perl脚本对所有测试用例进行回归验证,该脚本顺序执行文件里的每一行命令。在测试所有testcase流程是否无误时,perl脚本里的每行一行命令均为每条testcase仿真命令,回归次数为1。待流程确认无误且仿真通过后,再进行多次的回归验证。此时,在每条testcase仿真命令之前添加修改种子号的命令(命令1),来确保每次回归产生不同的随机激励。In one embodiment, the simulation environment uses a perl script to perform regression verification on all test cases, and the script executes each line of command in the file sequentially. When testing whether all testcase processes are correct, each line of command in the perl script is each testcase simulation command, and the number of regressions is 1. After the process is confirmed to be correct and the simulation is passed, multiple regression verifications are performed. At this point, add a command to modify the seed number (command 1) before each testcase simulation command to ensure that each regression produces a different random stimulus.
命令1:perl-pi-e’s|0x00000000|localtime(time)|g’testcase pathCommand 1: perl-pi-e's|0x00000000|localtime(time)|g'testcase path
在仿真执行之间,通过该命令将系统时间作为种子号替换testcase中的默认种子号0x00000000。其中local(time)为perl内置函数,会将系统时间转换成秒输出;其中testcase path’为待验证testcase的路径。Between simulation executions, use this command to use the system time as the seed number to replace the default seed number 0x00000000 in testcase. Among them, local(time) is a built-in function of perl, which will convert the system time into second output; among them, testcase path' is the path of the testcase to be verified.
仿真环境中每条testcase中的种子号均设置为0x00000000,而testcase中其它零值均用0x0表示,以此来确保种子号的修改不会影响testcase中其它函数的功能。The seed number in each testcase in the simulation environment is set to 0x00000000, and other zero values in the testcase are represented by 0x0, so as to ensure that the modification of the seed number will not affect the functions of other functions in the testcase.
接下来执行testcase的仿真命令,不同仿真时间下,同一testcase得到不同的种子号从而产生不同的激励,多次回归后即可完成场景的较完全覆盖。Next, execute the simulation command of the testcase. Under different simulation times, the same testcase gets different seed numbers to generate different incentives. After multiple regressions, the scene can be completely covered.
在该testcase执行完毕后,再用perl命令(命令2)将随机种子号修改为默认值0x00000000,以供同一testcase下次得到其它随机种子号,从而实现该外设随机函数的复用。After the testcase is executed, use the perl command (command 2) to modify the random seed number to the default value 0x00000000, so that the same testcase can get other random seed numbers next time, so as to realize the multiplexing of the peripheral random function.
命令2:perl–pi–e‘s|randseed=(.*)|randseed=0x00000000|g’testcasepathwayCommand 2: perl --pi --e 's|randseed=(.*)|randseed=0x00000000|g' testcasepathway
步骤S130,控制CPU执行所述随机测试用例,生成测试结果;Step S130, controlling the CPU to execute the random test cases to generate test results;
在一实施方式中,从所述CPU外部的静态存储器中获取操作码,以使所述CPU根据所述操作码执行所述随机测试用例。In one embodiment, the operation code is obtained from a static memory outside the CPU, so that the CPU executes the random test case according to the operation code.
仿真开始时,仿真环境会从SRAM中获取操作码(opcode)放入CPU的启动ROM中。CPU从启动ROM中读取命令,对操作码进行解码和执行随机测试用例。When the simulation starts, the simulation environment will obtain the operation code (opcode) from the SRAM and put it into the boot ROM of the CPU. The CPU reads commands from the boot ROM, decodes opcodes and executes random test cases.
步骤S140,读取状态寄存器的状态值,根据所述状态值判断运行测试是否完成;Step S140, read the status value of the status register, and judge whether the running test is completed according to the status value;
在CPU执行随机用例的过程中,checker同步工作,将必要的地址和数据信息输出到日志文件中供该测试场景的复现,直至仿真结束。同时监控状态寄存器的状态值来判断仿真是否成功或者出现异常,将仿真结果存放入日志信息中。如果出现异常,则提前结束仿真。During the process of CPU executing a random use case, the checker works synchronously, and outputs the necessary address and data information to the log file for the reproduction of the test scenario until the end of the simulation. At the same time, the status value of the status register is monitored to determine whether the simulation is successful or abnormal, and the simulation results are stored in the log information. If an exception occurs, the simulation ends prematurely.
在一实施方式中,对所述随机测试用例进行编译,得到编译结果并生成编译日志;将所述编译结果存储至所述静态存储器中;In one embodiment, the random test case is compiled, a compilation result is obtained and a compilation log is generated; the compilation result is stored in the static memory;
可以使用makefile脚本编译随机测试用例,并将编译结果转成十六进制存储到SRAM中。同时会生成编译日志供后续错误排查(Debug)阶段使用。You can use the makefile script to compile random test cases, and convert the compiled results into hexadecimal and store them in SRAM. At the same time, a compilation log will be generated for use in the subsequent error checking (Debug) stage.
若所述随机测试用例执行失败,根据所述编译日志和所述测试结果进行错误排查。If the execution of the random test case fails, error checking is performed according to the compilation log and the test result.
步骤S150,若所述运行测试完成,则根据所述测试结果判断所述随机测试用例是否执行成功,并在确定所述随机测试用例执行成功时结束此次运行测试。仿真结束后,根据日志信息判断testcase是否执行成功。如果仿真成功,执行下一个待验证的testcase;如果失败,则根据编译日志和日志信息进行debug。Step S150, if the running test is completed, judge whether the random test case is successfully executed according to the test result, and end the running test when it is determined that the random test case is successfully executed. After the simulation is over, judge whether the testcase is successfully executed according to the log information. If the simulation is successful, execute the next testcase to be verified; if it fails, debug according to the compilation log and log information.
与现有技术相比,第一,采用System Verilog和UVM组件替换真实的CPU,虽然采用了标准的验证语言,但是用组件模拟的CPU可靠性不高。针对该缺点,本申请实施例的仿真环境采用真实的CPU,验证结果可靠性有保证。Compared with the existing technology, first, the real CPU is replaced by System Verilog and UVM components. Although a standard verification language is used, the reliability of the CPU simulated by the components is not high. In view of this shortcoming, the simulation environment of the embodiment of the present application uses a real CPU, and the reliability of the verification result is guaranteed.
第二,采用C语言/C++产生驱动程序,System Verilog产生随机激励,在真实的CPU下进行仿真验证,但是这种方法增加了仿真环境的复杂度。针对这个问题,本验证环境的驱动程序及随机函数均用C语言实现。Second, use C language/C++ to generate the driver program, System Verilog to generate random excitation, and perform simulation verification under the real CPU, but this method increases the complexity of the simulation environment. To solve this problem, the drivers and random functions of this verification environment are implemented in C language.
第三,采用C语言/C++产生驱动程序和激励,但是由于嵌入式CPU没有有效的种子机制,无法得到随机激励。针对这个问题,本验证环境通过外部随机函数在每次仿真过程中自动产生不同的随机激励。Third, use C language/C++ to generate drivers and incentives, but because the embedded CPU does not have an effective seed mechanism, random incentives cannot be obtained. To solve this problem, this verification environment automatically generates different random excitations in each simulation process through an external random function.
综上,本实施例提供的CPU测试方法,通过接入外源随机激励来丰富测试场景;仅用C语言进行仿真环境,复杂度不高;同时采用真实的CPU确保测试场景的完备性以及测试结果的可靠性。To sum up, the CPU test method provided in this embodiment enriches the test scenarios by accessing external source random excitation; the simulation environment is only used in C language, and the complexity is not high; at the same time, a real CPU is used to ensure the completeness of the test scenario and the test reliability of the results.
实施例2Example 2
此外,本公开实施例提供了一种CPU测试装置。In addition, an embodiment of the present disclosure provides a CPU testing device.
具体的,如图3所示,CPU测试装置300包括:Specifically, as shown in Figure 3, the
构建模块310,用于根据验证场景构建基础测试用例;A
配置模块320,用于为所述基础测试用例配置外源随机激励,得到随机测试用例;The
执行模块330,用于控制CPU执行所述随机测试用例,生成测试结果;
判断模块340,用于读取状态寄存器的状态值,根据所述状态值判断运行测试是否完成;Judging
确定模块350,用于若所述运行测试完成,则根据所述测试结果判断所述随机测试用例是否执行成功,并在确定所述随机测试用例执行成功时结束此次运行测试。The determining
本实施例提供的CPU测试装置300可以实现实施例1所提供的CPU测试方法,为避免重复,在此不再赘述。The
本实施例提供的CPU测试装置,通过接入外源随机激励来丰富测试场景;仅用C语言进行仿真环境,复杂度不高;同时采用真实的CPU确保测试场景的完备性以及测试结果的可靠性。The CPU test device provided in this embodiment enriches the test scenarios by accessing external source random excitation; only uses C language to simulate the environment, and the complexity is not high; at the same time, a real CPU is used to ensure the completeness of the test scenarios and the reliability of the test results sex.
实施例3Example 3
此外,本公开实施例提供了一种电子设备,包括存储器以及处理器,所述存储器存储有计算机程序,所述计算机程序在所述处理器上运行时执行实施例1所提供的CPU测试方法。In addition, an embodiment of the present disclosure provides an electronic device, including a memory and a processor, the memory stores a computer program, and the computer program executes the CPU testing method provided in Embodiment 1 when running on the processor.
本发明实施例提供的电子设备,可以实现实施例1所提供的CPU测试方法,为避免重复,在此不再赘述。The electronic device provided in the embodiment of the present invention can implement the CPU testing method provided in Embodiment 1, and details are not repeated here to avoid repetition.
本实施例提供的电子设备,通过接入外源随机激励来丰富测试场景;仅用C语言进行仿真环境,复杂度不高;同时采用真实的CPU确保测试场景的完备性以及测试结果的可靠性。The electronic equipment provided in this embodiment enriches the test scenarios by accessing external source random excitation; the simulation environment is only used in C language, and the complexity is not high; at the same time, a real CPU is used to ensure the completeness of the test scenarios and the reliability of the test results .
实施例4Example 4
本申请还提供一种计算机可读存储介质,所述计算机可读存储介质上存储计算机程序,所述计算机程序被处理器执行时实现实施例1所提供的CPU测试方法。The present application also provides a computer-readable storage medium, on which a computer program is stored, and when the computer program is executed by a processor, the CPU testing method provided in Embodiment 1 is realized.
在本实施例中,计算机可读存储介质可以为只读存储器(Read-Only Memory,简称ROM)、随机存取存储器(Random Access Memory,简称RAM)、磁碟或者光盘等。In this embodiment, the computer-readable storage medium may be a read-only memory (Read-Only Memory, ROM for short), a random access memory (Random Access Memory, RAM for short), a magnetic disk, or an optical disk.
本实施例提供的计算机可读存储介质可以实现实施例1所提供的CPU测试方法,为避免重复,在此不再赘述。The computer-readable storage medium provided in this embodiment can implement the CPU testing method provided in Embodiment 1, and details are not repeated here to avoid repetition.
需要说明的是,在本文中,术语“包括”、“包含”或者其任何其他变体意在涵盖非排他性的包含,从而使得包括一系列要素的过程、方法、物品或者终端不仅包括那些要素,而且还包括没有明确列出的其他要素,或者是还包括为这种过程、方法、物品或者终端所固有的要素。在没有更多限制的情况下,由语句“包括一个……”限定的要素,并不排除在包括该要素的过程、方法、物品或者终端中还存在另外的相同要素。It should be noted that, in this document, the term "comprising", "comprising" or any other variation thereof is intended to cover a non-exclusive inclusion such that a process, method, article or terminal comprising a set of elements includes not only those elements, It also includes other elements not expressly listed, or elements inherent in the process, method, article, or terminal. Without further limitations, an element defined by the phrase "comprising a ..." does not preclude the presence of additional identical elements in the process, method, article or terminal comprising the element.
通过以上的实施方式的描述,本领域的技术人员可以清楚地了解到上述实施例方法可借助软件加必需的通用硬件平台的方式来实现,当然也可以通过硬件,但很多情况下前者是更佳的实施方式。基于这样的理解,本申请的技术方案本质上或者说对现有技术做出贡献的部分可以以软件产品的形式体现出来,该计算机软件产品存储在一个存储介质(如ROM/RAM、磁碟、光盘)中,包括若干指令用以使得一台终端(可以是手机,计算机,服务器,空调器,或者网络设备等)执行本申请各个实施例所述的方法。Through the description of the above embodiments, those skilled in the art can clearly understand that the methods of the above embodiments can be implemented by means of software plus a necessary general-purpose hardware platform, and of course also by hardware, but in many cases the former is better implementation. Based on such an understanding, the technical solution of the present application can be embodied in the form of a software product in essence or the part that contributes to the prior art, and the computer software product is stored in a storage medium (such as ROM/RAM, disk, CD) contains several instructions to enable a terminal (which may be a mobile phone, a computer, a server, an air conditioner, or a network device, etc.) to execute the methods described in various embodiments of the present application.
上面结合附图对本申请的实施例进行了描述,但是本申请并不局限于上述的具体实施方式,上述的具体实施方式仅仅是示意性的,而不是限制性的,本领域的普通技术人员在本申请的启示下,在不脱离本申请宗旨和权利要求所保护的范围情况下,还可做出很多形式,均属于本申请的保护之内。The embodiments of the present application have been described above in conjunction with the accompanying drawings, but the present application is not limited to the above-mentioned specific implementations. The above-mentioned specific implementations are only illustrative and not restrictive. Those of ordinary skill in the art will Under the inspiration of this application, without departing from the purpose of this application and the scope of protection of the claims, many forms can also be made, all of which belong to the protection of this application.
Claims (10)
Priority Applications (1)
Application Number | Priority Date | Filing Date | Title |
---|---|---|---|
CN202211486589.1A CN115718685A (en) | 2022-11-24 | 2022-11-24 | CPU test method, device, electronic equipment and storage medium |
Applications Claiming Priority (1)
Application Number | Priority Date | Filing Date | Title |
---|---|---|---|
CN202211486589.1A CN115718685A (en) | 2022-11-24 | 2022-11-24 | CPU test method, device, electronic equipment and storage medium |
Publications (1)
Publication Number | Publication Date |
---|---|
CN115718685A true CN115718685A (en) | 2023-02-28 |
Family
ID=85256370
Family Applications (1)
Application Number | Title | Priority Date | Filing Date |
---|---|---|---|
CN202211486589.1A Pending CN115718685A (en) | 2022-11-24 | 2022-11-24 | CPU test method, device, electronic equipment and storage medium |
Country Status (1)
Country | Link |
---|---|
CN (1) | CN115718685A (en) |
Cited By (2)
Publication number | Priority date | Publication date | Assignee | Title |
---|---|---|---|---|
CN119377030A (en) * | 2024-12-31 | 2025-01-28 | 北京开源芯片研究院 | System-on-chip verification method, device, electronic device and readable storage medium |
CN120044379A (en) * | 2025-04-22 | 2025-05-27 | 北京燧原智能科技有限公司 | Chip random test method, device, equipment and storage medium |
-
2022
- 2022-11-24 CN CN202211486589.1A patent/CN115718685A/en active Pending
Cited By (2)
Publication number | Priority date | Publication date | Assignee | Title |
---|---|---|---|---|
CN119377030A (en) * | 2024-12-31 | 2025-01-28 | 北京开源芯片研究院 | System-on-chip verification method, device, electronic device and readable storage medium |
CN120044379A (en) * | 2025-04-22 | 2025-05-27 | 北京燧原智能科技有限公司 | Chip random test method, device, equipment and storage medium |
Similar Documents
Publication | Publication Date | Title |
---|---|---|
US5202889A (en) | Dynamic process for the generation of biased pseudo-random test patterns for the functional verification of hardware designs | |
US11204859B2 (en) | Partial-results post-silicon hardware exerciser | |
US20080307264A1 (en) | Parameterized test driven development | |
CN100468358C (en) | Systems and methods for simulating conditions and driving control flow in software | |
CN101165658A (en) | Method and system for automatically generating unit test case of reproduced operation problem | |
CN115718685A (en) | CPU test method, device, electronic equipment and storage medium | |
CN110347590A (en) | The interface testing control method and device of operation system | |
CN113377586B (en) | Automatic detection method and device for server and storage medium | |
CN114492266B (en) | Chip verification method and device, electronic device, and storage medium | |
US9690681B1 (en) | Method and system for automatically generating executable system-level tests | |
JP7611927B2 (en) | Executing tests in a deterministic order | |
CN117556749A (en) | Chip verification method, multiplexing method and device for test cases | |
US8327309B2 (en) | Verification of design information for controlling manufacture of a system on a chip | |
US9117023B2 (en) | Dynamic generation of test segments | |
CN111813702B (en) | Debugging system, debugging method, apparatus, and computer-readable storage medium | |
CN113986263A (en) | Code automation testing method, device, electronic device, storage medium | |
US11132286B1 (en) | Dynamic reordering of test case execution | |
CN112527657B (en) | Method and equipment for automatic pile insertion in unit test | |
CN115544523A (en) | Chip boot program subsection verification method, device, equipment and readable medium | |
CN114218032A (en) | A hardware design verification method, device, electronic device and storage medium | |
JP3745968B2 (en) | Test system, test method, test program, and computer-readable recording medium recording the test program | |
CN112631904A (en) | Recording method and device of function call information | |
JP2011145880A (en) | Generation method for test task used in logic verification of semiconductor integrated circuit | |
US11989122B2 (en) | Handling mock objects that are written in the form of multiple assignment instructions | |
Sandhu | Comparison of Fault Simulation Over Custom Kernel Module Using Various Techniques |
Legal Events
Date | Code | Title | Description |
---|---|---|---|
PB01 | Publication | ||
PB01 | Publication | ||
SE01 | Entry into force of request for substantive examination | ||
SE01 | Entry into force of request for substantive examination | ||
CB02 | Change of applicant information |
Country or region after: China Address after: 410100 Hunan Province, Changsha City, East Fourth Road South Section, No. 128, Guoke Integrated Circuit Industrial Park, Building 9, 1701 Applicant after: Xinsheng Intelligent Technology (Hunan) Co.,Ltd. Address before: Room 528, No. 18 Xinya Road, Wujin National High tech Industrial Development Zone, Changzhou City, Jiangsu Province Applicant before: Jiangsu Xinsheng Intelligent Technology Co.,Ltd. Country or region before: China |