Processor instruction set and micro-architecture automated test architecture

Through the automated test architecture, the processor instruction set test cases are automatically generated and deployed, which solves the inefficiency of microarchitecture RTL code verification in processor design, and realizes a fully automated test process and high coverage.

CN119025399APending Publication Date: 2024-11-26CHIPEASY TECHNOLOGY (SHANGHAI) LTD
View PDF 0 Cites 0 Cited by

Patent Information

Application Number
CN202310587687.2
Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
Filing Date
2023-05-23
Publication Date
2024-11-26

AI Technical Summary

Technical Problem

During the processor design process, it is difficult for the existing technology to efficiently verify and test the generated microarchitecture RTL code, resulting in inefficient manual development of test cases.

Method used

Provide a processor instruction set and micro-architecture automated test architecture. By automatically generating CPU instruction set and micro-architecture test cases, compiled into executable files of different CPU architectures, and realize fully automatic operation deployment and result comparison, including automatic Generate instruction operand information, randomly generate input operands, automatic deployment and comparison test results.

Benefits of technology

It improves the test efficiency and coverage during the processor design process, realizes fully automated test deployment and result extraction, and can run 24*7 uninterruptedly, solving the inefficiency problem of traditional handwritten test cases.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN119025399A_ABST
    Figure CN119025399A_ABST
Patent Text Reader

Abstract

The invention discloses a processor instruction set and micro-architecture automatic test architecture, and relates to the technical field of computers, comprising the following steps: automatically generating a CPU instruction set and a micro-architecture test case; the micro-architecture test case comprises a plurality of test cases; compiling the same test case into executable files of different CPU system architectures; and full-automatic operation deployment and result comparison of the test cases are realized. According to the invention, the instruction set verification problem in the processor design process can be solved.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present invention relates to the field of computer technology, and in particular to a processor instruction set and micro-architecture automated testing architecture. Background Art

[0002] Currently, some companies in the industry have launched tools for designing processors using high-level languages, such as FARMC. FARMC supports users to design processors using C language, including the processor instruction set architecture. The tool will automatically generate the RTL code for the corresponding CPU for the user. After the user uses the tool to design the corresponding instructions, the first problem they face is how to verify and test the instructions, and how to ensure that the micro-architecture RTL code generated by the tool conforms to the instruction logic implemented by the user. If test cases are manually developed for each instruction, the efficiency will be very low. Summary of the invention

[0003] The purpose of the present invention is to provide a processor instruction set and micro-architecture automated testing architecture, which can solve the instruction set verification problem in the processor design process.

[0004] To achieve the above object, the present invention provides the following solutions:

[0005] A processor instruction set and micro-architecture automated testing architecture, comprising:

[0006] Automatically generate CPU instruction set and micro-architecture test cases; the micro-architecture test cases include multiple test cases;

[0007] Compile the same test case into executable files for different CPU architectures;

[0008] Fully automatic test case deployment and result comparison.

[0009] Optionally, automatically generate CPU instruction set and microarchitecture test cases, including:

[0010] Extract instruction information and microarchitecture information from CPU description files;

[0011] Determine instruction operand information according to the instruction information and the microarchitecture information; the instruction operand information includes the data type of the instruction operand, the range of the instruction operand, whether the instruction operand is output or input, and whether the instruction operand is register input or immediate input;

[0012] According to the instruction information, micro-architecture information and instruction operand information, the C function prototype of the corresponding instruction is automatically generated, and the input and output variables required by the instruction are defined;

[0013] Randomly generate instruction input operands based on the rand() function and instruction information;

[0014] According to the C function prototype of the instruction, the input and output variables required by the instruction, and the input operands of the instruction, a test case rd of a complete instruction is generated, thereby forming a complete test case file set.

[0015] Optionally, it also includes calling a save_test_result() function to save the test case rd into the corresponding memory.

[0016] Optionally, the instruction information includes: instruction name, instruction type, number of instruction operands and operand range, instruction operand type, register-related information and instruction assembly statement format; the microarchitecture information includes: number of storage units, pipeline information, and whether floating point is supported.

