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 to setup is about a 3 minute procedure…

Get the latest version of SVUnit from Sourceforge

  • Download the latest version of SVUnit from sourceforge by clicking the big blue button to the right.
  • Extract the SVUnit archive
    • Screen Shot 2013-06-03 at 4.29.40 PM
  • Source the SVUnit setup script (bash users source Setup.bsh. csh users source Setup.csh)
    • Screen Shot 2013-06-03 at 4.39.25 PM

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
  • create an SVUnit Makefile
    • Screen Shot 2013-06-03 at 4.27.51 PM
  • include one of the the simulator specific make files in your svunit.mk (could be vcs.mk, questa.mk or ius.mk)
    • Screen Shot 2013-06-03 at 4.42.24 PM
  • add a test to your unit test template using the SVTEST/SVTEST_END macros
    • Screen Shot 2013-06-03 at 4.28.08 PM
  • Run your new test!
    • Screen Shot 2013-06-03 at 4.28.19 PM

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.
Share/Bookmark

3 Responses to SVUnit Getting Started

  1. Tudor says:

    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!

    Cheers,
    Tudor

    • nosnhojn says:

      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 ;).

      -neil

  2. Simon Robidas says:

    hi Neil,

    The code above for bogus_unit_test.sv 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:

    `SVTEST_END

    Cheers,

    Simon

Leave a Reply

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

You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>