Method for reusing coverage collection code, and computer readable medium
By creating coverage warehouse base class and coverage warehouse class, using parameterized classes and factory mechanisms, the reuse of coverage collection code is solved, and the problem of redundancy and maintenance difficulties in chip verification of different performances is improved, and development efficiency and maintainability are improved.
Patent Information
- Application Number
- CN202210085224.1
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2022-01-25
- Publication Date
- 2025-03-18
- Estimated Expiration
- 2042-01-25
AI Technical Summary
In the prior art, when verifying the same type of chip with different performances, multiple sets of almost the same coverage collection codes need to be maintained, resulting in difficulty in code duplication and maintenance.
By creating coverage warehouse base class and coverage warehouse class, using parameterized classes and factory mechanisms, the coverage collection code is reused, and the coverage collection feature that is no longer supported is dynamically ignored.
It realizes the reuse of the coverage collection code, reduces code redundancy and maintenance difficulty, and improves development efficiency and maintainability.
Smart Images

Figure CN114443027B_ABST
Abstract
Description
Technical Field
[0001] The present invention relates to the field of chip verification technology, and in particular to a coverage collection code reuse method and a computer-readable medium. Background Art
[0002] like Figure 1 The figure shows an example diagram after abstracting the functional logic of a chip.
[0003] The signals of each port are as follows:
[0004] op: operation instructions, including addition ADD, subtraction SUB, multiplication MUL, and division DIV operations;
[0005] A: Operand operation, use register group to operate and store operands; B: Operand operation, use register group to operate and store operands; rslt: Operation result, use register group to operate and store the result.
[0006] Usually, in order to meet different market needs, different product strategies are formulated and corresponding product planning is carried out to plan a variety of chips of the same type with different performance. The performance parameters supported by the chip can be abstracted as follows:
[0007] support_mode: supported working modes, including HIGH_MODE, MEDIUM_MODE, and LOW_MODE. The higher the performance, the more modes it supports;
[0008] support_op: supported operation instructions, including ADD, SUB, MUL, DIV. The higher the performance, the more types of operation instructions it supports, which depends on the supported working mode support_mode;
[0009] support_reg: Supported register group, including registers R0~R7. The higher the performance, the more registers are used for the operands and results of the operation instructions, and the faster the operation speed is. This also depends on the supported working mode support_mode.
[0010] Then simply abstract its operation instructions and represent them with enumeration variables in the verification platform. Specifically:
[0011] mode: working mode;
[0012] op: operation instruction;
[0013] A_reg: register group used by operand A;
[0014] B_reg: register group used by operand B;
[0015] rslt_reg: The register group used by the operation result rslt.
[0016] Usually, it is necessary to write a coverage component coverage to collect coverage statistics for some important coverage points of the chip. This component obtains transaction data monitored by the monitor. It can be implemented through the subscriber mode or through the TLM communication port connection.
[0017] The coverage components generally include at least:
[0018] mode: collects coverage to the supported working modes;
[0019] op: collects and covers the supported operation instructions;
[0020] A_reg: collects the register group used by the covered operation operand A;
[0021] B_reg: collects the register group used by the covered operation operand B;
[0022] rslt_reg: collects the register group used by the covered operation result rslt.
[0023] Some cross-coverage points, such as the register group used by the operation instructions and the operation operand A, and other corner coverage points.
[0024] As mentioned above, in order to meet different market needs, different product strategies will be formulated and corresponding product planning will be carried out to plan out a variety of chips of the same type with different performance. Therefore, in order to verify a variety of chips of the same type with different performance, it may be necessary to maintain multiple sets of coverage collection code. For example, the same type of chip planned for the mid-to-low-end market no longer supports the HIGH_MODE working mode. At this time, the chip no longer supports the multiplication MUL and division DIV operation instructions. At the same time, the chip's operation speed will also be reduced. That is, at this time, its operation operands and operation results can no longer use all register groups R0~R7, but can only use register groups R0~R3. Then it is necessary to rewrite the above coverage collection code coverage and add some ignore_bins to ignore the coverage collection of some performance characteristics that are no longer supported.
[0025] Although only some ignore_bins need to be added, the previous coverage collection code needs to be completely copied. Similarly, if there are other chips of the same performance, there will be a lot of duplicate code. In this case, multiple sets of almost identical coverage collection codes need to be maintained at the same time. In addition, if modifications are needed later, multiple places may need to be modified simultaneously, which is troublesome and prone to omissions and errors. Summary of the invention
[0026] According to an embodiment of the present invention, a method for reusing coverage collection code is provided, comprising the following steps:
[0027] Create a base class for overlay warehouse;
[0028] As needed, the coverage warehouse base class derives the coverage warehouse subclass, the coverage warehouse subclass collects the coverage characteristics that need to be ignored, and overloads the static method of the coverage warehouse base class;
[0029] Create a coverage collection component base class for code overloading;
[0030] The coverage collection component base class is derived into a parameterized class, and the parameter of the parameterized class is the coverage bin subclass;
[0031] Pass the coverage bin class as a parameter into the above parameterized class to obtain the coverage collection parameter class;
[0032] Declare and instantiate the coverage collection component base class, and replace the coverage collection component base class with the coverage collection parameter class through code overloading.
[0033] Preferably, in the initial state, there is no coverage collection that needs to be ignored in the coverage bin base class.
[0034] Preferably, the functions in the overlay bin base class and the overlay bin subclass are provided for static calling.
[0035] Preferably, functions in the coverage warehouse base class and coverage warehouse subclass are statically called through the static keyword.
[0036] Preferably, deprecated coverage code that needs to be ignored is derived from the coverage bin base class.
[0037] Preferably, a factory mechanism is used for code reloading.
[0038] According to yet another embodiment of the present invention, a computer-readable medium having a non-volatile program code executable by a processor is provided, wherein the program code enables the processor to execute any one of the above coverage collection code reuse methods.
[0039] According to the coverage collection code reuse method and computer-readable medium of the embodiments of the present invention, coverage code reuse is achieved by passing the coverage collection characteristics that need to be ignored into a parameterized class; at the same time, the coverage bins ignore_bins that the target needs to ignore are obtained by calling the static method of the coverage bin subclass.
[0040] It is to be understood that both the foregoing general description and the following detailed description are exemplary, and are intended to provide further explanation of the technology as claimed. BRIEF DESCRIPTION OF THE DRAWINGS
[0041] Figure 1 This is an example diagram of the abstraction of chip function logic in the prior art;
[0042] Figure 2 A flowchart of a method for reusing coverage collection code according to an embodiment of the present invention;
[0043] Figure 3 Based on Figure 2 Schematic diagram of the method principle. DETAILED DESCRIPTION
[0044] The preferred embodiments of the present invention will be described in detail below in conjunction with the accompanying drawings to further illustrate the present invention.
[0045] First, combine Figure 2~3 A coverage collection code reuse method according to an embodiment of the present invention is described, which is used for chip verification of different performances and different modes and has a wide range of application scenarios.
[0046] like Figure 2~3 As shown, the method for reusing coverage collection code according to an embodiment of the present invention comprises the following steps:
[0047] Specifically, Figure 2~3 As shown, in step S1, a bin base class cg_ignore_bins_default is created. In this embodiment, the function of the bin base class is added with the keyword static to facilitate static calling through the :: symbol in subsequent steps.
[0048] Furthermore, in the initial state, there is no ignore_bins, that is, there is no coverage collection of some performance features that are no longer supported and need to be ignored.
[0049] Specifically, Figure 2~3As shown, in step S2, according to the actual project needs, the coverage bin base class cg_ignore_bins_default is derived to derive the coverage bin subclass subclass_cg_ignore_bins_default, the coverage bin subclass is the coverage collection feature that needs to be ignored, and overloads the static method of the coverage bin base class; in this embodiment, the function of the coverage bin subclass also needs to be added with the static keyword to facilitate the subsequent static call through the :: symbol.
[0050] Specifically, Figure 2~3 As shown, in step S3, a coverage collection component base class coverage_base is created for code reloading. In this embodiment, a factory mechanism is used for code reloading.
[0051] Specifically, Figure 2~3 As shown, in step S4, the coverage collection component base class coverage_base is derived to be a parameterized class, and the parameter of the parameterized class is the coverage bin subclass.
[0052] Specifically, Figure 2~3 As shown, in step S5, the coverage bin subclass subclass_cg_ignore_bins_default is passed as a parameter to the parameterized class, so that the coverage collection object coverage of the coverage collection component base class coverage_base ignores the coverage code that needs to be ignored and is no longer supported, and generates a coverage collection parameter class. In this embodiment, the coverage code that needs to be ignored and is no longer supported is derived from the coverage bin base class cg_ignore_bins_default.
[0053] Specifically, Figure 2~3 As shown, in step S6, the coverage collection component base class coverage_base is declared and instantiated, and the coverage collection component base class coverage_base is replaced with the coverage collection parameter class through code reloading, thereby realizing the reuse of the coverage collection code. In this embodiment, the factory mechanism is used for code reloading.
[0054] As described above, in the coverage collection code reuse method according to an embodiment of the present invention, coverage code reuse is achieved by passing the coverage collection characteristics that need to be ignored into a parameterized class; at the same time, the coverage bin ignore_bins that the target needs to ignore is obtained by calling the static method of the coverage bin subclass.
[0055] The above combined with Figure 2~3The coverage collection code reuse method according to the embodiment of the present invention is described. Further, the present invention can also be applied to a computer-readable medium having a non-volatile program code executable by a processor.
[0056] The computer-readable medium of the embodiment of the present invention has a non-volatile program code executable by a processor, and the program code enables the processor to execute the coverage collection code reuse method of the above embodiment.
[0057] Above, refer to Figure 2~3 A coverage collection code reuse method and computer-readable medium according to an embodiment of the present invention are described, in which coverage code reuse is achieved by passing coverage collection features that need to be ignored into a parameterized class; at the same time, the coverage bins ignore_bins that the target needs to ignore are obtained by calling a static method of the coverage bin subclass.
[0058] It should be noted that, in this specification, the terms "include", "comprises" or any other variations thereof are intended to cover non-exclusive inclusion, so that a process, method, article or device including a series of elements includes not only those elements, but also other elements not explicitly listed, or also includes elements inherent to such process, method, article or device. In the absence of further restrictions, the elements defined by the sentence "comprises..." do not exclude the existence of other identical elements in the process, method, article or device including the elements.
[0059] Although the content of the present invention has been described in detail through the above preferred embodiments, it should be appreciated that the above description should not be considered as a limitation of the present invention. After reading the above content, it will be apparent to those skilled in the art that various modifications and substitutions of the present invention will occur. Therefore, the protection scope of the present invention should be limited by the appended claims.
Claims
1. A method for reusing coverage collection code, characterized in that: The following steps are included: Create a base class for overlay warehouse; As required, the coverage bin base class derives a coverage bin subclass, the coverage bin subclass is the coverage collection feature that needs to be ignored, and overloads the static method of the coverage bin base class; Create a coverage collection component base class for code reloading; use the factory mechanism for code reloading; The coverage collection component base class is derived into a parameterized class, and the parameter of the parameterized class is a coverage bin subclass; Passing the coverage bin subclass as a parameter into the parameterized class to obtain a coverage collection parameter class; Declare and instantiate the coverage collection component base class, and replace the coverage collection component base class with the coverage collection parameter class through code overloading; In the initial state, there is no coverage collection that needs to be ignored in the coverage bin base class.
2. The method for reusing coverage collection code according to claim 1, characterized in that: The functions in the overlay bin base class and the overlay bin subclass are for static calling.
3. The method for reusing coverage collection code according to claim 1, characterized in that: Functions in the overlay bin base class and the overlay bin subclass are statically called using the static keyword.
4. The method for reusing coverage collection code according to claim 1, characterized in that: The coverage code that is no longer supported and needs to be ignored is derived from the coverage bin base class.
5. A computer-readable medium having a non-volatile program code executable by a processor, characterized in that: The program code enables the processor to execute the coverage collection code reuse method described in any one of claims 1 to 4.