[0017] Optionally, compile the same test case into executable files for different CPU architectures, including:

[0018] Compile the test case code into an executable file for the x86 architecture;

[0019] Compile the test case code into an executable file for the target architecture.

[0020] Optionally, test cases are fully automatically deployed and compared, including:

[0021] Develop a dedicated test scheduler xtest;

[0022] Run the executable file on the x86 architecture through xtest;

[0023] Run the executable on the target architecture through xtest;

[0024] Compare the running results of different test vectors.

[0025] According to the specific embodiments provided by the present invention, the present invention discloses the following technical effects:

[0026] The present invention provides a processor instruction set and micro-architecture automated testing framework, which is a set of CPU instruction set micro-architecture automated testing tools designed for modern CPU design tools, and is particularly suitable for scenarios such as FARMC, which use high-level languages ​​to design CPUs. The present invention can solve the instruction set verification problem in the processor design process through three steps, and centrally solves the three major problems faced in automated testing: (1) Automatically generate instruction test cases; after the CPU instruction is designed, as long as the necessary information is provided, the CPU instruction set and micro-architecture related test cases can be automatically generated, without manually writing the instruction test cases, which solves the disadvantage that the traditional CPU instruction set micro-architecture test requires handwritten test cases, and improves the test efficiency. (2) Automatically deploy the operation of test cases; with the automated test framework, the input of instructions can be randomly generated, and the test cases of instructions can also be dynamically and randomly generated, that is, through the automated deployment function, only a simple script needs to be provided to achieve fully automated test deployment and operation and test result extraction. (3) Automatically compare test results; through the automated deployment function, the 7*24-hour uninterrupted operation test process can be realized, which greatly improves the test efficiency and coverage. The present invention can be widely applied to similar scenarios in the industry, and the efficiency of CPU design verification will be greatly improved. BRIEF DESCRIPTION OF THE DRAWINGS

[0027] In order to more clearly illustrate the embodiments of the present invention or the technical solutions in the prior art, the drawings required for use in the embodiments will be briefly introduced below. Obviously, the drawings described below are only some embodiments of the present invention. For ordinary technicians in this field, other drawings can be obtained based on these drawings without paying creative labor.

[0028] Figure 1 A flowchart of a processor instruction set and micro-architecture automated testing architecture provided by an embodiment of the present invention;

[0029] Figure 2 A specific flow chart of the processor instruction set and micro-architecture automated testing architecture provided by an embodiment of the present invention. DETAILED DESCRIPTION

[0030] The following will be combined with the drawings in the embodiments of the present invention to clearly and completely describe the technical solutions in the embodiments of the present invention. Obviously, the described embodiments are only part of the embodiments of the present invention, not all of the embodiments. Based on the embodiments of the present invention, all other embodiments obtained by ordinary technicians in this field without creative work are within the scope of protection of the present invention.

[0031] In order to make the above-mentioned objects, features and advantages of the present invention more obvious and easy to understand, the present invention is further described in detail below with reference to the accompanying drawings and specific embodiments.

[0032] This embodiment provides a processor instruction set and micro-architecture automated testing architecture, including: 1. The step of automatically generating CPU instruction set and micro-architecture test cases. This step can automatically extract CPU instruction-related information from chip design EDA, and then automatically generate corresponding C language instruction set test cases based on the CPU instruction-related information. 2. The step of compiling the same C language test case into executable files for different CPU architectures. This step provides a method that can compile a C language test case of an instruction set into executable files under different computer architectures. 3. The step of fully automatic running deployment of test cases and result comparison. This step can fully automatically deploy and run instruction set micro-architecture test cases, and then determine whether the RTL corresponding to the instruction set description is correct.

[0033] like Figure 1 and Figure 2 As shown, this embodiment provides a processor instruction set and micro-architecture automated testing architecture, including the following steps.

[0034] Step 1: Automatically generate CPU instruction set and micro-architecture test cases; the micro-architecture test cases include multiple test cases.

[0035] In this embodiment, step 1 specifically includes:

