Automated test architecture for instruction set and micro-architecture of processor

Through the automated test architecture, the inefficiency of microarchitecture RTL code verification in processor design is solved, fully automated test deployment and result comparison are realized, and testing efficiency and coverage are improved. .

WO2024239815A1PCT designated stage expired Publication Date: 2024-11-28CHIPEASY TECHNOLOGY (SHANGHAI) LTD

Patent Information

Application Number
PCT/CN2024/086962
Authority / Receiving Office
WO · WO
Patent Type
Applications
Current Assignee / Owner
Priority Date
2023-05-23
Filing Date
2024-04-10
Publication Date
2024-11-28

AI Technical Summary

Technical Problem

During the processor design process, it is difficult for the existing technology to effectively verify and test the generated microarchitecture RTL code, resulting in inefficiency and 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, randomly generating input operands, and fully automatic running deployment and comparison results, solving the efficiency of manual test cases writing question.

Benefits of technology

It realizes an automated test process, improves test efficiency and coverage, can run 24*7 uninterruptedly, reduces manual intervention, and ensures the accuracy and efficiency of test results.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN2024086962_28112024_PF_FP_ABST
    Figure CN2024086962_28112024_PF_FP_ABST
Patent Text Reader

Abstract

The present invention relates to the technical field of computers. Disclosed is an automated test architecture for an instruction set and micro-architecture of a processor. The automated test architecture comprises: automatically generating CPU instruction set and micro-architecture test cases, wherein the micro-architecture test cases comprise a plurality of test cases; compiling the same test case into files executable on different CPU system architectures; and performing fully automatic operation deployment on the test cases and performing result comparison. The present invention can solve the problem of verification for an instruction set during the design of a processor.
Need to check novelty before this filing date? Find Prior Art

Description

Processor instruction set and microarchitecture automated testing architecture 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 allows users to design processors using C, including the processor instruction set architecture. The tool automatically generates the corresponding CPU RTL code for the user. After using the tool to design the corresponding instructions, the first problem users face is how to verify and test the instructions. How to ensure that the microarchitecture RTL code generated by the tool conforms to the instruction logic implemented by the user? Manually developing test cases for each instruction would be very inefficient.

[0003] Summary of the Invention

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

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

[0006] A processor instruction set and microarchitecture automated testing architecture, comprising:

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

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

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

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

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

[0012] Determining instruction operand information based on the instruction information and the microarchitecture information; the instruction operand information includes a data type of the instruction operand, a range of the instruction operand, whether the instruction operand is output or input, and whether the instruction operand is a register input or an immediate input;

[0013] Automatically generate the C function prototype of the corresponding instruction based on the instruction information, microarchitecture information and instruction operand information, and define the input and output variables required by the instruction;

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

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

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

[0017] 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.

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

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

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

[0021] Optionally, fully automated test case deployment and result comparison, including:

[0022] Develop a dedicated test scheduler xtest;

[0023] Run executable files on the x86 architecture through xtest;

[0024] Run the executable file on the target architecture through xtest;

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

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

[0027] The present invention provides a processor instruction set and micro-architecture automated testing architecture, 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 concentrates on solving the three major problems faced in automated testing: (1) Automatically generate instruction test cases: After the CPU instructions are designed, as long as the necessary information is provided, the CPU instruction set and micro-architecture related test cases can be automatically generated, without the need to manually write instruction test cases, which solves the disadvantage of traditional CPU instruction set micro-architecture testing requiring handwritten test cases and improves test efficiency. (2) Automatically deploy test case operation: With the automated testing architecture, instruction input can be randomly generated, and instruction test cases 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 test result extraction. (3) Automatically compare test results: Through the automated deployment function, the test process can be run 24 hours a day without interruption, greatly improving 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

[0028] In order to more clearly illustrate the embodiments of the present invention or the technical solutions in the prior art, the following briefly introduces the drawings required for use in the embodiments. 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 any creative work.

[0029] FIG1 is a flow chart of a processor instruction set and micro-architecture automated testing architecture provided by an embodiment of the present invention;

[0030] FIG2 is a specific flow chart of a processor instruction set and micro-architecture automated testing architecture provided by an embodiment of the present invention. DETAILED DESCRIPTION

[0031] The following will clearly and completely describe the technical solutions in the embodiments of the present invention in conjunction with the accompanying drawings. 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 making creative efforts are within the scope of protection of the present invention.

[0032] 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.

[0033] 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 for 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.

[0034] As shown in FIG1 and FIG2 , this embodiment provides a processor instruction set and micro-architecture automated testing architecture, including the following steps.

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

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

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

[0038] 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 use. 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.

[0039] After compiling, a CPU designed by FARMC will generate a .so file for each CPU. 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 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 registers, you can use code similar to the following:

[0040] farm_t*farm;

[0041] ls_t*list;

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

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

[0044] farm = create_farm();

[0045] 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.

[0046] Other information can be obtained using similar methods. The extracted information will be stored in memory in the form of arrays and corresponding structures. It can also be saved in the form of a txt file to check whether the information is accurate.

[0047] Instruction information includes: instruction name, instruction type, operand number range, 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 support is supported, and other necessary microarchitecture information.

[0048] Step 1.2: Determine the instruction operand information based on the instruction information and microarchitecture information. This instruction operand information includes the data type of the instruction operand, the range of the instruction operand, whether the instruction operand is an output or input, and whether the instruction operand is a register input or an immediate input. This instruction operand information is used to generate the C code for the instruction test case.

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

