Wednesday, April 30, 2014

A Quick Look at svlib

I just took a quick look at svlib from Verilab.  Very cool.  It's a library for SystemVerilog that gives you file globbing, regular expressions, a better string class, simple ini config file parsing (with yaml support promised for the future!), and more.  It was announced back in March and it took me this long to getting around to reading about it.  Hopefully it doesn't take me that long to actually try it out :-)

They welcome feedback so brace yourself, here it comes.  First of all it's open source (Apache license) which is excellent.  It's open source and it has documentation.  Amazing!  :-)  It is not currently developed openly though.  Could we get a github, bitbucket, or sourceforge project going?  Our industry (design verification) desperately needs to admit and recognize that we are software developers.  I mean no, we are verifiers!  Bug finders!  It just so happens that writing software is the primary technique we use to verify designs and find bugs (hence the need for svlib).  We need to get better at writing software.  Open Source projects are a great way for us to help each other develop those skills.  The paper and presentation talk about the trade-offs and design considerations that were considered by the svlib authors as they wrote svlib.  How much better would it be for all of us to be able to see and participate in the discussions that led to the particular design of something like svlib?

Second item of feedback.  Recommending people do an import svlib_pkg::* is no surprise, but it's still bad.  C++ and Python programmers long ago realized how bad their equivalents are: using namespace and from import *.  We SystemVerilog programmers need to realize this too.  Brian Hunter makes the case for SystemVerilog in his seminal Namespaces, Build Order, and Chickens video.  You can see the reasoning for C++ and Python all over the internet.  As I have made this argument people have pointed out how awkward the alternative svlib_pkg::foo looks in your code.  A big thing that would help with that is to drop the _pkg suffix.  We don't need that suffix, it's like doing this. svlib::foo is not that bad and clearly shows exactly where foo came from.

Third item of feedback.  It was bold and probably justified to put this all together in a single library named svlib.  It probably simplified some things and expedited getting the code working and out the door.  Those are good things.  Long-term though, I think we'll be better served if this were split into multiple smaller libraries.  Maybe one for regexes alone, one for os/system interactions, one for ini parsing, and so forth.  Python and its libraries are good examples to follow here.  If you make the project open I promise to help out with this where I can and I'm sure others would too.

Those concerns aside, svlib is a great thing to happen to the SystemVerilog community and hopefully just the start of better things to come.  Collaboration and sharing of libraries and tools like this will help our entire industry grow and and progress.