[0036] Step 1.1: Extract instruction information and microarchitecture information from the CPU description file.

[0037] The CPU description file can be an XML file, a JSON file, or a binary file in a specific format. You can choose the extraction method based on the chip design EDA you are using. Here, we take the FARMC chip design language as an example to describe the extraction process. The methods for other forms of description files are similar.

[0038] After compilation, a .so file will be generated for each CPU designed by FARMC. The format of this .so file is the same as the commonly used dynamic link file, which contains all the CPU information (such as registers, instructions, opcodes, etc.). You only need to write a tool by hand to open this dynamic link file in the form of dlopen (cpu.so) to obtain the handle of the CPU information. Then, through the provided libfarm.a library, you can obtain the required CPU information through various functions for obtaining information; the libfarm.a library contains various functions for parsing this information. For example, if you need to extract the information of the CPU register, you can use code similar to the following:

[0039] farm_t*farm;

[0040] ls_t*list;

[0041] dll=dlopen(cpu.so,RTLD_LAZY);

[0042] create_farm=dlsym(dll,"farm_create");

[0043] farm = create_farm();

[0044] list = farm_get_regfile_list (farm); / / Get the linked list of all registers. The elements in the linked list are the information of a register file.

[0045] Other information can be obtained using similar methods. The extracted information will be stored in memory in the form of arrays and corresponding structures. At the same time, the extracted related information can also be saved in the form of txt files to check whether the information is accurate.

[0046] Instruction information includes: instruction name, instruction type, instruction operand number range, instruction operand type, register related information, instruction assembly statement format and other necessary information. Microarchitecture information includes: number of storage units, pipeline information, whether floating point is supported and other necessary microarchitecture information.

[0047] Step 1.2: Determine the instruction operand information according to the instruction information and micro-architecture information; the instruction operand information includes the data type of the instruction operand, the range of the instruction operand, whether the instruction operand is output or input, and whether the instruction operand is register input or immediate input. This instruction operand information is used to generate the instruction test case C code.

[0048] Taking FARMC as an example, the derivation process of instruction operand information is introduced as follows:

[0049] The information extracted in step 1.1 contains information about instructions and instruction operands, but this information is recorded in the form of LD (logic description) in a linked list of corresponding operand information. This LD records various behaviors of instructions or operands, such as whether the operand is input or output, the range of operands, etc. The entire derivation process is actually to parse LD and extract all the information required for step 1.3 from LD.

[0050] Step 1.3: According to the instruction information, micro-architecture information and instruction operand information, the C function prototype of the corresponding instruction is automatically generated, and the input and output variables required by the instruction are defined.

[0051] The above automatic generation process is actually the process of replacing handwritten code with automated scripts. With the information obtained in steps 1.1 and 1.2, we can know what the function prototype corresponding to an instruction is, such as whether this instruction has a return value, how many parameters there are, and the types of all parameters. The code is: For example, an ADD instruction corresponds to a C function prototype of int32_tADD(int32_trs1, int32_trs2).

[0052] Step 1.4: Randomly generate instruction input operands based on the rand() function and instruction information. Specifically: corresponding to rs1 and rs2 in step 1.3, the instruction input operands are randomly generated by calling the rand() function provided by the operating system and the instruction operand information extracted in step 1.1. rand() will generate a 32-bit number. Since some input operands have a limited range, the value needs to be adjusted according to the properties of the operand. The input operand here is the parameter of the function corresponding to this instruction. The function parameters are generated through this step.

[0053] Step 1.5: Generate a test case rd for a complete instruction based on the C function prototype of the instruction, the input and output variables required by the instruction, and the instruction input operands.

[0054] Generate the C language code related to the function call of the instruction through the information extracted in step 1.1 and the information derived in step 1.2; taking the ADD instruction as an example, the following ADD instruction test case code will be generated:

[0055] intrd,rs1,rs2;

[0056] rs1=12345; 12345 is randomly generated by rand().

[0057] rs2=45678; 45678 is randomly generated by rand().

[0058] rd=ADD(rs1,rs2);

