Thought Leadership

Using the UVM libraries with Questa

by Rich Edelman and Dave Rich

Introduction

The UVM is a derivative of OVM 2.1.1. It has similar use model, and is run in generally the same way.

One significant change is that the UVM requires a DPI compiled library in order to enable regular expression matching, backdoor access and other functionality.

When running UVM based testbenches, we recommend using the built-in, pre-compiled UVM and DPI compiled libraries. This will remove the need to install any compilers or create a “build” environment.

One other issue to mention if you are converting from OVM to UVM, and if you use stop_request() and/or global_stop_request(), then you will need to use the following plusarg, otherwise your testbench will end prematurely without awaiting your stop_request().

vsim +UVM_USE_OVM_RUN_SEMANTIC +UVM_TESTNAME=hello …

Simulating with UVM Out-Of-The-Box with Questa

The UVM base class libiraries can be used out of the box with Questa 10.0b or higher very easily. There is no need to compile the SystemVerilog UVM package or the C DPI source code yourself. The Questa 10.0b release and every release afterwards contains a pre-compiled DPI library, as well as a pre-compiled UVM library. The only dependency is that your host system requires glibc-2.3.4 or later installed. Questa 10.0c Windows users only, please read this important note about the location of the DPI libraries.

You can easily use these steps:

vlib work
vlog hello.sv
vsim hello …

Notice that we don’t have to specify +incdir+$(UVM_HOME)/src,  $(UVM_HOME)/src/uvm_pkg.sv  to vlog, or add a -sv_lib command to the vsim command to load the uvm_dpi shared object.

Controling UVM Versions

Each release of Questa comes with multiple versions of the UVM pre-compiled and ready to load.  By default, a fresh install of Questa will load the latest version of UVM that is available in the release.  If an older version of UVM is needed, this version can be selected in one of two ways.

Modify the modelsim.ini File

Inside the modelsim.ini file, it contains a line which defines a library mapping for Questa.  That line is the mtiUvm line.  It looks something like this:

mtiUvm = $MODEL_TECH/../uvm-1.1b

This example is pointing to the UVM 1.1b release included inside the Questa release.  If we wanted to downgrade to UVM 1.1a, then we would simply modify the line to look like this:

mtiUvm = $MODEL_TECH/../uvm-1.1a

Command Line Switch

The Questa commands can also accept a switch on the command line to tell it which libraries to look for.  This switch overrides what is specified in the modelsim.ini file if there is a conflict.  The switch is ‘-L’.  If this switch is used, then all Questa commands with the exception of vlib will need to use the switch.

vlib work
vlog hello.sv -L $QUESTA_HOME/uvm-1.1a
vsim hello -L $QUESTA_HOME/uvm-1.1a ...

If you are using some other platform, or you want to compile your own DPI library, please follow the directions below.

If you use an earlier Questa installation, like 6.6d or 10.0, then you must supply the +incdir, and you must compile the UVM.

For example, with 10.0a on linux, you can do

vlib work
vlog hello.sv
vsim -c -sv_lib $UVM_HOME/lib/uvm_dpi …

if you use your own UVM download, or you use Questa 6.6d or 10.0 you need to do the following:

vlib work
vlog +incdir+$UVM_HOME/src $UVM_HOME/src/uvm_pkg.sv
mkdir -p $UVM_HOME/lib
g++ -m32 -fPIC -DQUESTA -g -W -shared
-I/u/release/10.0a/questasim//include
$UVM_HOME/src/dpi/uvm_dpi.cc
-o $UVM_HOME/lib/uvm_dpi.so
vlog +incdir+$UVM_HOME/src hello.sv
vsim -c -sv_lib $UVM_HOME/lib/uvm_dpi …

Building the UVM DPI Shared Object Yourself

If you don’t use the built-in, pre-compiled UVM, then you must provide the vlog +incdir+ and you must compile the UVM yourself, including the DPI library.

In $UVM_HOME/examples, there is a Makefile.questa which can compile and link your DPI shared object.

For Linux (linux):

cd $UVM_HOME/examples
setenv MTI_HOME /u/release/10.0a/questasim/
make -f Makefile.questa dpi_lib

> mkdir -p ../lib
> g++ -m32 -fPIC -DQUESTA -g -W -shared
>   -I/u/release/10.0a/questasim//include
>   ../src/dpi/uvm_dpi.cc -o ../lib/uvm_dpi.so

For Linux 64 (linux_x86_64)

cd $UVM_HOME/examples
setenv MTI_HOME /u/release/10.0a/questasim/
make LIBNAME=uvm_dpi64 BITS=64 -f Makefile.questa dpi_lib

