SVUnit Getting Started

Why SVUnit?

Good question. You’ll want to use SVUnit if you and your customers value defect free systemverilog code. Simple as that.

The SVUnit framework allows you to easily isolate modules, classes and/or interfaces in your designs and testbenches so you can kill bugs at a granularity that is most productive: the unit test level. It’s good for design and verification engineers. It’s also great for test-driven development if you care enough to prevent defects in the first place.

On the other hand, if your customers like buggy code or you don’t think defect free code is worth the effort, then SVUnit is not for you.

SVUnit Download and Setup


Download the Latest Version of SVUnit from GitHubDownload to setup is about a 3 minute procedure…


  • Download the latest version of SVUnit from GitHub by clicking the big blue button to the right.
  • Extract the SVUnit archive
    • Screen Shot 2016-05-06 at 10.46.08 AM
  • Source the SVUnit setup script (bash users source Setup.bsh. csh users source Setup.csh)
    • Screen Shot 2016-05-06 at 10.48.17 AM

Your First SVUnit Project

It’ll take you about another 2minutes to get a new project started…

    • Create and/or ‘cd’ to a new project directory
    • Start a unit-under-test (could be a class, interface or module)
      • Screen Shot 2013-06-03 at 4.27.31 PM
    • generate a new unit test template
      • Screen Shot 2013-06-03 at 4.27.44 PM
    • add a test to your unit test template using the SVTEST/SVTEST_END macros
      • Screen Shot 2014-08-29 at 12.37.36 PM
    • Run your new test with the simulator of your choice!
      • Screen Shot 2014-08-12 at 4.45.22 PM

SVUnit User Guide

For the full description of how to use SVUnit, you can check out the SVUnit User Guide.

SVUnit User Group Forum

To connect with other users, ask questions and share SVUnit experience, join the SVUnit User Group. Everyone is welcome!

Check Out the SVUnit Examples For More

For more elaborate examples of what you can do with SVUnit, check out these examples packaged with SVUnit…

    • examples/modules/apb_slave – an example for designers. This is a verilog APB slave module being verified with a set of simple read/write accessibility tests.
    • examples/uvm/simple_model – for verification engineers building UVM components, simple model is a simple (perfect) reference.
    • examples/uvm/uvm_express – this is a more elaborate example of building an UVM agent. You’ll find BFMs, monitors, coverage groups and an agent in this example with unit tests that take about 10 seconds to run. Don’t let the name fool you… uvm_express will help anyone using UVM!
    • uvm/uvm_report_mock – learn how to verify your uvm_error and uvm_fatal testbench checkers by using the UVM report mock scoreboarding.

11 thoughts on “SVUnit Getting Started

  1. Hi Neil,

    I must confess I had my doubts in the beginning with respect to using SVUnit. I thought it would be painful to set up and use. I finally got over them, installed it and started using it. I was very pleasantly surprised. It took very little effort to become productive. After getting more accustomed to unit testing I do plan on trying out TDD.

    Thanks a lot for the great library and keep up the good work!


    1. Great to hear that you’ve come around! I think we verification engineers have grown used to so I’m always a bit skeptical as well when people suggest they have something that’s easy to use. Nice to know people are finding SVUnit *actually* easy to use ;).


  2. hi Neil,

    The code above for results in a compile error with SVUnit version 2.8, since the macro definition for SVTEST_END does not call for a parameter (see /svunit-code/svunit_base/svunit_defines.svh, line 180). The second to last line of code should just read:




  3. Hi Neil,

    I tried it and test is failing with following error, looks like something related to perl package, could you please let me know what per version is required to run this example:

    Can’t locate File/ in @INC (you may need to install the File::Which module) (@INC contains: /global/freeware/Linux/2.6/perl-5.20.2/lib/site_perl/5.20.2/x86_64-linux /global/freeware/Linux/2.6/perl-5.20.2/lib/site_perl/5.20.2 /global/freeware/Linux/2.6/perl-5.20.2/lib/5.20.2/x86_64-linux /global/freeware/Linux/2.6/perl-5.20.2/lib/5.20.2 .) at /slowfs/vgvips23/uditk/client_space/svunit/svunit-code/bin/runSVUnit line 28.
    BEGIN failed–compilation aborted at /slowfs/vgvips23/uditk/client_space/svunit/svunit-code/bin/runSVUnit line 28

    1. udit, looks like your perl install is missing the File::Which module. I’m using perl5 but I’m pretty sure that module is packaged with older versions. 3 options… move to a newer version of perl, install File::Which and stick with the version you have, or you could comment out lines 28, 117-121 or runSVUnit. ‘which’ is only used to make sure the simulator you’ve chosen is in your PATH. so it’s a safety measure that runSVUnit will still run without. hope that helps!


  4. I ran into this as well, and worked around it by downloading File/Which from CPAN, then installing it locally, because I do not have root privileges thanks to corporate IT.

    I’m using Perl 5.10, but do not have the flexibility to upgrade to a later version, again due to corporate IT. As it turns out, this module is not part of our standard Perl distro.

    I think it would be nice if releases do not require additional dependencies that the user’s environment might not have, and would have to either install these on their own or hack the SVUnit code to make it work. Perhaps these dependencies can somehow be bundled with the SVUnit release, and the SVUnit setup could set the PERL5LIB to add its lib to the search path, saving the end user some time to set up.

    1. thanks manning. I’ll look into removing the File/Which and getting what I need some other way. rather than trying to guess at what people might need and package it with svunit, I think I better just keep it simple and remove anything that causes trouble. thanks for chiming in.


  5. Hi all,

    Unfortunately I run all my FPGA development flow in Windows 7 (not by choice).
    Is there a way to run svunit in Windows ?

    Thank you for the help you can provide,


    1. I’ve used SVUnit under cygwin, but the problem was always the define for the SVUnit version, that is a string containing a space character. Cygwin gets problems because of this. I always had to patch the distro to remove this from the run script.

      The usage of absolute paths was also rather annoying because the (Windows) simulator expects different styles of paths than what cygwin provides it, so I had to create a wrapper script that mangles the paths.

      Do as Neil suggested and open a question on the user group and I can post the stuff I have in there.

  6. Hi Neil,

    Where can I acces tutorial videos for SVUnit version 3.17?
    Also, Does it support simulator RivieraPRO? If so, do you have library support in order to use it with RivieraPRO?


Leave a Reply

Your email address will not be published. Required fields are marked *