![Build](https://github.com/tpoikela/uvm-python/workflows/Build/badge.svg?branch=master)
[![Coverage Status](https://coveralls.io/repos/github/tpoikela/uvm-python/badge.svg?branch=master)](https://coveralls.io/github/tpoikela/uvm-python?branch=master)
[![PyPI version](https://badge.fury.io/py/uvm-python.svg)](https://badge.fury.io/py/uvm-python)
UVM library for Python
======================
This is a port of SystemVerilog (SV) Universal Verification Methodology (UVM)
1.2 to Python and cocotb. Icarus Verilog (iverilog) and Verilator have been used for
testing the code so far.
See documentation for more details:
- [uvm-python Documentation](https://uvm-python.readthedocs.io/).
- [uvm-python User's Guide](https://uvm-python.readthedocs.io/en/latest/uvm_users_guide_1.2.html)
SystemVerilog UVM is not currently supported by any open source/free tools. cocotb offers
excellent solution to interact with any simulator (free/proprietary), so
testbenches can be written in Python as well. `uvm-python` tries to offer
an API similar to the original SV-UVM version. This means that many UVM verificaton
skills and API knowledge are transferable from SV to Python very easily.
If you want to port a larger bulk of SV code to use `uvm-python`, you can try the
script `bin/sv2py.pl` as the first step. It's a regex-based solution, and code
will still require lots of manual edits to work.
Documentation
-------------
The documentation is available on `readthedocs.io` in
[uvm-python HTML documentation](https://uvm-python.readthedocs.io/).
Installation
------------
You can install uvm-python as a normal Python package. It is recommended to use
[venv](https://docs.python.org/3/library/venv.html) to create a virtual
environment for Python prior to installation.
Install from PyPi using pip:
```shell
python -m pip install uvm-python
```
or directly from source files (for the latest development version):
```shell
git clone https://github.com/tpoikela/uvm-python.git
cd uvm-python
python -m pip install . # If venv is used
# Or without venv, and no sudo:
python -m pip install --user . # Omit --user for global installation
```
See [Makefile](test/examples/simple/Makefile) for working examples. You can
also use Makefiles in `test/examples/simple` as a
template for your project.
Running the examples and development
------------------------------------
See `test/examples/simple/Makefile` for working examples. More features/examples will be added
incrementally.
To run all tests:
```shell
SIM=icarus make test # Use iverilog as a simulator
```
To run unit tests only:
```
make test-unit # Does not require simulator
```
### Minimal working example ###
`uvm-python` must be installed prior to running the example. Alternatively, you
can create a symlink to the `uvm` source folder:
```shell
cd test/examples/minimal
ln -s ../../../src/uvm uvm
SIM=icarus make
```
You can find the
source code for this example [here](test/examples/minimal). This example
creates a test component, registers it with the UVM factory, and starts the test.
You can execute the example by running `SIM=icarus make`. Alternatively, you can
run it with `SIM=verilator make`.
```make
# File: Makefile
TOPLEVEL_LANG ?= verilog
VERILOG_SOURCES ?= new_dut.sv
TOPLEVEL := new_dut
MODULE ?= new_test
include $(shell cocotb-config --makefiles)/Makefile.sim
```
The top-level module must match `TOPLEVEL` in `Makefile`:
```verilog
// File: new_dut.sv
module new_dut(input clk, input rst, output[7:0] byte_out);
assign byte_out = 8'hAB;
endmodule: new_dut
```
The Python test file name must match `MODULE` in `Makefile`:
```python
# File: new_test.py
import cocotb
from cocotb.triggers import Timer
from uvm import *
@uvm_component_utils
class NewTest(UVMTest):
async def run_phase(self, phase: UVMPhase):
phase.raise_objection(self)
await Timer(100, "NS")
uvm_info("NEW_TEST", "Test passed, all OK", UVM_MEDIUM)
phase.drop_objection(self)
@cocotb.test()
async def test_dut(dut):
await run_test('NewTest')
```
Current status
--------------
Testbenches can already be written with all the typical UVM
components. UVM Phasing is in place, and working. Stimulus can be generated
using (even hierarchical) sequences. Register
layer supports already read/write to registers (via frontdoor), and to
memories (frontdoor and backdoor). TLM 1.0 is implemented,
put/get/analysis interfaces are done, and master/slave interfaces work. Initial
implementation of TLM2.0 has also been added. The table below summarizes the
status:
| Feature | Status |
| --------- | ------ |
| TLM1.0 | Done |
| TLM2.0 | Done |
| Components | Done |
| Phases | Done |
| Objections | Test and env-level objections work |
| Sequences | Partially done, hier sequences work |
| Registers | Reg/mem access working, built-in sequences partially done |
Please try it out, and let me know if
something you require should be added, or even better, add it yourself, test it
and create a pull request!
HDL Simulators
--------------
Tested with Icarus Verilog (iverilog v13.0 (devel)) and verilator (v5.008). The
exact commit for iverilog can be found from `ci/install_iverilog.sh`.
Icarus Verilog and verilator are free simulators, which can
be used with cocotb. uvm-python uses cocotb to interface with these simulators.
Memory backdoor access has issues with packed multi-dimensional arrays in
verilator. Also, some other examples are not working with verilator yet.
Proprietary simulators that work with cocotb should work with
uvm-python as well, but haven't been tested.
Related projects
----------------
- [cocotb](https://github.com/cocotb/cocotb) cosimulation library for writing testbenches in Python
- [uvm-python-verification-lib](https://github.com/jg-fossh/uvm-python-verification-lib) UVM Python Verification Agents Library
Raw data
{
"_id": null,
"home_page": "https://github.com/tpoikela/uvm-python",
"name": "uvm-python",
"maintainer": "",
"docs_url": null,
"requires_python": ">=3.8",
"maintainer_email": "",
"keywords": "UVM,SystemVerilog,Verilog,RTL,Coverage",
"author": "Tuomas Poikela",
"author_email": "tuomas.sakari.poikela@gmail.com",
"download_url": "https://files.pythonhosted.org/packages/06/35/60f9fc85d8158777427cb36d1702cfdd6b1ec8def4dda9f174382ed18bd9/uvm-python-0.3.0.tar.gz",
"platform": "any",
"description": "![Build](https://github.com/tpoikela/uvm-python/workflows/Build/badge.svg?branch=master)\n[![Coverage Status](https://coveralls.io/repos/github/tpoikela/uvm-python/badge.svg?branch=master)](https://coveralls.io/github/tpoikela/uvm-python?branch=master)\n[![PyPI version](https://badge.fury.io/py/uvm-python.svg)](https://badge.fury.io/py/uvm-python)\n\nUVM library for Python\n======================\n\nThis is a port of SystemVerilog (SV) Universal Verification Methodology (UVM)\n1.2 to Python and cocotb. Icarus Verilog (iverilog) and Verilator have been used for\ntesting the code so far.\n\nSee documentation for more details:\n - [uvm-python Documentation](https://uvm-python.readthedocs.io/).\n - [uvm-python User's Guide](https://uvm-python.readthedocs.io/en/latest/uvm_users_guide_1.2.html)\n\nSystemVerilog UVM is not currently supported by any open source/free tools. cocotb offers\nexcellent solution to interact with any simulator (free/proprietary), so\ntestbenches can be written in Python as well. `uvm-python` tries to offer\nan API similar to the original SV-UVM version. This means that many UVM verificaton\nskills and API knowledge are transferable from SV to Python very easily.\n\nIf you want to port a larger bulk of SV code to use `uvm-python`, you can try the\nscript `bin/sv2py.pl` as the first step. It's a regex-based solution, and code\nwill still require lots of manual edits to work.\n\nDocumentation\n-------------\n\nThe documentation is available on `readthedocs.io` in\n[uvm-python HTML documentation](https://uvm-python.readthedocs.io/).\n\nInstallation\n------------\n\nYou can install uvm-python as a normal Python package. It is recommended to use\n[venv](https://docs.python.org/3/library/venv.html) to create a virtual\nenvironment for Python prior to installation.\n\nInstall from PyPi using pip:\n```shell\npython -m pip install uvm-python\n```\n\nor directly from source files (for the latest development version):\n\n```shell\ngit clone https://github.com/tpoikela/uvm-python.git\ncd uvm-python\npython -m pip install . # If venv is used\n# Or without venv, and no sudo:\npython -m pip install --user . # Omit --user for global installation\n```\n\nSee [Makefile](test/examples/simple/Makefile) for working examples. You can\nalso use Makefiles in `test/examples/simple` as a\ntemplate for your project.\n\nRunning the examples and development\n------------------------------------\n\nSee `test/examples/simple/Makefile` for working examples. More features/examples will be added\nincrementally.\n\nTo run all tests:\n```shell\n SIM=icarus make test # Use iverilog as a simulator\n```\n\nTo run unit tests only:\n```\n make test-unit # Does not require simulator\n```\n\n### Minimal working example ###\n\n`uvm-python` must be installed prior to running the example. Alternatively, you\ncan create a symlink to the `uvm` source folder:\n\n```shell\ncd test/examples/minimal\nln -s ../../../src/uvm uvm\nSIM=icarus make\n```\n\nYou can find the\nsource code for this example [here](test/examples/minimal). This example\ncreates a test component, registers it with the UVM factory, and starts the test.\n\nYou can execute the example by running `SIM=icarus make`. Alternatively, you can\nrun it with `SIM=verilator make`.\n\n```make\n# File: Makefile\nTOPLEVEL_LANG ?= verilog\nVERILOG_SOURCES ?= new_dut.sv\nTOPLEVEL := new_dut\nMODULE ?= new_test\ninclude $(shell cocotb-config --makefiles)/Makefile.sim\n```\n\nThe top-level module must match `TOPLEVEL` in `Makefile`:\n\n```verilog\n// File: new_dut.sv\nmodule new_dut(input clk, input rst, output[7:0] byte_out);\n assign byte_out = 8'hAB;\nendmodule: new_dut\n```\n\nThe Python test file name must match `MODULE` in `Makefile`:\n\n```python\n# File: new_test.py\nimport cocotb\nfrom cocotb.triggers import Timer\nfrom uvm import *\n\n@uvm_component_utils\nclass NewTest(UVMTest):\n\n async def run_phase(self, phase: UVMPhase):\n phase.raise_objection(self)\n await Timer(100, \"NS\")\n uvm_info(\"NEW_TEST\", \"Test passed, all OK\", UVM_MEDIUM)\n phase.drop_objection(self)\n\n\n@cocotb.test()\nasync def test_dut(dut):\n await run_test('NewTest')\n```\n\nCurrent status\n--------------\n\nTestbenches can already be written with all the typical UVM \ncomponents. UVM Phasing is in place, and working. Stimulus can be generated\nusing (even hierarchical) sequences. Register\nlayer supports already read/write to registers (via frontdoor), and to \nmemories (frontdoor and backdoor). TLM 1.0 is implemented,\nput/get/analysis interfaces are done, and master/slave interfaces work. Initial\nimplementation of TLM2.0 has also been added. The table below summarizes the\nstatus:\n\n| Feature | Status |\n| --------- | ------ |\n| TLM1.0 | Done |\n| TLM2.0 | Done |\n| Components | Done |\n| Phases | Done |\n| Objections | Test and env-level objections work |\n| Sequences | Partially done, hier sequences work |\n| Registers | Reg/mem access working, built-in sequences partially done |\n\nPlease try it out, and let me know if\nsomething you require should be added, or even better, add it yourself, test it\nand create a pull request!\n\nHDL Simulators\n--------------\n\nTested with Icarus Verilog (iverilog v13.0 (devel)) and verilator (v5.008). The\nexact commit for iverilog can be found from `ci/install_iverilog.sh`.\n\nIcarus Verilog and verilator are free simulators, which can\nbe used with cocotb. uvm-python uses cocotb to interface with these simulators.\nMemory backdoor access has issues with packed multi-dimensional arrays in\nverilator. Also, some other examples are not working with verilator yet.\n\nProprietary simulators that work with cocotb should work with\nuvm-python as well, but haven't been tested.\n\nRelated projects\n----------------\n\n - [cocotb](https://github.com/cocotb/cocotb) cosimulation library for writing testbenches in Python\n - [uvm-python-verification-lib](https://github.com/jg-fossh/uvm-python-verification-lib) UVM Python Verification Agents Library\n",
"bugtrack_url": null,
"license": "Apache 2.0",
"summary": "uvm-python UVM implementation in Python on top of cocotb",
"version": "0.3.0",
"split_keywords": [
"uvm",
"systemverilog",
"verilog",
"rtl",
"coverage"
],
"urls": [
{
"comment_text": "",
"digests": {
"blake2b_256": "a9f83b0aed94e7e2503bf996e46c142e3b33d2744799bdf3b74697314bc2bb4e",
"md5": "e94883ede47d21185c7746e3872240ff",
"sha256": "6140808b069331b5aba96b337ddc7bf4cd0cf668935a0154a5f24db9fb5d0051"
},
"downloads": -1,
"filename": "uvm_python-0.3.0-py3-none-any.whl",
"has_sig": false,
"md5_digest": "e94883ede47d21185c7746e3872240ff",
"packagetype": "bdist_wheel",
"python_version": "py3",
"requires_python": ">=3.8",
"size": 593071,
"upload_time": "2023-03-29T17:07:45",
"upload_time_iso_8601": "2023-03-29T17:07:45.711728Z",
"url": "https://files.pythonhosted.org/packages/a9/f8/3b0aed94e7e2503bf996e46c142e3b33d2744799bdf3b74697314bc2bb4e/uvm_python-0.3.0-py3-none-any.whl",
"yanked": false,
"yanked_reason": null
},
{
"comment_text": "",
"digests": {
"blake2b_256": "063560f9fc85d8158777427cb36d1702cfdd6b1ec8def4dda9f174382ed18bd9",
"md5": "89e6e9a5040a7796125934654f7c90f8",
"sha256": "616ce8c2d6baf660c7693484abe318b6f0ac6880b95897f734649e588910b44b"
},
"downloads": -1,
"filename": "uvm-python-0.3.0.tar.gz",
"has_sig": false,
"md5_digest": "89e6e9a5040a7796125934654f7c90f8",
"packagetype": "sdist",
"python_version": "source",
"requires_python": ">=3.8",
"size": 2191158,
"upload_time": "2023-03-29T17:07:48",
"upload_time_iso_8601": "2023-03-29T17:07:48.795258Z",
"url": "https://files.pythonhosted.org/packages/06/35/60f9fc85d8158777427cb36d1702cfdd6b1ec8def4dda9f174382ed18bd9/uvm-python-0.3.0.tar.gz",
"yanked": false,
"yanked_reason": null
}
],
"upload_time": "2023-03-29 17:07:48",
"github": true,
"gitlab": false,
"bitbucket": false,
"github_user": "tpoikela",
"github_project": "uvm-python",
"travis_ci": true,
"coveralls": true,
"github_actions": true,
"lcname": "uvm-python"
}