当前位置: 首页 > 工具软件 > WEC-Sim > 使用案例 >

linux下搭建uvm环境,转:使用QuestaSIM进行UVM仿真环境搭建

田普松
2023-12-01

使用QuestaSIM进行UVM仿真环境搭建

(Using the UVM libraries with Questa)

注意: 直到目前的questaSim 10.1版本(2012-01-31)为止,仍旧不能支持win64环境下的UVM编译,所以如果您要确定使用UVM环境,则不要使用X64版本的Windows操作系统。

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.0 release 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 -c hello …

If you are using some other platform, or you want to compile your own DPI library, please follow the directions below. The text above describes using Questa 10.0b in a way that reduces the need for +incdir+ and compiling the UVM itself. This capability is built-in to 10.0b and following releases.

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

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.1 Release you need to get the Open Source kit – it contains the examples.

Download the uvm-1.1.tar.gz and unpack it.

); background-attachment: initial; background-origin: initial; background-clip: initial; background-color: initial; background-position: 3px 6px; background-repeat: no-repeat no-repeat; ">Go to the Accellera website and download the “UVM 1.1 class library code and user guide”

set your UVM_HOME to point to the UVM 1.1 installation.

); background-attachment: initial; background-origin: initial; background-clip: initial; background-color: initial; background-position: 3px 6px; background-repeat: no-repeat no-repeat; ">setenv UVM_HOME /tmp/uvm-1.1

Go to the example that you want to run.

); background-attachment: initial; background-origin: initial; background-clip: initial; background-color: initial; background-position: 3px 6px; background-repeat: no-repeat no-repeat; ">cd $UVM_HOME/examples/simple/hello_world

Invoke make for your platform.:

); background-attachment: initial; background-origin: initial; background-clip: initial; background-color: initial; background-position: 3px 6px; background-repeat: no-repeat no-repeat; ">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

); background-attachment: initial; background-origin: initial; background-clip: initial; background-color: initial; background-position: 3px 6px; background-repeat: no-repeat no-repeat; ">For Linux (linux)

cd $UVM_HOME/examples/simple/hello_world

make -f Makefile.questa all

); background-attachment: initial; background-origin: initial; background-clip: initial; background-color: initial; background-position: 3px 6px; background-repeat: no-repeat no-repeat; ">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).

 类似资料: