How to read and write registers in UVM environment using C language

By encapsulating the callable register access interface method of C language in the UVM verification environment, the problem of direct access to DUT registers in the prior art is solved, and the use of C language in the UVM environment is realized for register read and write access, which meets the requirements of chip verification.

CN114840254BActive Publication Date: 2025-03-18YUNHE ZHIWANG (SHANGHAI) TECHNOLOGY CO LTD
View PDF 1 Cites 0 Cited by

Patent Information

Application Number
CN202210418237.6
Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
Filing Date
2022-04-21
Publication Date
2025-03-18
Estimated Expiration
2042-04-21

AI Technical Summary

Technical Problem

The prior art does not support direct use of C language to read and write access to DUT registers, which cannot meet the requirements of chip verification.

Method used

Build a UVM verification environment and a C locale environment, and encapsulate the register access interface methods for call in the C locale environment under the UVM verification environment. By creating access methods and control programs in the C locale environment, these interface methods are called to achieve read and write access to the target registers.

Benefits of technology

It realizes direct access to registers using C language in the UVM environment, meets the requirements of chip verification and improves the comprehensiveness and efficiency of verification.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN114840254B_ABST
    Figure CN114840254B_ABST
Patent Text Reader

Abstract

The present invention discloses a method for reading and writing registers in a UVM environment using C language, comprising the following sub-steps: building a UVM verification environment and a C language environment; encapsulating an interface method for register access called in a C language environment in the UVM environment, and encapsulating it in a package reusable package file; creating a first access method in the C language environment for calling the above-mentioned several interface methods; writing a control program in the C language environment for calling the first access method to read and write a target register; starting the control program in the UVM verification environment to finally complete the read and write access to the target register. The present invention solves the problem that the prior art does not support directly using C language to read and write access to a register of a DUT.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present invention relates to the technical field of chip verification, and in particular to a method for reading and writing registers in a UVM environment by using C language. Background Art

[0002] In the prior art, such as Figure 1 As shown in the figure, registers are used inside RTL (Register transfer level) design to complete some logic functions. Therefore, when we verify the RTL design, we need to model its internal registers to simulate the functional logic inside the RTL as much as possible, so as to help verification developers judge the correctness of the RTL design function.

[0003] The UVM register model (register_model) can be used to conveniently model the registers and storage inside the DUT (Design under test, i.e. the RTL design mentioned above). After creating the register model, you can obtain the handle of the register model in the sequence and component and call the interface method in the register model to complete the read and write access to the register, such as Figure 1 As shown in the figure, the sequence on the left implements read and write access to the register by calling the interface method in the register model. You can also directly start the sequence of the register bus as on the right, that is, implement read and write access to the register by operating the bus. UVM (Universal Verification Methodology) is a universal verification methodology, so it needs to be able to handle various types of transaction request sequence_item. After integrating the characteristics of various types of transaction request sequence_item, UVM predefines a transaction request sequence_item, namely uvm_reg_item. Then, the bus2reg() and reg2bus() methods of the adapter are used to realize the conversion between uvm_reg_item and the bus_item of the target bus protocol, and finally the sequencer and driver drive it to the DUT (Device Under Test), thereby finally completing the reading and writing of the target register.

[0004] There are situations in the existing technology that cannot meet the requirements of chip verification. For example, when we perform system-level full-chip verification on a SOC (System on chip) chip, we usually use C function incentives to implement it, and then compile it into instructions that the CPU can run. The CPU then uses a series of bus interfaces to finally complete the reading and writing of the target registers according to a certain access sequence. Because a chip will eventually be given to software developers for development and use, software developers use C language to write code, and then use tools to compile it into corresponding instructions to use the functions provided on this chip. Therefore, in order to verify the chip more comprehensively, we need to verify the chip's usage scenarios at the full-chip level by simulating the methods used by software developers. However, the existing solutions do not support direct use of C language to read and write access to the DUT's registers, so the existing solutions cannot meet our requirements for chip verification. Summary of the invention

[0005] According to an embodiment of the present invention, a method for reading and writing registers in a UVM environment using C language is provided, comprising the following sub-steps:

[0006] Build UVM verification environment and C language environment;

[0007] In the UVM verification environment, several interface methods for register access called in the C language environment are encapsulated, and several interface methods are encapsulated into the package reusable package file of the UVM verification environment;

[0008] Creating a first access method in a C language environment for calling the above-mentioned several interface methods;

[0009] Writing a control program in a C language environment to call the first access method to perform read and write access to the target register;

[0010] The control program is started in the UVM verification environment, thereby finally completing the read and write access of the target register.