> mkdir -p ../lib
> g++ -m64 -fPIC -DQUESTA -g -W -shared
>   -I/u/release/10.0a/questasim//include
>   ../src/dpi/uvm_dpi.cc -o ../lib/uvm_dpi64.so

For Windows (win32):

cd $UVM_HOME/examples
setenv MTI_HOME /u/release/10.0a/questasim/
make -f Makefile.questa dpi_libWin

> mkdir -p ../lib
> c:/QuestaSim_10.0a/gcc-4.2.1-mingw32vc9/bin/g++.exe
>   -g -DQUESTA -W -shared
>   -Bsymbolic -Ic:/QuestaSim_10.0a/include
>   ../src/dpi/uvm_dpi.cc -o
>   ../lib/uvm_dpi.dll
>   c:/QuestaSim_10.0a/win32/mtipli.dll -lregex

Note: For Windows, you must use the GCC provided on the Questa download page: (questasim-gcc-4.2.1-mingw32vc9.zip)

Save to /tmp/questasim-gcc-4.2.1-mingw32vc9.zip
cd $MTI_HOME
unzip /tmp/questasim-gcc-4.2.1-mingw32vc9.zip
<creates the GCC directories in the MTI_HOME>

Using the UVM DPI Shared Object

You should add the -sv_lib switch to your vsim invocation. You do not need to specify the extension, vsim will look for ‘.so’ on linux and linux_x86_64, and ‘.dll’ on Windows.

linux:

vsim -sv_lib $UVM_HOME/lib/uvm_dpi -do “run -all; quit -f”

linux_x86_64:

vsim -sv_lib $UVM_HOME/lib/uvm_dpi64 -do “run -all; quit -f”

win32:

cp $UVM_HOME/lib/uvm_dpi.dll .
vsim -sv_lib uvm_dpi -do “run -all; quit -f”

Running the examples from the UVM 1.1 Release

If you want to run the examples from the UVM 1.0 Release you need to get the Open Source kit – it contains the examples.

1. Download the UVM tar.gz and unpack it.

2. set your UVM_HOME to point to the UVM installation.

  • setenv UVM_HOME /tmp/uvm-<version#>

3. Go to the example that you want to run.

  • cd $UVM_HOME/examples/simple/hello_world

4. Invoke make for your platform:

  • For Windows (win32)
cd $UVM_HOME/examples/simple/hello_world
make DPILIB_TARGET=dpi_libWin -f Makefile.questa all
# Note: for windows, you need a "development area", with make, gcc/g++, etc. Using cygwin is the easiest solution
  • For Linux (linux)
cd $UVM_HOME/examples/simple/hello_world
make -f Makefile.questa all
  • For Linux 64 (linux_x86_64)
cd $UVM_HOME/examples/simple/hello_world
make BITS=64 -f Makefile.questa all

Migration from OVM to UVM

An OVM design can be migrated to UVM using a script. Many OVM designs can work without any hand coded changes or other intervention. It is a good idea to first get your design running on the latest version of OVM 2.1.2, before starting the migration process.

These designs can be converted from OVM to UVM using the distributed conversion script:

cd $MY_TEST_BENCH
$UVM_HOME/bin/ovm2uvm

In certain cases hand coded changes might be required.

Using the ovm2uvm script, you can run a “dry run” try and see what must be changed. There are many options to the script. Before using it, you should study it carefully, and run it in ‘dry-run’ mode until you are comfortable with it. In all cases, make a backup copy of your source code, before you use the script to replace-in-place.

By default it does not change files.

Here is a simple script which copies the ovm code, then applies
the script.

# Copy my ovm-source to a new place.
(cd ovm-source; tar cf – .) | (mkdir -p uvm-source; cd uvm-source; tar xf -)

# Do a dry-run
$UVM_HOME/bin/ovm2uvm.pl -top_dir uvm-source

# Examine the *.patch file
….

# If satisfied with the analysis, change in place
$UVM_HOME/bin/ovm2uvm.pl -top_dir uvm-source -write

If you are migrating to the UVM from OVM, you are NOT required to use this script, but you must do a conversion by some means.

Once your OVM design is converted to UVM, you are almost ready to run.

The UVM requires that you use some DPI code. Additionally, the UVM defines a different semantic for run(). If you are using an OVM design converted to UVM, and you use stop_request() or global_stop_request(), then you need to add a switch:

vsim +UVM_USE_OVM_RUN_SEMANTIC +UVM_TESTNAME=hello …

