Disclosure of Invention
In view of this, the embodiments of the present application provide a code model generating method, a code model verifying method and related devices, so as to provide a basis for improving UVM verification efficiency.
In order to achieve the above object, the embodiment of the present invention provides the following technical solutions:
the embodiment of the application provides a code model generation method, which comprises the following steps:
acquiring an original code model, wherein the original code model comprises at least one attribute;
Determining the called attribute of the original code model in the simulation verification process based on the original code model;
And selecting codes for realizing the called attributes to form an object code model according to the called attributes.
Optionally, after the step of determining the attribute of the original code model, the method further includes:
Acquiring an attribute information file, wherein the attribute information file records a first corresponding relation, and the first corresponding relation is a corresponding relation between the original code model and the called attribute;
The step of composing an object code model according to the called attribute comprises the following steps:
and selecting code combinations for realizing the called attributes according to the attribute information file to obtain an object code model.
Optionally, the first correspondence includes an attribute of each original code model that is invoked during a simulation verification process.
Optionally, the step of selecting, according to the attribute information file, a code combination for implementing the invoked attribute to obtain an object code model includes:
Traversing the attribute information file, and searching and generating code fragments corresponding to the called attributes of each original code model;
and writing the code segment corresponding to the called attribute into the class of the target code model to obtain the target code model.
Optionally, the step of determining, based on the original code model, an attribute of the original code model that is invoked in a simulation verification process includes:
And running the test case once by using the original code model, and acquiring attribute codes of the attributes called by the original code model in the process of running the test case.
Optionally, before the step of selecting the function module corresponding to the simulation function to form the object code model according to the simulation function, the method further includes:
and disassembling the original code model based on the attribute to obtain a second corresponding relation, wherein the second corresponding relation is the corresponding relation between the attribute of the original code model and the code segment of the original code model.
Optionally, the second correspondence includes a one-to-one correspondence between an attribute of each of the original code models and a code segment of the original code model.
Optionally, the original code model and the target code model are RAL-based storage units;
the file type of the attribute information file includes a hash table file.
Optionally, the method further comprises the steps of obtaining an address which is not accessed in the process of running the test case;
Deleting the non-accessed address in a memory included in the object code model.
The embodiment of the application also provides a code model verification method, which comprises the following steps:
acquiring an original code model, wherein the original code model comprises at least one attribute;
Determining the called attribute of the original code model in the simulation verification process based on the original code model;
Selecting codes for realizing the called attributes to form an object code model according to the called attributes, and performing simulation verification on the code equipment to be verified by using the object code model.
Optionally, monitoring and outputting the invoked attribute in the simulation verification process of the original code model.
The embodiment of the application also provides a code model generating device, which comprises:
An original code model acquisition module for acquiring an original code model, the original code model includes at least one attribute;
the called attribute acquisition module is used for determining the called attribute of the original code model in the simulation verification process based on the original code model;
and the object code model generation module is used for selecting codes for realizing the called attributes to form an object code model according to the called attributes.
Optionally, the method further comprises:
the attribute information file acquisition module is used for acquiring an attribute information file, wherein the attribute information file records a first corresponding relation, and the first corresponding relation is a corresponding relation between the original code model and the called attribute;
And the object code model generating module is used for selecting the code combination for realizing the called attribute according to the attribute information file to obtain an object code model.
Optionally, the object code model generating module is configured to traverse the attribute information file, search and generate a code segment corresponding to the called attribute of each original code model, and write the code segment corresponding to the called attribute into a class of the object code model to obtain an object code model.
Optionally, the called attribute obtaining module is used for obtaining a test case, running the test case once by using the original code model, and obtaining attribute codes of the called attributes of the original code model in the process of running the test case.
Optionally, the method further comprises:
And the attribute disassembly module is used for disassembling the original code model based on the attribute to obtain a second corresponding relation, wherein the second corresponding relation is the corresponding relation between the attribute of the original code model and the code segment of the original code model.
Optionally, the method further comprises:
The non-accessed address acquisition module is used for acquiring the non-accessed address in the process of running the test case;
And the address deleting module is used for deleting the non-accessed address in a memory included in the object code model.
The embodiment of the application also provides a code model verification device, which comprises:
The system comprises an object code model acquisition module, a code composition module and a code generation module, wherein the object code model acquisition module is used for acquiring an original code model, the original code model comprises at least one attribute, determining the called attribute of the original code model in the simulation verification process based on the original code model, and selecting codes for realizing the called attribute according to the called attribute;
and the simulation verification module is used for performing simulation verification on the code equipment to be verified by using the original code model or the target code model.
Optionally, the system further comprises an attribute monitoring module for monitoring and outputting the invoked attribute of the original code model in the simulation verification process.
The embodiment of the application also provides a code model verification system which comprises the code model generation device and the code model verification device.
The embodiment of the application also provides a computing system for executing the code model generation method and the code model verification method.
Embodiments of the present application also provide a storage medium storing computer instructions that, when executed, implement the code model generation method as described above and the code model verification method as described above.
The code model generation method comprises the steps of obtaining an original code model, determining the called attribute of the original code model in the simulation verification process based on the original code model, and selecting codes for realizing the called attribute to form an object code model according to the called attribute.
In this way, an object code model is obtained by determining the called attributes in the UVM verification process based on the original code model after the original code model for simulation verification is obtained, and combining codes for realizing the called attributes in the original code model. So that there are no attributes within the object code model that are unused in the simulation verification process. And the composition of the object code model is simpler under the condition that the same attribute can be realized between the object code model and the original code model. Therefore, in the simulation verification process, the object code model is used for simulation, so that the purpose of reducing the operation amount in the process of simulating operation of the original code model is achieved, the simulation speed in the simulation verification process is increased, and the simulation verification efficiency is improved.
Detailed Description
The following description of the embodiments of the present application will be made clearly and completely with reference to the accompanying drawings, in which it is apparent that the embodiments described are only some embodiments of the present application, but not all embodiments. All other embodiments, which can be made by those skilled in the art based on the embodiments of the application without making any inventive effort, are intended to be within the scope of the application.
In the UVM verification environment, RAL is the most basic component and comprises the following functions of initializing a register and a memory, dynamically acquiring values of the register and the memory by a reference model, updating data contrast checking, and finally checking the values of the register and the memory before the simulation is finished. These functions of RAL offer great convenience to the UVM verification environment and also present problems in that each register and memory has a corresponding reference model and a large number of functions, which consume many resources when the number of registers is large, such as on the SoC level, reducing the speed of emulation, and in some special cases many functions are redundant, without any benefit other than affecting the speed of emulation.
In the simulation environment, in order to reduce the influence of the increased complexity caused by using the RAL, some verification environments choose to construct a code model to replace a register model in UVM, so that the simulation speed is increased. However, the built model is not a standard bottom-layer UVM register model, so that an upper-layer SoC user can generate ambiguity, and learning cost can be brought. The private register models constructed by different IP groups may have differences and are more difficult to use for upper-layer SoC users. Inside IP, the updating of the model can also be cumbersome if new requirements are introduced.
Based on the above description, there is a need for a SoC simulation method that not only simplifies the building of a register model inside an IP, but also facilitates the introduction and modification of an IP level by an upper layer at a SoC level.
In order to solve the above problems, an embodiment of the present application provides a code model generating method, in which an object code model is obtained by code combination of attributes used by an original code model, so that the size of the object code model running in a simulation process is simplified, and verification efficiency is improved. As an alternative implementation, fig. 1 shows a schematic flow chart of a code model generating method provided by an embodiment of the present application. As shown in fig. 1, the code model generating method provided by the embodiment of the application includes the following steps.
Step S10, an original code model is obtained, wherein the original code model comprises at least one attribute.
It should be noted that the original code model is the code model of the SoC system that needs to be verified in the UVM test. In the UVM test, a plurality of test cases are required to be run by using the original code model so as to simulate and verify the original code model.
Further, in an alternative implementation, the model of the original code model is a code model implemented based on RAL (Register Abstraction Layer ). The RAL code abstracts the hardware registers and memory into a software model that allows a verification engineer to operate on the registers without regard to underlying implementation details. In addition, the RAL employs an object-oriented programming (OOP) method, with each of the registers or memories' RALs corresponding to a class. And furthermore, based on the modularized design of codes, RAL classes are realized by encapsulating code modules with different attributes, so that the repeated use and maintenance are facilitated.
Specifically, in an alternative implementation, a schematic structural diagram of the original code model is shown in fig. 2. The plurality of raw code models shown in fig. 2 includes at least one register 11 and at least one memory 21. Wherein, the register 11 and the memory 21 are all RAL. At least 4 attributes are included in the register 11, respectively for initialization, mirroring, real-time monitoring and value checking, and at least 4 attributes are also included in the memory 21, respectively for initialization, mirroring, decoding and value checking. Furthermore, an object-oriented programming method is adopted based on the RAL, and each attribute in the register 11 and the memory 21 is an attribute code composition for realizing different attributes. Such as an initialization attribute code, a mirror attribute code, a decode attribute code, etc.
And step S20, determining the called attribute of the original code model in the simulation verification process based on the original code model.
As can be seen from the foregoing, not all the attributes of the original code model are called in the UVM verification process, and the codes of these non-called attributes are implemented, if the codes appear in the original code model, the complexity of the codes of the original code model is increased, resulting in lengthy codes and disordered structures of the original code model, and the readability and maintainability of the original code model are reduced. Second, redundant codes consume additional computing resources, increase simulation time, and reduce verification efficiency. Furthermore, unused attributes may contain potential errors or conflicts, increasing the difficulty of debugging and locating problems.
After the called attribute of the original code model in the UVM verification process is determined, the original code model can be simplified based on the called attribute, the attribute which is only called in the UVM verification process is reserved, the simplified original code model (namely the target code model) is enabled to be more simplified, the structure is clear, the understanding and the maintenance are easy, the development and the use efficiency are improved, the calculation resources required by simulation are reduced by redundant codes, the simulation speed is accelerated, and the verification efficiency is improved. The debugging difficulty can be reduced, and the reliability and stability of codes are improved.
Further, the attribute of the original code model, which is called in the UVM verification process, cannot be directly determined according to the original code model, and needs to be determined based on the specific running condition of the original code model in the UVM verification process. Specifically, as shown in fig. 3, in an alternative implementation, the step S20 includes a step S21 of obtaining a test case. And S22, running the test case once by using the original code model, and acquiring attribute codes of the attributes called by the original code model in the process of running the test case. In this way, by using one test case, the called properties can be easily determined, thereby facilitating the subsequent simplification of the original code model.
Further, in an optional implementation, the method for obtaining the attribute code of the attribute called by the original code model in the running process may include using a callback function in the RAL, or setting a monitoring module for the original code model, so that after the attribute is called, information of the attribute used may be output and recorded. Specifically, a callback function can be added in the code for realizing each attribute in the original code model, or a monitoring module is additionally configured for the original code model when the original code model is configured, and the monitoring module monitors which attributes are used and output in each read-write operation and records the output in log information of the monitoring module.
Further, after obtaining the attribute code of the called attribute, the attribute code of the called attribute needs to be sorted so as to determine the called attribute later. As shown in fig. 3, in an alternative implementation, the method further includes step S23 of obtaining an attribute information file, where a first correspondence is recorded in the attribute information file, where the first correspondence is a correspondence between the secondary model and the invoked attribute.
The attribute information file is a file obtained by sorting the attribute codes of the called attributes obtained in step S22. Specifically, in an optional implementation, the attribute codes of the called attributes are sorted through a preset script file, and the sorted result is saved as a specific file format, and the obtained file is the attribute information file. The preset script file can automatically compare the obtained called attribute codes with the attribute codes which are known in a pre-stored code library and can realize different attributes, so that the original code model calls and records the attributes. For example, for two original code models, its called properties may be recorded in the format of original code model 1, property { initialization }, original code model 2, property { mirror }. Further, to facilitate storage and use of the attribute information file, in an alternative implementation, the file type of the attribute information file is a hash table.
With continued reference to fig. 1, the code model generating method provided by the embodiment of the present application further includes step S30 of selecting, according to the called attribute, a code for implementing the called attribute to form an object code model.
It should be noted that, as can be seen from the foregoing, the implementation of the original code model is based on the RAL of the Object Oriented Programming (OOP) method, so that in the original code model, the codes implementing each attribute can be independently operated except for the attribute information to be processed transferred between the attribute codes implementing each attribute. And therefore, selecting the codes for realizing the called attributes, and using the codes for realizing the called attributes to reconstruct an object code model, namely removing redundant attributes in the original code model in the object code model, thereby obtaining a simplified object code model.
Further, after the attribute information file is obtained, the called attribute and the code of the called attribute can be easily determined according to the attribute information file, so, as shown in fig. 3, in an alternative implementation, the step S30 includes a step S31 of selecting, according to the attribute information file, a code combination implementing the called attribute to obtain an object code model.
Specifically, based on the use of the attribute information file, as shown in fig. 4, in an alternative implementation, the step S31 includes a step S311 of traversing the attribute information file to find and generate a code segment corresponding to the called attribute of each original code model. It should be noted that, in an alternative implementation, the processing of the attribute information file is continued through the script file to obtain the destination register. After the called attribute is found in the attribute information file, a code segment corresponding to the called attribute needs to be found in a pre-stored code library, and the code segment is generated.
And step S312, writing the code segment corresponding to the called attribute into the class of the target code model to obtain the target code model.
It should be noted that, the class of the object code model is the class representing the object code model in the code implementation process. A "class" is a code structure that provides a complete set of registers and memory modeling framework to facilitate modeling, accessing, and validating hardware registers or memory in a high level abstract manner. And writing the attribute codes of the called attributes into the classes of the object code model to obtain the required object code model.
At this time, the resulting reduced object code model is shown in fig. 5, with respect to the object code model as described in fig. 2 as an example. In these modified RALs, only the initialization attribute is left in the register 11, while the attributes of both registers 12 and 13 are reduced, relative to the registers, and also only the initialization attribute is left in the memory 21, and the attributes in the memory 22 and 23 are reduced, relative to the memories. Therefore, the code model generation method provided by the embodiment of the application can effectively simplify the complexity of the original code model.
In this way, an object code model is obtained by determining the called attributes in the UVM verification process based on the original code model after the original code model for simulation verification is obtained, and combining codes for realizing the called attributes in the original code model. So that there are no attributes within the object code model that are unused in the simulation verification process. And the composition of the object code model is simpler under the condition that the same attribute can be realized between the object code model and the original code model. Therefore, in the simulation verification process, the object code model is used for simulation, so that the purpose of reducing the operation amount in the process of simulating operation of the original code model is achieved, the simulation speed in the simulation verification process is increased, and the simulation verification efficiency is improved.
Further, for a strange original code model, there may not be a pre-stored code base storing the attributes and the attribute codes, so it is necessary to generate a pre-stored code base based on the original code model. Specifically, as shown in fig. 6, in an alternative implementation, before the step S20, a step S11 is further included of disassembling the original code model based on the attribute to obtain a second correspondence. The second corresponding relation is a corresponding relation between the attribute of the original code model and the code segment of the original code model. Specifically, in an optional implementation, the second correspondence includes a one-to-one correspondence between an attribute of each of the original code models and a code segment of the original code model.
Thus, after the second corresponding relation of the original code model is obtained, the attribute of the original code model and the code segments of the original code model can be stored to obtain a pre-stored code library, or the pre-stored code library can be directly recorded in a cache for subsequent use.
Further, if the original code model is a simulation model of the memory, during the initialization of the memory, all possible address spaces of the memory are usually simulated according to the design specification or the memory specification, and addresses that cannot be accessed in the current test scenario may exist in these address spaces, so that the addresses that cannot be accessed may be reduced.
Specifically, as shown in fig. 6, in an alternative implementation, the code model generating method provided by the embodiment of the present application further includes step S41, where an address that is not accessed in the process of running the test case is obtained. Specifically, in the running process of running the test, a coverage rate collection module can be additionally arranged in the original code model to monitor conditions of reading, writing, accessing bits and the like of the original code model so as to obtain a coverage rate analysis file of an address of the original code model. The coverage rate analysis file can display the accessed rate of the addresses, and the addresses with the accessed rate of zero are the addresses which are not accessed. Or using a log and report mechanism of the original code model to acquire the accessed addresses in the process of all the running test cases, and comparing the accessed addresses with all the addresses of the original code model to determine the non-accessed addresses.
And S42, deleting the non-accessed address in a memory included in the target code model. It should be noted that, since the address that is not accessed in the verification process, even if the address that is not accessed is deleted, the operation of the target register is not affected. After deleting the address which is not accessed, the object code model can be simplified, and the simulation efficiency is improved.
The embodiment of the application also provides a code model verification method, which uses the simplified object code model to verify the code model, thereby simplifying the size of the object code model operated in the simulation process and improving the verification efficiency. As an alternative implementation, fig. 7 shows a schematic flow chart of a code model verification method provided by an embodiment of the present application. As shown in fig. 7, the code model verification method provided by the embodiment of the application includes the following steps.
Step S51, an original code model is obtained, the original code model comprises at least one attribute, the attribute of the original code model which is called in the simulation verification process is determined based on the original code model, and codes for realizing the called attribute are selected to form an object code model according to the called attribute.
And S52, performing simulation verification on the code to be verified by using the target code model.
Further, in order to facilitate the determination of the attribute of the original code model that is invoked during the simulation verification process, in an optional implementation, the step S52 is performed while further including a step S53 of monitoring and outputting the attribute of the original code model that is invoked during the simulation verification process.
In this way, an object code model is obtained by determining the called attributes in the UVM verification process based on the original code model after the original code model for simulation verification is obtained, and combining codes for realizing the called attributes in the original code model. So that there are no attributes within the object code model that are unused in the simulation verification process. And the composition of the object code model is simpler under the condition that the same attribute can be realized between the object code model and the original code model. Furthermore, in the simulation verification process, the target code model is used, so that the operation amount of the target code model in the simulation operation can be reduced, the simulation speed in the simulation verification process is increased, and the simulation verification efficiency is improved.
The embodiment of the application also provides a code model generating device, which obtains the target code model through the code combination of the used attributes of the original code model, thereby simplifying the size of the target code model operated in the simulation process and improving the verification efficiency. As an alternative implementation, fig. 8 shows a schematic structural diagram of a code model generating apparatus provided by an embodiment of the present application. As shown in fig. 8, the code model generating apparatus provided by the embodiment of the present application includes the following structure.
An original code model acquisition module 100 for acquiring an original code model, the original code model including at least one attribute;
And the called attribute acquisition module 200 is used for determining the attribute of the original code model, which is called in the simulation verification process, based on the original code model.
And the object code model generating module 300 is used for selecting codes for realizing the called attributes to form an object code model according to the called attributes.
Further, in an optional implementation, as shown in fig. 8, the code model generating apparatus provided by the embodiment of the present application further includes:
The attribute information file obtaining module 400 is configured to obtain an attribute information file, where a first correspondence is recorded in the attribute information file, where the first correspondence is a correspondence between the original code model and the invoked attribute.
The object code model generating module 300 is configured to select, according to the attribute information file, a code combination for implementing the invoked attribute to obtain an object code model.
Further, in an optional implementation, the object code generation and acquisition module 300 is configured to traverse the attribute information file, find and generate a code segment corresponding to a called attribute of each original code model, and write the code segment corresponding to the called attribute into a class of the object code model to obtain an object code model.
Further, in an alternative implementation, the called attribute obtaining module 200 is configured to obtain a test case, run the test case once by using the original code model, and obtain an attribute code of an attribute called by the original code model in the process of running the test case.
Further, in an optional implementation, as shown in fig. 8, the code model generating apparatus provided by the embodiment of the present application further includes:
And the attribute disassembly module 500 is configured to disassemble the original code model based on attributes to obtain a second corresponding relationship, where the second corresponding relationship is a corresponding relationship between the attributes of the original code model and the code segments of the original code model.
Further, in an optional implementation, as shown in fig. 8, the code model generating apparatus provided by the embodiment of the present application further includes:
The non-accessed address obtaining module 610 is configured to obtain an address that is not accessed in the process of running the test case.
An address deleting module 620, configured to delete the non-accessed address in a memory included in the object code model.
The embodiment of the application also provides a code model verification device, which uses the simplified object code model to verify the code model, thereby simplifying the size of the object code model operated in the simulation process and improving the verification efficiency. As an alternative implementation, fig. 9 shows a schematic structural diagram of a code model verification device provided by an embodiment of the present application. As shown in fig. 9, the code model verification apparatus provided by the embodiment of the present application includes the following structure.
The object code model obtaining module 700 is configured to obtain the object code model generated by the code model generating device.
And the simulation verification module 800 is used for performing simulation verification on the code equipment to be verified by using the target code model.
The embodiment of the application also provides a code model verification system, which comprises an object code model acquisition module, a verification module and a verification module, wherein the object code model acquisition module is used for acquiring an original code model, the original code model comprises at least one attribute, the attribute of the original code model which is called in the simulation verification process is determined based on the original code model, and codes for realizing the called attribute are selected to form the object code model according to the called attribute.
Further, in an alternative implementation, the code model verification system further comprises an attribute monitoring module for monitoring and outputting the attributes of the original code model which are called in the simulation verification process.
The embodiment of the application also provides a computing system for executing the code model generation method and the code model verification method.
Embodiments of the present application also provide a storage medium storing computer instructions that, when executed, implement the code model generation method as described above and the code model verification method as described above.
Although the embodiments of the present application are disclosed above, the present application is not limited thereto. Various changes and modifications may be made by one skilled in the art without departing from the spirit and scope of the application, and the scope of the application should be assessed accordingly to that of the appended claims.