[0011] Furthermore, the native DPI interface file of the SystemVerilog language and the first access method created in the C environment are declared in the header file reg_api.h.

[0012] Further, several interface methods of the UVM verification environment are encapsulated in the UVM verification environment, and a package reusable package file that encapsulates several interface methods in the UVM verification environment is included, including the following sub-steps:

[0013] Import the UVM verification environment library file at the top of the c_stimulus.sv file in the SystemVerilog language environment to encapsulate several interface methods;

[0014] Create the set_c_stimulus_register_block method in the c_stimulus.sv file to pass the handle of the register model in the UVM verification environment to several interface methods;

[0015] Create the get_register_from_address method in the c_stimulus.sv file to get the target register;

[0016] Create a second access method in the c_stimulus.sv file to access the target register;

[0017] Several interface methods are encapsulated in a UVM verification environment for calling a first access method in the UVM verification environment.

[0018] Further, the get_register_from_address method obtains the target register in the register model according to the address of the target register on the bus.

[0019] Furthermore, a second access method is created in the c_stimulus.sv file to access the target register, including the following sub-steps:

[0020] Create the second access method in the c_stimulus.sv file and call the get_register_from_address method to obtain the handle of the target register.

[0021] Use the handle of the target register to call the read and write access methods of the native registers of the UVM verification environment to access the target register.

[0022] The method for reading and writing registers in a UVM environment using C language according to an embodiment of the present invention solves the problem that the prior art does not support directly using C language to read and write registers of a DUT.

[0023] 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

[0024] Figure 1 It is a schematic diagram of the prior art;

[0025] Figure 2 A schematic diagram of a method for reading and writing registers in a UVM environment using C language according to an embodiment of the present invention;

[0026] Figure 3A flow chart of the steps of a method for reading and writing access to registers in a UVM environment using C language according to an embodiment of the present invention;

[0027] Figure 4 for Figure 3 Flow chart of the sub-steps of step S2;

[0028] Figure 5 for Figure 4 Flowchart of the sub-steps of step S24. DETAILED DESCRIPTION

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

[0030] First, combine Figures 2~5 The present invention describes a method for reading and writing registers in a UVM environment using C language according to an embodiment of the present invention, which is used for chip verification and has a wide range of application scenarios.

[0031] like Figures 2~4 As shown, the read-write access method of registers in a UVM environment using C language in an embodiment of the present invention comprises the following sub-steps:

[0032] In S1, Figure 2~3 As shown, build the UVM verification environment and C language environment.

[0033] In S2, if Figure 2~3 As shown, several interface methods for register access called in the C language environment are encapsulated in the UVM verification environment, and the several interface methods are encapsulated into the package reusable package file of the UVM verification environment.

[0034] In S3, such as Figure 2~3 As shown, a first access method is created in a C language environment to call the above-mentioned several interface methods.

[0035] In S4, Figure 2~3 As shown, a control program is written in a C language environment, and the control program is a C program, which is used to call the first access method to perform read and write access to the target register.

[0036] In S5, Figure 2~3 As shown, the control program is started in the UVM verification environment, thereby finally completing the read and write access to the target register.

[0037] Furthermore, the native DPI interface file of the SystemVerilog language and the first access method created in the C environment are declared in the header file reg_api.h.

[0038] Further, several interface methods of the UVM verification environment are encapsulated in the UVM verification environment, and a package reusable package file that encapsulates several interface methods in the UVM verification environment is included, including the following sub-steps.

[0039] In S21, if Figure 2 , 4 As shown, the library file of the UVM verification environment is imported at the top of the c_stimulus.sv file in the SystemVerilog language environment to encapsulate several interface methods using the native register access method in the UVM verification environment.

[0040] In S22, if Figure 2 , 4 As shown, the set_c_stimulus_register_block method is created in the c_stimulus.sv file to pass the handle of the register model in the UVM verification environment to several interface methods.

[0041] In S23, if Figure 2 , 4 As shown, create the get_register_from_address method in the c_stimulus.sv file to obtain the target register.

[0042] In S24, if Figure 2 , 4 As shown, a second access method is created in the c_stimulus.sv file for accessing the target register. The second access method first calls the get_register_from_address method to obtain the handle of the target register, and then uses the handle of the target register to call the native register read and write access method of the UVM verification environment to implement the access to the target register.

[0043] Furthermore, a second access method is created in the c_stimulus.sv file for accessing the target register, including the following sub-steps:

[0044] In S241, Figure 5 As shown, create a second access method in the c_stimulus.sv file, call the get_register_from_address method, and obtain the handle of the target register.