In order to NOT use this switch, you need to change your OVM design. You need to NOT use stop_request() or global_stop_request(). You should cause your test and testbench to be controlled by raising objections as the first thing in your run tasks, and then lowering your objections where you previously had your stop requests.

More information about migrating from OVM to UVM can be found in the Verification Academy Cookbook (registration required).

 

Dave Rich

Dave Rich is Verification Technologist at Mentor Graphics and is one of the authors of Mentor’s Advanced Verification Methodology cookbook. He began his career as a design and verification engineer in 1981 at Data General. In 1987, he joined Gateway Design Automation as one of the first application engineers to support Verilog-XL. At Gateway, he helped design many of the early features of the Verilog Hardware Description Language (HDL), and after Cadence acquired Gateway, helped prepare the Language Reference Manual (LRM) that would eventually be donated to the newly formed Open Verilog International. In 1995, he joined another Verilog simulation company, Frontline Design Automation as an AE manager and later as a Product Manager after it was acquired by Avant!. In 1998, he joined Ambit Design and worked as a consulting engineer for both synthesis and simulation products after it was acquired by Cadence. In 2000, he joined Co-Design Automation as Director of Application Engineering where the Superlog HDL was being developed that eventually became the basis of the Accellera SystemVerilog 3.0 standard. Co-Design Automation was acquired by Synopsys in 2002. Dave began work on numerous technical committees within Accellera and later the IEEE P1800 working group, which he continues today.

More from this author

Comments

