Combining VUnit and UVVM
Combining VUnit and UVVM

Combining VUnit and UVVM

Adding OSVVM to a VUnit project is quite simple since OSVVM is included in VUnit as a sub-repository. If you want to use OSVVM features in a VUnit testbench, calling VUnit.add_osvvm() is all you have to do.

Adding UVVM to VUnit is much more complicated. UVVM is not directly included in VUnit and it consists of 20+ different libraries/components which have to be added to VUnit manually:

  • uvvm_util
  • uvvm_vvc_framework
  • bitvis_vip_scoreboard
  • bitvis_vip_avalon_mm
  • bitvis_vip_avalon_st
  • ...

There are two different ways to compile all these libraries and add them to a VUnit project:

  1. Precompile UVVM and add it to VUnit as external libraries
  2. Add UVVM sources to VUnit and let VUnit handle the compile step

Let's have a closer look at these two possibilities.

1. Precompile UVVM

UVVM includes a build system based on TCL scripts. To compile all UVVM components, run the script UVVM/scripts/compile_src.do. This script will place a library for each component next to the source directory of the component.

After compiling, you can add each component to VUnit as an external library:

from vunit import VUnit
VU = VUnit.from_argv()

VU.add_external_library(uvvm_util, "UVVM/uvvm_util/sim/uvvm_util")
VU.add_external_library(uvvm_vvc_framework, "UVVM/uvvm_vvc_framework/sim/uvvm_vvc_framework")
VU.add_external_library(bitvis_vip_scoreboard, "UVVM/bitvis_vip_scoreboard/sim/bitvis_vip_scoreboard")
VU.add_external_library(bitvis_vip_uart, "UVVM/bitvis_vip_avalon_mm/sim/bitvis_vip_avalon_mm")
...

2. Add UVVM sources to VUnit

Instead of precompiling UVVM using its compile script, you can add each library and its source files directly to VUnit. VUnit handles the compile order and UVVM is treated internally the same way as all other VHDL source files.

To do so, you have to find out which source files have to be added to which libraries. UVVM provides this information as .txt files. The file component_list.txt located at UVVM/script/ contains a list of all UVVM components:

uvvm_util
uvvm_vvc_framework
bitvis_vip_scoreboard
bitvis_vip_avalon_mm
bitvis_vip_avalon_st
bitvis_vip_uart
...
bitvis_vip_axi
bitvis_vip_spec_cov
bitvis_vip_wishbone

Some components have dependencies on each other. For example, all vip-components depend on uvvm_util and uvvm_vvc_framework. Some components also require bitvis_vip_scoreboard.

The source files of each component are located in a directory named after the component. Along with the source files, the file compile_order.txt lists all sources of a component in the correct compile order. Here is an example of this file for UVVM's UART component (located at /bitvis_vip_uart/script/compile_order.txt):

# library bitvis_vip_uart
../src/uart_bfm_pkg.vhd
../src/transaction_pkg.vhd
../src/vvc_cmd_pkg.vhd
../src/monitor_cmd_pkg.vhd
../../uvvm_vvc_framework/src_target_dependent/td_target_support_pkg.vhd
../../uvvm_vvc_framework/src_target_dependent/td_vvc_framework_common_methods_pkg.vhd
../src/vvc_methods_pkg.vhd
../../uvvm_vvc_framework/src_target_dependent/td_queue_pkg.vhd
../../uvvm_vvc_framework/src_target_dependent/td_vvc_entity_support_pkg.vhd
../src/uart_rx_vvc.vhd
../src/uart_tx_vvc.vhd
../src/uart_vvc.vhd
../src/uart_monitor.vhd
../src/vvc_context.vhd

Now that we know which files have to be added to VUnit, we can do so in the VUnit run script:

from vunit import VUnit
VU = VUnit.from_argv()

lib_uvvm_util = VU.add_library("uvvm_util")
lib_uvvm_util.add_source_files( "path/to/UVVM" / "uvvm_util" / "src" / "*.vhd")

lib_uvvm_vvc_framework = VU.add_library("uvvm_vvc_framework")
lib_uvvm_vvc_framework.add_source_files("path/to/UVVM" / "uvvm_vvc_framework" / "src" / "*.vhd")

lib_uvvm_scoreboard = VU.add_library("bitvis_vip_scoreboard")
lib_uvvm_scoreboard.add_source_files("path/to/UVVM" / "bitvis_vip_scoreboard" / "src" / "*.vhd")

lib_uvvm_uart = VU.add_library("bitvis_vip_uart")
lib_uvvm_uart.add_source_files("path/to/UVVM" / "bitvis_vip_uart" / "src" / "*.vhd")
lib_uvvm_uart.add_source_files("path/to/UVVM" / "uvvm_vvc_framework" / "src_target_dependent" / "*.vhd")

...

The above code can be shortened using the add_uvvvm_sources() function from the VUnit-helpers Python package. VUnit-helpers is a collection of functions that simplify the VUnit run script, resulting in a shorter and more readable script. You can install VUnit-helpers from PyPi (pip install vunit_helpers).

from vunit import VUnit
from vunit_helpers import add_uvvm_sources


VU = VUnit.from_argv()
add_uvvm_sources(VU, "path/to/UVVM", ["uvvm_util", "uvvm_vvc_framework", "bitvis_vip_scoreboard", "bitvis_vip_uart"])

If you want to add all components it's even simpler:

from vunit import VUnit
from vunit_helpers import add_uvvm_sources

VU = VUnit.from_argv()
add_uvvm_sources(VU, "path/to/UVVM")

Now the only difference to adding OSVVM is that the path of UVVM must be specified explicitly. And you still have to clone or download UVVM from Github.

To view or add a comment, sign in

Others also viewed

Explore content categories