What you will learn in this tip: Running test simulations, storing log files, creating a summary from log files and merging coverage from different tests with Python.
During the verification process, It is very common to run many tests. In order to simulate each one of them you need to execute different test files separately. In case there is a significant amount of tests that have to be performed, this process can easily be extremely time-consuming. It is also difficult to review the results of all the different tests. A possible solution to that is to create a Python script which runs all the tests and then gathers all the results of these tests in order to review them all together.
To handle terminal commands, it is necessary to import and use the “os” package of Python. With the help of this package, someone will be able to run test simulations and handle the results of these tests more easily.
In order to run a test, it is important to gather the names of all the tests first. In case all the tests are stored in a single directory and the name of the test files are the same as the names of the test cases, then the “listdir(“ directory ”)” function can be used to store all of them in a list. If this is not the case, another solution would be to create and store the tests’ names list manually.
After the tests’ names have been gathered, we can run a simulation for each of them. The function “system(“ command ”)” can be used to execute terminal commands. The “xrun” command with all the necessary options will run simulations and create log, waves and coverage files for each test. Afterward, these files can be stored separately to gather the results of all tests together. In case the list with the test names includes the “.sv” suffix, it is important to exclude it because this will result in a fatal error during the simulation.
Another extra feature that can be added to the script is the creation of a summary. This summary can include important information and results from the log files of all tests. By searching for specific keywords in the log files someone can find and store parts of the documents that are important to be stored according to their needs.
Finally, it is very common for tests to include coverage. In that case, an extra feature can be added in the script that merges the results of all the tests’ coverage. Since this can be done through terminal commands, the “system ( command )” function is needed. To achieve this, the tests need to have the same covergroups.