34 thoughts about “Using the UVM libraries with Questa
  • localhost% /work/sv/uvm-1.0p1/examples>make -f Makefile.questa dpi_lib
    mkdir -p /work/sv/uvm-1.0p1/lib
    g++ -m32 -fPIC -DQUESTA -g -W -shared -I/asic/ssg_vol2/modeltech/questa6_4a/questasim/include /work/sv/uvm-1.0p1/src/dpi/uvm_dpi.cc -o /work/sv/uvm-1.0p1/lib/uvm_dpi.so
    In file included from /work/sv/uvm-1.0p1/src/dpi/uvm_dpi.cc:30:
    /work/sv/uvm-1.0p1/src/dpi/uvm_hdl.c: In function `int uvm_hdl_set_vlog(char*, t_vpi_vecval*, PLI_INT32)’:
    /work/sv/uvm-1.0p1/src/dpi/uvm_hdl.c:234: error: `vpi_release_handle’ was not declared in this scope
    /work/sv/uvm-1.0p1/src/dpi/uvm_hdl.c: In function `int uvm_hdl_get_vlog(char*, t_vpi_vecval*, PLI_INT32)’:
    /work/sv/uvm-1.0p1/src/dpi/uvm_hdl.c:294: error: `vpi_release_handle’ was not declared in this scope
    /work/sv/uvm-1.0p1/src/dpi/uvm_hdl.c:311: error: `vpi_release_handle’ was not declared in this scope
    /work/sv/uvm-1.0p1/src/dpi/uvm_hdl.c: In function `int uvm_hdl_check_path(char*)’:
    /work/sv/uvm-1.0p1/src/dpi/uvm_hdl.c:341: error: `vpi_release_handle’ was not declared in this scope
    make: *** [dpi_lib] Error 1

    What’s wrong here?

  • Hi,
    I am trying to use uvm-1.0p1 with 10.0b. Can you please specify steps?
    I used uvm_1.0 with 10.0a and everything was working OK.

    Now I am getting the following

    Warning: (vsim-3747) Failed to find user-specified function ‘uvm_hdl_check_path’ in DPI search list ….
    …………………………….
    Fatal: (vsim-160) …10.0b/verilog_src/uvm-1.0p1/src/dpi/uvm_svcmd_dpi.svh(27): Null foreign function pointer encountered when calling ‘dpi_get_next_arg_c’

    Thanks in advance

  • You need a SupportNet account to see the document. Basically it says the DPI library was placed in the wrong location in the distribution and you need to move or link it to the correct location.

  • Hi Dave,
    I am trying to run UVM 1.1 on Questa 10.0c and am facing the same issue. Just like “orenieru” I am also seeing that “important link” says “broken link”. Where is this uvm_dpi.so supposed to be in the install dir? And more importantly what is the final use model to use the pre-compiled DPI for UVM 1.1?

    Thanks
    Srini
    http://www.cvcblr.com

  • BTW, quick update – a simple find command on Cygwin (Windows) revealed no results for uvm_dpi.so, so am I supposed to compile it? Will the 10.0c1 relelase have the fix?

    Thanks

  • How to resolve error in simulating UVM1.1 W7(64-bit ) Questasim10.0c even installed gcc-4.2.1-mingw32vc9.

    ** Fatal: (vsim-7019) Can’t locate a C compiler for compilation of DPI export tasks/functions.
    #
    # Time: 0 ns Iteration: 0 Unknown: File: UNKNOWN
    # FATAL ERROR while loading design

  • Make sure you are using the 32-bit version of Questa (recommended anyways because 32-bit mode is faster) with a 32-bit compiler. Did you put the compiler on your system path?

  • Hi ,

    I am getting error with uvm-1.1d with questa 10.0b
    make DPILIB_TARGET=dpi_libWin -f Makefile.questa all
    mkdir -p ../../../lib
    /cygdrive/c/questasim_10.0b//gcc-4.2.1-mingw32vc9/bin/g++.exe -g -DQUESTA -W -shared -Bsymbolic -x c -I/cygdrive/c/questasim_10.0b//include ../../../src/dpi/uvm_dpi.cc -o ../../../lib/uvm_dpi.dll /cygdrive/c/questasim_10.0b//win32/mtipli.dll -lregex
    In file included from ../../../src/dpi/uvm_dpi.cc:34:
    ../../../src/dpi/uvm_regex.cc:26:22: error: vpi_user.h: No such file or directory
    In file included from ../../../src/dpi/uvm_dpi.cc:34:
    ../../../src/dpi/uvm_regex.cc: In function ‘uvm_re_match’:

  • I am trying to simulate the examples with Questasim 10.0c. I can compile ok but when I try to simulate I get a lot of error messages like the following

    ** Warning: (vsim-3770) Failed to find user specified function ‘uvm_hdl_check_path’. The search list was empty.
    # Using -sv_lib, -sv_root, and -sv_liblist arguments can provide a search list
    # of shared libraries that will be used to resolve user specified functions.
    # Time: 0 ns Iteration: 0 Instance: /hello_world File: D:/HDS/uvm/examples/simple/hello_world/hello_world.sv

    # ** Warning: (vsim-3770) Failed to find user specified function ‘uvm_hdl_deposit’. The search list was empty.
    # Using -sv_lib, -sv_root, and -sv_liblist arguments can provide a search list
    # of shared libraries that will be used to resolve user specified functions.
    # Time: 0 ns Iteration: 0 Instance: /hello_world File: D:/HDS/uvm/examples/simple/hello_world/hello_world.sv

    # ** Warning: (vsim-3770) Failed to find user specified function ‘uvm_hdl_force’. The search list was empty.
    # Using -sv_lib, -sv_root, and -sv_liblist arguments can provide a search list
    # of shared libraries that will be used to resolve user specified functions.

    Can anyone give me a solution?

    Thanks

  • Am very new to UVM and stuck with this error.. please help in sloving this.

    ** Error: pci_package.sv(27): near “endpackage”: syntax error, unexpected endpackage, expecting function or task
    make: *** [comp] Error 2

  • hi dave,
    i am trying to stimulate questasim 10.1c but i am getting the error as “failed to find user specified function ‘uvm_hdl_check_path’ in DPI C/C++ source ” . .thanks in advance

  • while compiling the UVM based testbench, Questa sim 10.2 tool gave these mesages as “unexpected signal 11 error” . please suggest us, why we are getting error.

  • after read this note ,, still I failed to run ubus example exist in uvm kit developed by accellera ,, shall you derive me the nested steps to do this so as to know my mistakes ,,,

  • while compilation in questa 10.0b, I am getting a warning:
    # ** Warning: (vsim-8607) G:/projects/work/spi_top.v(120): Non-positive replication multiplier inside concat. Replication will be ignored.

    How to remove this.
    Thanks.

  • Hi all,

    i’m using ModelSim 10.1c to simulate an UVM code using UVM 1.1b, i got the following fatal error:

    vl_unpack_regbit: Cannot handle type

    what does it mean?

  • Hello sir,
    I’m using questa sim 10.0b in windows 8.1 but when i gave make run_test it’s shows make is not recognized as an int. Or extnl command. Please to me to how this problem overcome

  • Hi
    Can anybody tell how to utilize UVM 1.2 package in questasim 10.0b
    Please help me out in the complete steps that i need to follow for using UVM package.
    thanks in advance

  • Pingback: Skidson

Leave a Reply

This article first appeared on the Siemens Digital Industries Software blog at https://blogs.stage.sw.siemens.com/verificationhorizons/2011/03/08/using-the-uvm-10-release-with-questa/