Friday, August 2, 2013

SVUnit Upgrade

Being a relatively early adopter of svunit (for unit testing SystemVerilog code), I had a fair amount of code written to work with the early 0.X versions of svunit. The maintainers of svunit have made some good progress and are now on version 2.3 (as of writing this). My old tests don't work with the new version of the framework, but I figured out how to update them. Just in case anyone else is in the same predicament, I will share the steps I took to fix things:

  • In the *_unit_test.sv file:
    1. remove typedef class c_<UUT>_unit_test
    2. keep the module <UUT>_unit_test declaration, but delete everything in the module except for the string name… and any interface declarations you may have added
    3. delete the c_<UUT>_unit_test class declaration
    4. add svunit_testcase svunit_ut; under the string name…
    5. Now that this is a module and not a class, tasks and functions declared in here might need to have the automatic keyword added to the declaration in order to behave the same
    6. change function new… to function void build();
    7. change super.new(name); to svunit_ut = new(name);
    8. inside task setup, change super.setup(); to svunit_ut.setup();
    9. inside task teardown, change super.teardown(); to svunit_ut.teardown();
    10. remove (<testname>) from all `SVTEST_END macros (it no longer takes an argument)
    11. change last line of file from endclass to endmodule

That should be it.