[0059] save_test_result(&rd,0,4);

[0060] Step 1.6: Write the generated test cases to a file.

[0061] Here, rd is the test case result. This embodiment calls a save_test_result() function to save the test case result to the corresponding memory.

[0062] Step 1.7: Generate multiple test cases according to the specific instruction information to form a complete test case file set.

[0063] Repeat step 1.5 to generate multiple instruction test cases in a C language file. The number of instruction test cases generated is related to the size of the memory used to store the result. For example, taking the ADD instruction as an example, the size of the memory used to store the result is 4096 bytes. Since the result of the ADD instruction requires 4 bytes, a C file can have 1024 ADD instruction test cases.

[0064] Step 2: Compile the same test case into executable files for different CPU architectures.

[0065] In this embodiment, step 2 specifically includes:

[0066] Step 2.1: Compile the test case code generated in step 1 into an executable file for the x86 architecture.

[0067] For the X86 architecture, the logic of the corresponding instructions can be implemented in C language. For example, FARMC (a tool developed using C language to design CPU) directly uses C language to describe instructions. The instruction logic is a C language function in FARMC, which can be directly compiled into executable code on the X86 architecture. Therefore, the FARMC description corresponding to all instructions is compiled into a library file using x86's gcc, and then the C language file generated in step 1 is compiled into a .o file, and the library file and the .o file are linked. You can get the implementation of all instruction behaviors on X86. Therefore, the implementation of the ADD instruction on the X86 architecture is the ADD function in FARMC. Other tools can also implement similar functions.

[0068] Step 2.2: Compile the test case code generated in step 1 into an executable file for the target architecture.

[0069] For the target platform (such as riscv), the instruction function call in the C language is equivalent to executing a hard instruction. The compiler will generate a corresponding Intrinsic (equivalent to a function built into the compiler) for each hardware instruction. When compiling the test case code, the compiler will automatically use the built-in function for compilation and linking, and finally generate an executable file for the target architecture.

[0070] Step 3: Fully automatic test case deployment and result comparison.

[0071] In this embodiment, step 2 specifically includes:

[0072] Step 3.1: Develop a dedicated test scheduler xtest; xtest is an application running on x86linux. Its function is to deploy different executable files to different test carriers for running, and to realize automatic running and comparison of the running results of test cases on different test carriers.

[0073] Step 3.2: Run the executable on x86 architecture through xtest.

[0074] xtest will create a thread and create a shared memory through the Linux shared memory API. The newly created thread will make a fork() call to create a new process, which will directly call the execv() function to execute the test case ELF file and pass the created shared memory information to the new process. The test case process can then write the test results into this shared memory.

[0075] Step 3.3: Run the executable on the target architecture through xtest.

[0076] When executing the executable file of the target architecture, there are two cases. When the execution carrier is a simulator, the execution method is the same as X86. When the execution carrier is hardware (FPGA, development board):

[0077] First, there is a block of memory in the ELF file of the target architecture to store the calculation results of each instruction function in the test case. The information of this memory can be obtained by reading the ELF file information.

[0078] The bootloader xboot needs to be installed on the hardware. This bootloader can communicate with the host computer xtest through a private protocol. Based on the established protocol, xtest can read and modify the content on the hardware and obtain the status of the test case execution.

[0079] xtest will create a new thread. The function of this thread is to parse the EFL file to be executed, and then send the code segment and data segment in the ELF file to xboot. xboot will copy the corresponding data to the correct memory location.

[0080] After all data is ready, xtest will send a run command to xboot, and xboot will jump to the test case execution entry to execute the test case. At the same time, xtest will wait until xboot sends back the result of the test case execution.

[0081] After the test case is executed, the execution result will be notified to xboot through the exit() system call, and xboot will forward the test result to xtest.

[0082] After xtest gets the result, if the test case runs successfully, it will send a command to read the memory to read the contents of the memory area where the test results are stored.

[0083] Step 3.4: Compare the running results of different test vectors.

