A method and system for NVMe model construction and testing
By constructing and testing NVMe models using macro definitions and step-by-step compilation, the problems of low scalability and collaboration efficiency of existing platforms are solved, enabling efficient simulation testing and rapid development.
Patent Information
- Application Number
- CN202310091743.3
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2023-02-03
- Publication Date
- 2026-01-30
- Estimated Expiration
- 2043-02-03
AI Technical Summary
Existing NVMe model building and testing platforms lack scalability, making it difficult to quickly integrate collaborative code from multiple users, and are not convenient enough for verifying design response times in special scenarios.
Functional instructions are defined using macros. Through step-by-step compilation and simulation testing, combined with ifdef statements for conditional constraints, the NVMe model is constructed and tested.
It improves the scalability and multi-user collaboration capabilities of the testing platform, simplifies code modification and bug fixing testing, enhances simulation testing efficiency, and shortens the development cycle.
Smart Images

Figure CN116302967B_ABST
Abstract
Description
Technical Field
[0001] This invention relates to the field of instruction program testing, and in particular to a method for constructing and testing an NVMe model. Background Technology
[0002] Because of the numerous types of NVMe commands and the strict adherence to the NVMe protocol, the entire NVMe model requires a lengthy development cycle. The NVMe model runs within the NVMe controller to execute corresponding NVMe operations according to the NVMe protocol. Before using the NVMe model in the NVMe controller, it needs to be built and tested. During testing, the NVMe model runs on a test platform to generate stimuli for the DUT (Device Under Test). By observing the DUT's response to these stimuli, the correctness of the NVMe operations is determined, thus testing the correctness of the NVMe model.
[0003] However, in practical applications, as engineers gain a deeper understanding of the protocol, the command processing and command generation parts may be frequently modified. Furthermore, with upgrades to the NVMe protocol and changes in product functionality, new NVMe commands may be added. This necessitates a highly scalable testing platform to facilitate the modification and addition of commands to the NVMe model. The significant workload means that multiple engineers will collaborate on writing this NVMe model, requiring the testing platform to have the ability to quickly and efficiently integrate code. Additionally, in certain use cases, it needs to be able to easily verify whether the design (DUT) produces the expected response through bug-completion tests.
[0004] In summary, how to enable a testing platform to simultaneously possess the following three characteristics is a technical problem that urgently needs to be solved in this field:
[0005] 1. This makes the testing environment of the testing platform more scalable;
[0006] 2. Makes it easier to merge the verification environment of the testing platform, facilitating collaboration among multiple people;
[0007] 3. Enables the testing platform to make special modifications to the environment code during testing. Summary of the Invention
[0008] To address the aforementioned technical problems, in one aspect of this invention, an NVMe model construction and testing method is proposed. The method includes the following steps implemented by an NVMe model construction and testing platform: defining functional instructions, wherein the defined functional instructions are program shells; issuing writing tasks for the functional instructions and receiving the returned logic code corresponding to the functional instructions; constructing an NVMe model based on the defined functional instructions; performing step-by-step compilation of the NVMe model; and performing simulation testing on the NVMe model.
[0009] In one or more embodiments, defining functional instructions includes defining functional instructions through macro definitions. The functional instructions include: management instructions specified in the NVMe protocol; response instructions corresponding to the management instructions; and custom instructions conforming to the NVMe protocol.
[0010] In one or more embodiments, issuing a task to write the function instruction and receiving the returned logic code corresponding to the function instruction includes: issuing a file containing the macro definition name of the function instruction to the corresponding client and binding it with the client's login account; and saving the file containing the logic code corresponding to the function instruction returned by the client to a public compilation folder.
[0011] In one or more embodiments, constructing an NVMe model based on the defined functional instructions includes: constructing an NVMe model based on macro definitions of the functional instructions and logic code for other functions besides the functional instructions.
[0012] In one or more embodiments, the step-by-step compilation of the NVMe model includes compiling the NVMe model step-by-step according to a preset compilation layer, the preset compilation layer including: a first layer, compiling the program shell of the macro definition; a second layer, compiling the NVMe model; a third layer, compiling the files in the public compilation folder; and a fourth layer, compiling externally injected test files, wherein the test files are used to conditionally constrain the execution of the logic code under the macro definition through ifdef statements.
[0013] In one or more embodiments, the NVMe model construction and testing method of the present invention further includes: after constructing the NVMe model based on the functional instructions, executing the compilation of the first layer and the second layer in sequence to ensure that the defined functional instructions correspond one-to-one with the functional instructions in the NVMe model, and the compilation correctness of the NVMe model.
[0014] In one or more embodiments, an NVMe model construction and testing method of the present invention further includes: before performing simulation testing on the NVMe model, sequentially executing the compilation in the third layer and the fourth layer to replace the logic code in the macro definition with the latest logic code.
[0015] In one or more embodiments, an NVMe model building and testing method of the present invention further includes: when it is necessary to modify the corresponding functional instructions, resending a file containing the modified logic code corresponding to the functional instructions to the NVMe model building and testing platform; and replacing the original file with the same macro definition name in the public compilation folder; wherein, modifying the corresponding functional instructions includes: modifying the original logic code or expanding the new logic code.
[0016] In one or more embodiments, an NVMe model building and testing method of the present invention further includes: when error injection testing is required, sending error logic code containing corresponding functional instructions to the NVMe model building and testing platform by using a test file with a corresponding macro definition name; and imposing conditional constraints on the execution of the error logic code by using an ifdef statement.
[0017] In a second aspect of the invention, an NVMe model building and testing system is proposed, comprising: an NVMe model building and testing platform; one or more external devices; and a design under test; wherein the one or more external devices and the design under test are respectively communicatively connected to the NVMe model building and testing platform; the NVMe model building and testing platform is configured to implement the steps of an NVMe model building and testing method as described in any of the above embodiments, including: defining functional instructions, wherein the defined functional instructions are program shells; issuing writing tasks for the functional instructions and receiving returned logic code corresponding to the functional instructions; building an NVMe model based on the defined functional instructions; performing step-by-step compilation of the NVMe model; and performing simulation testing on the NVMe model.
[0018] In one or more embodiments, defining functional instructions includes defining functional instructions through macro definitions. The functional instructions include: management instructions specified in the NVMe protocol; response instructions corresponding to the management instructions; and custom instructions conforming to the NVMe protocol.
[0019] In one or more embodiments, issuing a task to write the function instruction and receiving the returned logic code corresponding to the function instruction includes: issuing a file containing the macro definition name of the function instruction to the corresponding client and binding it with the client's login account; and saving the file containing the logic code corresponding to the function instruction returned by the client to a public compilation folder.
[0020] In one or more embodiments, constructing an NVMe model based on the defined functional instructions includes: constructing an NVMe model based on macro definitions of the functional instructions and logic code for other functions besides the functional instructions.
[0021] In one or more embodiments, the step-by-step compilation of the NVMe model includes compiling the NVMe model step-by-step according to a preset compilation layer, the preset compilation layer including: a first layer, compiling the program shell of the macro definition; a second layer, compiling the NVMe model; a third layer, compiling the files in the public compilation folder; and a fourth layer, compiling externally injected test files, wherein the test files are used to conditionally constrain the execution of the logic code under the macro definition through ifdef statements.
[0022] In one or more embodiments, the NVMe model construction and testing method of the present invention further includes: after constructing the NVMe model based on the functional instructions, executing the compilation of the first layer and the second layer in sequence to ensure that the defined functional instructions correspond one-to-one with the functional instructions in the NVMe model, and the compilation correctness of the NVMe model.
[0023] In one or more embodiments, an NVMe model construction and testing method of the present invention further includes: before performing simulation testing on the NVMe model, sequentially executing the compilation in the third layer and the fourth layer to replace the logic code in the macro definition with the latest logic code.
[0024] In one or more embodiments, an NVMe model building and testing method of the present invention further includes: when it is necessary to modify the corresponding functional instructions, resending a file containing the modified logic code corresponding to the functional instructions to the NVMe model building and testing platform; and replacing the original file with the same macro definition name in the public compilation folder; wherein, modifying the corresponding functional instructions includes: modifying the original logic code or expanding the new logic code.
[0025] In one or more embodiments, an NVMe model building and testing method of the present invention further includes: when error injection testing is required, sending error logic code containing corresponding functional instructions to the NVMe model building and testing platform by using a test file with a corresponding macro definition name; and imposing conditional constraints on the execution of the error logic code by using an ifdef statement.
[0026] The beneficial effects of the present invention include: by utilizing the characteristic that macro definitions can be repeatedly compiled and the final compilation result is taken as the standard, combined with step-by-step compilation, the test environment of the test platform can have stronger scalability, easier merging, facilitate multi-person collaboration, and facilitate test debugging, and can improve simulation test efficiency and shorten the development cycle of NVMe models. Attached Figure Description
[0027] To more clearly illustrate the technical solutions in the embodiments of the present invention or the prior art, the drawings used in the description of the embodiments or the prior art will be briefly introduced below. Obviously, the drawings described below are only some embodiments of the present invention. For those skilled in the art, other embodiments can be obtained based on these drawings without creative effort.
[0028] Figure 1 This is a flowchart illustrating the workflow of an NVMe model construction and testing method according to the present invention.
[0029] Figure 2 This is a schematic diagram of the SSD controller chip of the present invention;
[0030] Figure 3 This is a schematic diagram of the structure of an NVMe model construction and testing system according to the present invention. Detailed Implementation
[0031] To make the objectives, technical solutions, and advantages of the present invention clearer, the embodiments of the present invention will be further described in detail below with reference to specific examples and the accompanying drawings.
[0032] It should be noted that all uses of "first" and "second" in the embodiments of the present invention are for the purpose of distinguishing two entities or parameters with the same name but different names. It is clear that "first" and "second" are only for the convenience of expression and should not be construed as limiting the embodiments of the present invention. Subsequent embodiments will not explain this in detail.
[0033] Figure 1 This is a flowchart illustrating the workflow of an NVMe model construction and testing method according to the present invention. Figure 1 As shown, the workflow of an NVMe model construction and testing method of the present invention includes: Step S1, the following steps implemented by the NVMe model construction and testing platform: Step S2, defining functional instructions, wherein the defined functional instructions are program shells; Step S3, issuing the writing task for the functional instructions and receiving the returned logic code of the corresponding functional instructions; Step S4, constructing an NVMe model based on the defined functional instructions; Step S5, performing step-by-step compilation of the NVMe model; and Step S6, performing simulation testing on the NVMe model.
[0034] Specifically, to provide a test environment for a test platform with stronger scalability, easier merging, convenient multi-person collaboration, and convenient test debugging, the first aspect of this invention proposes an NVMe model construction and testing method. Those skilled in the art will understand that this NVMe model construction and testing method describes the test environment of the test platform, or the specific operations that the test environment can perform. In this embodiment, the invention divides the construction of the NVMe model into several steps, including: defining functional instructions, i.e., determining the functional instructions required by the NVMe model in this invention, and determining which functional instructions should be defined as program shells in advance by distinguishing the difficulty of writing the functional instructions and considering the possibility of future modifications, to facilitate later modifications; wherein, a program shell is an empty shell containing only the name of the functional instruction without specific logic code. After defining the functional instructions, it is necessary to assign writing tasks for those instructions, which is the most labor-intensive part, requiring collaboration from multiple engineers. Each engineer only needs to complete the writing of the corresponding instruction function according to the assigned writing task, without needing to care about its logical relationship in the NVMe model, and then send the written logic code to the test platform. The test platform pre-stores NVMe models built based on defined functional instructions. After the NVMe model is compiled step by step, the compiled intermediate files are obtained. Then, the test program of the NVMe model can be generated by recombining the compiled intermediate files through the Elaboration operation.
[0035] As described in the above embodiments, the NVMe model construction and testing method of the present invention enables the testing platform to have stronger scalability, easier merging, facilitate multi-person collaboration, and facilitate test annotation capabilities. This significantly improves the efficiency of NVMe model construction and testing, and shortens the NVMe model development cycle.
[0036] In one embodiment, the specific method for defining function instructions in step S1 includes defining function instructions through macro definitions. Function instructions include: management instructions specified in the NVMe protocol; response instructions corresponding to management instructions; and custom instructions that conform to the NVMe protocol.
[0037] Specifically, the NVMe protocol specifies 22 management commands, some of which have dozens of sub-branches, each requiring different command processing by the local CPU (NVMe controller), and resulting in different completion responses. In addition to the commands specified in the protocol, developers can also define dozens of other custom management commands.
[0038] Figure 2 This is a schematic diagram of the SSD controller chip of the present invention. Figure 2 As shown, most commands sent by the host computer are passed to the local CPU via the NVMC module for processing, in order to execute the corresponding instruction processes. The completion responses will also vary. After receiving these commands, the local CPU model will... Figure 2 The cmd process module shown performs special handling of some commands according to the NVMe protocol and may invoke... Figure 2 The other logic module section. After the command is completed, the completion generate module sends out the data that needs to be transmitted. The NVMe model in this invention is the instruction model running on the aforementioned local CPU.
[0039] In this embodiment, the present invention utilizes the characteristics of macro definitions, which are essentially text replacements and can be repeatedly compiled, with the final effect determined by the last compilation. Combined with subsequent step-by-step compilation, this can greatly reduce the number of files that need to be compiled before simulation testing, thereby significantly improving the efficiency of simulation testing.
[0040] In one embodiment, issuing a task to write functional instructions and receiving the returned logic code of the corresponding functional instructions includes: sending a file containing the macro definition name of the functional instructions to the corresponding client and binding it with the client's login account; and saving the file containing the logic code of the corresponding functional instructions returned by the client to a public compilation folder.
[0041] In this embodiment, the issued writing task can be a file containing only macro definition names of function instructions. In another optional embodiment, the issued compilation task file may also contain usable environment variables and special requirements for function writing, such as whether a response instruction needs to be written. Binding the writing task to the client's login account serves two purposes: firstly, it helps determine which client uploaded the task file caused the error when compilation errors occur later; secondly, it prevents other users from accidentally uploading task files and thus unintentionally modifying task files uploaded by other accounts by setting upload permissions.
[0042] In one embodiment, constructing an NVMe model based on defined functional instructions includes: constructing the NVMe model based on macro definitions of the functional instructions and logic code for other functions besides the functional instructions. These other functions include the corresponding functions of data transfer instructions.
[0043] In one embodiment, step-by-step compilation of the NVMe model includes compiling the NVMe model step-by-step according to a preset compilation layer, which includes: a first layer for compiling the program shell of macro definitions; a second layer for compiling the NVMe model; a third layer for compiling the files in the common compilation folder; and a fourth layer for compiling externally injected test files, wherein the test files are used to conditionally constrain the execution of the logic code under the macro definitions through ifdef statements.
[0044] Specifically, after constructing the NVMe model based on functional instructions, the compilation of the first and second layers is executed sequentially to ensure that the defined functional instructions correspond one-to-one with the functional instructions in the NVMe model, and to ensure the correctness of the NVMe model compilation. Before performing simulation testing on the NVMe model, the compilation of the third and fourth layers is executed sequentially to replace the logic code in the macro definitions with the latest logic code.
[0045] As described in the above embodiments, by combining the feature that macro definitions can be repeatedly compiled and the last compilation is the standard, with step-by-step compilation, the present invention can realize that only the compilation of the third and fourth layers needs to be performed before simulation testing, thereby greatly reducing the number of files that need to be compiled. In the simulation testing process that requires repeated modification of instructions, the efficiency of simulation testing can be greatly improved.
[0046] In one embodiment, the NVMe model building and testing method of the present invention further includes: when it is necessary to modify the corresponding functional instructions, resending the file containing the modified logic code of the corresponding functional instructions to the NVMe model building and testing platform; and replacing the original file with the same macro definition name in the public compilation folder; wherein, modifying the corresponding functional instructions includes: modifying the original logic code or expanding the new logic code.
[0047] In an optional embodiment, some custom function instructions can be predefined and compiled into the NVMe model during the construction process. If these custom function instructions are still empty programs before testing, they can be disabled by adding conditional restrictions to these custom function instructions in the test file and then enabled after the logic code of the function instructions is tampered with or added.
[0048] In one embodiment, the present invention further includes: when error injection testing is required, sending error logic code containing corresponding functional instructions to the NVMe model building and testing platform using a test file with corresponding macro definition names; and conditionally constraining the execution of the error logic code using ifdef statements. It can be understood that the "error logic code" is intentionally injected error-injected logic code.
[0049] As can be seen from the above embodiments, the error injection process of the present invention is more convenient. It only requires the use of deliberately erroneous logic code to replace the logic code with the same macro definition name through compilation. Furthermore, the execution of the erroneous logic code can be controlled by conditional constraints.
[0050] In a second aspect of the invention, an NVMe model building and testing system is proposed. Figure 3 This is a schematic diagram of the structure of an NVMe model construction and testing system according to the present invention. Figure 3 As shown, the NVMe model building and testing system of the present invention includes: an NVMe model building and testing platform 100; one or more external devices 200; and a design under test 300; wherein the one or more external devices 200 and the design under test 300 are respectively communicatively connected to the NVMe model building and testing platform 100; the NVMe model building and testing platform 100 is configured to implement the steps in an NVMe model building and testing method as described in any of the above embodiments, including: defining functional instructions, wherein the defined functional instructions are program shells; issuing writing tasks for the functional instructions and receiving the returned logical code of the corresponding functional instructions; building an NVMe model based on the defined functional instructions; performing step-by-step compilation of the NVMe model; and performing simulation testing on the NVMe model.
[0051] In one or more embodiments, defining functional instructions includes defining functional instructions through macro definitions. Functional instructions include: management instructions specified in the NVMe protocol; response instructions corresponding to management instructions; and custom instructions conforming to the NVMe protocol.
[0052] In one or more embodiments, issuing a task to write function instructions and receiving the returned logic code of the corresponding function instructions includes: sending a file containing the macro definition name of the function instructions to the corresponding client and binding it with the client's login account; and saving the file containing the logic code of the corresponding function instructions returned by the client to a public compilation folder.
[0053] In one embodiment, building an NVMe model based on defined functional instructions includes: building an NVMe model based on macro definitions of functional instructions and logic code for other functions besides functional instructions.
[0054] In one embodiment, step-by-step compilation of the NVMe model includes compiling the NVMe model step-by-step according to a preset compilation layer, which includes: a first layer for compiling the program shell of macro definitions; a second layer for compiling the NVMe model; a third layer for compiling the files in the common compilation folder; and a fourth layer for compiling externally injected test files, wherein the test files are used to conditionally constrain the execution of the logic code under the macro definitions through ifdef statements.
[0055] In one embodiment, the NVMe model construction and testing method of the present invention further includes: after constructing the NVMe model based on functional instructions, executing the compilation of the first layer and the second layer in sequence to ensure that the defined functional instructions correspond one-to-one with the functional instructions in the NVMe model, and the compilation correctness of the NVMe model.
[0056] In one embodiment, the NVMe model construction and testing method of the present invention further includes: before performing simulation testing on the NVMe model, executing the compilation in the third and fourth layers in sequence to replace the logic code in the macro definition with the latest logic code.
[0057] In one embodiment, the NVMe model building and testing method of the present invention further includes: when it is necessary to modify the corresponding functional instructions, resending the file containing the modified logic code of the corresponding functional instructions to the NVMe model building and testing platform; and replacing the original file with the same macro definition name in the public compilation folder; wherein, modifying the corresponding functional instructions includes: modifying the original logic code or expanding the new logic code.
[0058] In one embodiment, an NVMe model building and testing method of the present invention further includes: when error injection testing is required, sending error logic code containing corresponding functional instructions to the NVMe model building and testing platform by using a test file with a corresponding macro definition name; and imposing conditional constraints on the execution of the error logic code by using an ifdef statement.
[0059] The above are exemplary embodiments disclosed in this invention. However, it should be noted that various changes and modifications can be made without departing from the scope of the embodiments of this invention as defined by the claims. The functions, steps, and / or actions of the methods according to the disclosed embodiments described herein do not need to be performed in any particular order. Furthermore, although the elements disclosed in the embodiments of this invention may be described or claimed individually, they may be understood as multiple unless explicitly limited to a singular number.
[0060] It should be understood that, as used herein, the singular form “a” is intended to include the plural form as well, unless the context clearly supports an exception. It should also be understood that, as used herein, “and / or” refers to any and all possible combinations of one or more of the associated listed items.
[0061] The embodiment numbers disclosed in the above embodiments of the present invention are merely for description and do not represent the superiority or inferiority of the embodiments.
[0062] Those skilled in the art should understand that the discussion of any of the above embodiments is merely exemplary and is not intended to imply that the scope of the invention (including the claims) is limited to these examples. Within the framework of the invention, technical features of the above embodiments or different embodiments can be combined, and many other variations of different aspects of the invention exist, which are not provided in the details for the sake of brevity. Therefore, any omissions, modifications, equivalent substitutions, improvements, etc., made within the spirit and principles of the invention should be included within the protection scope of the invention.
Claims
1. A method for NVMe model building and testing, the method comprising: The method comprises the following steps implemented by the NVMe model construction and testing platform: Defining a function instruction by means of macro definition, and the defined function instruction is a program shell; Issuing a writing task for the function instruction, and receiving returned logic code corresponding to the function instruction, including issuing a file containing a macro definition name of the function instruction to a corresponding client and binding with a login account of the client; saving a file returned by the client and containing logic code corresponding to the function instruction to a public compilation folder; Constructing an NVMe model based on the defined function instruction, including constructing the NVMe model based on the macro definition of the function instruction and logic code of other functions other than the function instruction; Step-by-step compiling the NVMe model, including step-by-step compiling the NVMe model according to a preset compilation layer, and the preset compilation layer includes: a first layer, compiling the program shell of the macro definition; a second layer, compiling the NVMe model; a third layer, compiling files in the public compilation folder; and a fourth layer, compiling an externally injected test file, wherein the test file is used to conditionally restrict execution of the logic code under the macro definition through an ifdef statement; Simulating and testing the NVMe model; The method further comprises: after constructing the NVMe model based on the function instruction, sequentially executing the compilation in the first layer and the second layer to ensure that the defined function instruction corresponds to the function instruction in the NVMe model one by one and the compilation correctness of the NVMe model; Before simulating and testing the NVMe model, sequentially executing the compilation in the third layer and the fourth layer to replace the logic code in the macro definition with the latest logic code.
2. The method of claim 1, wherein, The function instruction includes: A management class instruction specified in the NVMe protocol; A reply instruction corresponding to the management class instruction; and A self-defined instruction conforming to the NVMe protocol. 3.The NVMe model building and testing method of claim 1, wherein, The method further comprises: When a corresponding function instruction needs to be modified, sending a file containing modified logic code corresponding to the function instruction to the NVMe model construction and testing platform again; and Replacing an original file with the same macro definition name in the public compilation folder; Wherein, the modification of the corresponding function instruction includes: modifying the original logic code or expanding new logic code.
4. The method of claim 1, wherein, The method further comprises: When error injection testing is needed, sending a test file with a corresponding macro definition name to the NVMe model construction and testing platform to send error logic code corresponding to the function instruction; and Conditionally restricting execution of the error logic code through an ifdef statement.
5. A system for NVMe model building and testing, the system comprising: It includes: An NVMe model construction and testing platform; One or more external devices; And A design under test; wherein the one or more external devices and the design under test are respectively in communication connection with the NVMe model construction and testing platform; The NVMe model construction and testing platform is configured to implement the steps of the NVMe model construction and testing method according to any one of claims 1-4.
Citation Information
Patent Citations
An embedded software debugging method
CN109144849A