Monday, April 17, 2017

A Simple UVM Example for Beginners

Ref [1] is a very good UVM guide for beginners. Ref[2] provides source codes for the examples used in Ref [1]. Below are the steps to try the example out.

QuickStart to Run the Example
----------------------------------------
1. Create a simulation directory and let's use $SIMULATION to represent the directory.
2. Download the source codes for the example UVM codes from Ref [2] and extract it under $SIMULATION. This generates a directory of $SIMULATION/uvm-testbench-tutorial-simple-adder-master.
3. Create a directory $SIMULATION/uvm-src.
4. Download the UVM 1.2 or UVM 1.1d source codes from Ref [3] and extract it under uvm-src. This creates a directory of $SIMULATION/uvm-src/uvm-1.2 or $SIMULATION/uvm-src/uvm-1.1d.
5. Switch to the directory of $SIMULATION/uvm-testbench-tutorial-simple-adder-master.
6. If UVM 1.2 source code is used in step 4, we need to edit the UVM_HOME variable in the file of Makefile.vcs.

Change
UVM_HOME = ../uvm-src/uvm-1.1d
to
UVM_HOME = ../uvm-src/uvm-1.2

If uvm-1.1d was downloaded in step 4, we can skip this step.
7. Set up vcs environment so that vcs program can run.
8. Run "make  -f  Makefile.vcs


Add Waveform Dumping Feature
------------------------------------------
Ref [4] and Ref [5] are two good references of how to use vcs to dump waveform. Below are my working steps.

1. Added the following in the test-bench code of simpleadder_tb_top.sv.

`ifdef DUMP_FSDB
initialbegin
  $fsdbDumpfile("test.fsdb");
  $fsdbDumpvars;
end
`endif

2. In Makefile.vcs, added below options for vcs to compile the test-bench to do waveform dumping.

+define+DUMP_FSDB \
-P $(NOVAS_HOME)/share/PLI/VCS/LINUX/novas.tab $(NOVAS_HOME)/share/PLI/VCS/LINUX/pli.a \

NOTE:  The environment variable NOVAS_HOME was set to the path of the verdi install directory in my environment.

3. Run "make -f Makefile.vcs" again. The file test.fsdb is generated during the simulation and I can run "verdi -ssf test.fsdb" to view the waveform generated.

If removing "+define+DUMP_FSDB" option for vcs in step 2, then the code added in step 1 won't take effect and test.fsdb will not be generated.

Both Ref[4],[5] mentioned add $(NOVAS_INST_DIR)/share/PLI/lib/$(PLATFORM) as one of $LD_LIBRARY_PATH searching paths. But the experiment shows this is not needed.

References
-------------
1. https://colorlesscube.com/uvm-guide-for-beginners/
2. https://github.com/naragece/uvm-testbench-tutorial-simple-adder
3. http://accellera.org/downloads/standards/uvm
3. https://verificationacademy.com/cookbook/questa/compilinguvm
4. https://blogs.mentor.com/verificationhorizons/blog/2011/03/08/using-the-uvm-10-release-with-questa/
4. http://chanrui.blogspot.com/2012/03/verdi-and-vcs-cosim.html
5. http://www.cnblogs.com/lunix/archive/2011/03/20/vcs_and_verdi_cosim.html
6. https://github.com/hjking/mydotfiles/blob/master/vim/vim_wiki/eda/verdi/Linking_And_Dumping.wiki

No comments:

Post a Comment