[0050] The information extracted in step 1.1 contains information about the instruction and its operands. However, this information is recorded in the form of LD (Logic Description) in a linked list corresponding to the operand information. This LD records various behaviors of the instruction or operand, such as whether the operand is input or output, the range of the operand, and so on. The entire derivation process is actually to parse the LD and extract all the information required for step 1.3 from it.

[0051] Step 1.3: Based on the instruction information, microarchitecture information, and instruction operand information, automatically generate the C function prototype of the corresponding instruction, and define the input and output variables required by the instruction.

[0052] The automatic generation process described above essentially replaces handwritten code with an automated script. With the information obtained in steps 1.1 and 1.2, we can determine the function prototype corresponding to an instruction, such as whether the instruction returns a value, how many parameters it takes, and the types of all parameters. For example, the prototype of an ADD instruction corresponding to a C function is int32_t ADD(int32_t rs1, int32_t rs2).

[0053] Step 1.4: Based on the rand() function and the instruction information, randomly generate the instruction input operands. 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() generates a 32-bit number. Because some input operands have a limited range, the value needs to be adjusted based on the operand's properties. The input operands here are the parameters of the function corresponding to this instruction. This step generates the function parameters.

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

[0055] Generate the C language code related to the instruction function call based on 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:

[0056] int rd,rs1,rs2;

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

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

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

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

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

[0062] Here, rd is the test case result. In this embodiment, a save_test_result() function is called to save the test case result to the corresponding memory.

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

[0064] Repeat step 1.5 to generate test cases for multiple instructions in a C language file. The number of instruction test cases generated depends on the size of the memory used to store the result. For example, if the size of the memory used to store the result of the ADD instruction is 4096 bytes and the result of the ADD instruction requires 4 bytes, a C language file can have 1024 ADD instruction test cases.

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

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

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

[0068] For the x86 architecture, the logic of corresponding instructions can be implemented in C. For example, FARMC (a tool developed using the C language for CPU design) directly describes instructions in C. The instruction logic is represented by a C function within FARMC, which can be directly compiled into executable code for the x86 architecture. Therefore, the FARMC descriptions of all instructions are compiled into a library file using the x86 gcc compiler. The C file generated in step 1 is then compiled into a .o file, and the library and .o files are linked. This yields the x86 implementation of all instruction behavior. Therefore, the implementation of the ADD instruction on the x86 architecture is the ADD function within FARMC. Other tools can also implement similar functionality.

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

[0070] For the target platform (such as RISC V), 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.

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

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

[0073] Step 3.1: Develop a dedicated test scheduler called xtest. xtest is an application that runs on x86 Linux. Its function is to deploy different executable files to different test carriers for execution. It can automatically run and compare the running results of test cases on different test carriers.

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

[0075] xtest creates a thread and a shared memory block using the Linux shared memory API. The newly created thread then calls fork() to create a new process. This new process then directly calls execv() to execute the test case ELF file and passes the shared memory information to the new process. The test case process can then write the test results to this shared memory block.

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

[0077] 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):

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

[0079] 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 test case execution.

[0080] 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 of the ELF file to xboot. xboot will copy the corresponding data to the correct memory location.

[0081] After all data is ready, xtest sends a run command to xboot, which then jumps to the test case execution entry point to execute the test case. Meanwhile, xtest waits until xboot sends back the test case execution result.

[0082] 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.

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

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

[0085] By following these steps, we can obtain test results for the test case on various test vehicles and compare the results across different platforms. Since all executable files are derived from the same source file, the values ​​in the memory used to store the instruction execution results must be identical after the entire code is executed. By deploying the ELF file from the target platform to the FPGA platform for execution and then comparing the results with those from the x86 platform, we can determine whether the hardware microarchitecture implementation is correct.

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

[0087] 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 disadvantage of traditional CPU instruction set microarchitecture testing requiring 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 and test result extraction. (3) Through the entire test process, the test can be run 24*7 without interruption, greatly improving the efficiency of the test.

[0088] Second, through step 2, we can ensure the high accuracy of the test. (1) By compiling the same code into executable files on different architectures, we can ensure the accuracy of the test results. We only need to ensure that there are no problems with the instruction description.

[0089] 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, thus improving the test coverage.

[0090] 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.

[0091] This document uses specific examples to illustrate the principles and implementation methods of the present invention. The above examples are only intended to help understand the method and core concept of the present invention. At the same time, those skilled in the art will find that the specific implementation methods and application scopes may vary based on the concept of the present invention. In summary, the contents of this specification should not be construed as limiting the present invention.

Claims

1. A processor instruction set and micro-architecture automated testing architecture, 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, 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, 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, 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. The processor instruction set and micro-architecture automated testing architecture according to claim 1, 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. The processor instruction set and micro-architecture automated testing architecture according to claim 1, 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.

Citation Information

Patent Citations

  • Instruction set batch testing device and method for processor

    CN102567164A

  • Simulator based automatic functional test implementation method for central processing unit instruction sets

    CN104317715A

  • A parallel automated verification method for a processor instruction set

    CN109189479A

  • Large-scale use case generation method for processor simulation verification

    CN113688046A

  • Instruction set verification method and device based on RISC-V processor

    CN115408264A

Cited By

  • Invalid instruction generation method and device, electronic equipment and storage medium

    CN119861971A

  • Random instruction sequence generation method, generator and verification system

    CN121050774A

  • Random instruction test case generation method and device

    CN122285537A

  • A random instruction test case generation method and device

    CN122285537B

  • Software and hardware collaborative verification system and method for multi-core heterogeneous SoC

    CN122572374A