[0084] Through the above steps, we can get the test results of the test cases on various test carriers and compare the results of running on different platforms. Since the executable files are all from the same source file, the values ​​in the memory used to store the instruction execution results must be the same after the entire code is executed. By deploying the ELF file on the target platform to the FPGA platform for execution, and then comparing it with the results running on x86, we can determine whether the implementation of the hardware microarchitecture is correct.

[0085] Compared with the prior art, the present invention has the following advantages:

[0086] First, the present invention can bring about a highly efficient test process through steps 1, 2, and 3, and the test process is fully automated. (1) By extracting CPU instruction information and randomly generating test case functions, the shortcoming of traditional CPU instruction set microarchitecture testing that requires handwritten test cases is solved. The new method can automatically generate test cases, thereby improving the efficiency of the test. (2) Through the automated deployment function, only a simple script needs to be provided to achieve fully automated test deployment and operation as well as test result extraction. (3) Through the entire test process, the test can run uninterruptedly 24*7, greatly improving the efficiency of the test.

[0087] Second, through step 2, the high accuracy of the test is ensured. (1) By compiling the same code into executable files on different architectures, the accuracy of the test result judgment is ensured. It only needs to ensure that there are no problems with the instruction description.

[0088] Third, through step 2, the test coverage can be greatly improved. (1) All test inputs are randomly generated, which improves the test scenario coverage. (2) The entire solution can be deployed and run around the clock without manual intervention. As long as time permits, it can cover various edge cases, improving the test coverage.

[0089] The various embodiments in this specification are described in a progressive manner, and each embodiment focuses on the differences from other embodiments. The same or similar parts between the various embodiments can be referenced to each other.

[0090] The principles and implementation methods of the present invention are described in this article using specific examples. The description of the above embodiments is only used to help understand the method and core idea of ​​the present invention. At the same time, for those skilled in the art, according to the idea of ​​the present invention, there will be changes in the specific implementation methods and application scope. In summary, the content of this specification should not be understood as limiting the present invention.

Claims

1. A processor instruction set and microarchitecture automated testing architecture, It is characterized in that include: Automatically generate CPU instruction set and micro-architecture test cases; The micro-architecture test case includes a plurality of test cases; Compile the same test case into executable files for different CPU architectures; Fully automatic test case deployment and result comparison.

2. A processor instruction set and micro-architecture automated testing architecture according to claim 1, It is characterized in that Automatically generate CPU instruction set and microarchitecture test cases, including: Extract instruction information and microarchitecture information from CPU description files; Determine instruction operand information according to the instruction information and the microarchitecture information; the instruction operand information includes the data type of the instruction operand, the range of the instruction operand, whether the instruction operand is output or input, and whether the instruction operand is register input or immediate input; According to the instruction information, micro-architecture information and instruction operand information, the C function prototype of the corresponding instruction is automatically generated, and the input and output variables required by the instruction are defined; Randomly generate instruction input operands based on the rand() function and instruction information; According to the C function prototype of the instruction, the input and output variables required by the instruction, and the input operands of the instruction, a test case rd of a complete instruction is generated, thereby forming a complete test case file set.

3. A processor instruction set and micro-architecture automated testing architecture according to claim 2, It is characterized in that It also includes calling a save_test_result() function to save the test case rd into the corresponding memory.

4. A processor instruction set and micro-architecture automated testing architecture according to claim 2, It is characterized in that The instruction information includes: instruction name, instruction type, number of instruction operands and operand range, instruction operand type, register related information and instruction assembly statement format; the microarchitecture information includes: number of storage units, pipeline information, and whether floating point is supported.

5. A processor instruction set and micro-architecture automated testing architecture according to claim 1, It is characterized in that Compile the same test case into executable files for different CPU architectures, including: Compile the test case code into an executable file for the x86 architecture; Compile the test case code into an executable file for the target architecture.

6. A processor instruction set and micro-architecture automated testing architecture according to claim 1, It is characterized in that Fully automatic test case deployment and result comparison, including: Develop a dedicated test scheduler xtest; Run the executable file on the x86 architecture through xtest; Run the executable on the target architecture through xtest; Compare the running results of different test vectors.