[0045] In S242, if Figure 5 As shown, the handle of the target register is used to call the read and write access method of the register native to the UVM verification environment to access the target register.

[0046] In S25, if Figure 2 , 4 As shown, several interface methods are encapsulated in a UVM verification environment for calling a first access method in the UVM verification environment, and the several interface methods include:

[0047] c_reg_write is used to simulate write access to registers, and the access_type parameter determines whether it is front-door or back-door access.

[0048] c_reg_read is used to simulate read access to registers, and the access_type parameter determines whether it is a front-door or back-door access.

[0049] c_reg_poke, used to simulate backdoor write (peek) access to registers.

[0050] c_reg_peek, used to simulate backdoor read (poke) access to registers.

[0051] c_reg_get is used to simulate the acquisition of the expected value of a register.

[0052] c_reg_set is used to simulate the setting of the expected value of the register.

[0053] c_reg_update is used to simulate the update of the mirror value in the register model and the value of the actual register in the DUT.

[0054] c_reg_get_mirrored_value is used to obtain the mirrored value in the register model.

[0055] c_reg_randomize, used to randomize the expected values ​​in the register model.

[0056] c_reg_predict, used to update the expected and mirrored values ​​in the register model.

[0057] c_reg_reset, which sets the expected and mirrored values ​​in the register model to the reset values ​​during configuration.

[0058] c_reg_get_reset is used to return the reset value of the register model during configuration.

[0059] Furthermore, the get_register_from_address method searches in the register model according to the address of the target register on the bus, and then returns the handle of the target register to obtain the target register.

[0060] like Figure 2As shown, the present embodiment provides a DPI interface that interacts with the C language through the SystemVerilog language, and can realize joint compilation development with the C language, and the UVM universal verification methodology is developed based on the SystemVerilog language, so we can utilize the DPI interface to realize the read and write access of the register in the UVM environment with the C language; The register model of the present embodiment in the UVM universal verification methodology provides a series of register read and write access methods, so we can use the DPI interface in the C language environment to provide similar corresponding access interface to achieve the same effect of directly calling the register read and write access method in the UVM verification environment, give full play to the versatility of this method, encapsulate it into the library file of universal methodology, to facilitate use in other similar projects, improve development efficiency.

[0061] Above, refer to Figures 2~5 The present invention describes a method for reading and writing registers in a UVM environment using C language according to an embodiment of the present invention, which solves the problem that the prior art does not support directly using C language to read and write registers of a DUT.

[0062] 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 includes 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.

[0063] 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 reading and writing registers in a UVM environment using C language, characterized in that: Contains the following sub-steps: Build UVM verification environment and C language environment; Encapsulating several interface methods for register access called in the C language environment under the UVM verification environment, and encapsulating the several interface methods into a package reusable package file of the UVM verification environment; Creating a first access method in the C language environment for calling the plurality of interface methods; Writing a control program in the C language environment to call the first access method to perform read and write access to the target register; Start the control program in the UVM verification environment, thereby finally completing the read and write access of the target register; In the UVM verification environment, several interface methods of the UVM verification environment are encapsulated, and a package reusable package file of the UVM verification environment is included, comprising the following sub-steps: Import the library file of the UVM verification environment at the top of the c_stimulus.sv file in the SystemVerilog language environment to encapsulate the several interface methods; Create a set_c_stimulus_register_block method in the c_stimulus.sv file, and pass the handle of the register model in the UVM verification environment to the several interface methods; Create a get_register_from_address method in the c_stimulus.sv file to obtain the target register; Creating a second access method in the c_stimulus.sv file for accessing the target register; The plurality of interface methods are encapsulated in the UVM verification environment for calling the first access method in the UVM verification environment.

2. The method for reading and writing registers in a UVM environment using C language as claimed in claim 1, wherein: The SystemVerilog language native DPI interface file and the first access method created in the C environment are declared in the header file reg_api.h.

3. The method for reading and writing registers in a UVM environment using C language as claimed in claim 1, wherein: The get_register_from_address method obtains the target register in the register model according to the address of the target register on the bus.

4. The method for reading and writing registers in a UVM environment using C language as claimed in claim 1, wherein: Create a second access method in the c_stimulus.sv file for accessing the target register, comprising the following sub-steps: Create a second access method in the c_stimulus.sv file, call the get_register_from_address method, and obtain the handle of the target register; The handle of the target register is used to call the read and write access method of the register native to the UVM verification environment to access the target register.

Citation Information

Patent Citations

  • Method for reusing C program test vector in UVM (Universal Verification Methodology) verification environment

    CN104899138A