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.

Comments

Chiggs said…
Pretty much a +1 for all your feedback points from me.

The industry "best-practice" of habitual namespace pollution really irks me. The mindset also seeps into software written by HW engineers!
Anonymous said…
Bryan,

First, thanks a ton for taking the trouble to look at svlib and to raise these interesting issues. I really appreciate it; svlib was created in response to my own frustration with SV's inflexibility in certain areas, and I had hoped that others would find at least the core concept attractive, but there's been (to me) surprisingly little response.

In essence you raise three key points. I'm quite sure that if you were to start picking over the details you would find much more to take issue with - there's plenty in there that I'm less than proud of - but let's stick with your specific comments at this stage.

First, you suggest that the project should be opened on sourceforge or the like. Verilab has put a number of projects on bitbucket in the past, and we aim to do the same with svlib in due course. Open collaborative development is a fine aim. But I, personally, am not ready for it yet. I have some very strong opinions about the shape such a library should take, and I truly don't know how to shepherd or manage a collaborative project without jeopardising that vision. As soon as I have a design of svlib that I'm truly happy with, I will be more than willing to open the development to others who are likely to be far more skilled in implementation than I. This position probably sounds arrogant or selfish, and you must form your own judgment about that. The reality, though, is that I (foolishly?) committed to publishing svlib at DVCon in March, and I ran out of time to complete the specification to the level of maturity that I wanted. I have promised to make a much more mature release before very long, and as soon as that is done I shall open the whole thing on bitbucket.

Second, you raise the old problem of wildcard package import. This question (and other closely related problems) exercised me mightily as I was planning svlib. In principle, in the abstract, I totally agree with you. However, svlib's avowed aim was to provide the most natural possible API for typical SV users. The use of the suffix "_pkg" to denote a package, for example, is now a very deeply ingrained SV idiom, legitimized by many published packages such as UVM. Fighting that idiomatic usage would have been a lost cause for a small minority project such as this. In a similar way, I recommended wildcard import in the notes because it is easy and familiar; sophisticated users are always free to use fully qualified names if they prefer. I have no defence against the accusation that this was a feeble capitulation, but sometimes pragmatism (and sensitivity to the mindset of one's target audience) is appropriate.

Finally, you question the decision to put everything in a single package. Clearly this decision gives rise to problems of scale, and (like the package naming and import problem) it's a question that cost me quite a lot of sleep as I planned svlib. However, I believe I've at least partly alleviated the problems by coralling most of the interesting functionality in classes, using static methods where appropriate. This decision means that users who care about such things can, for example, do all their regex processing by importing only the Str and Regex classes from svlib if they so wish. My hope was that this architecture could go some way towards alleviating Chris Higgs's complaint about namespace pollution, which concerns me too, while also admitting a use model that will be more familiar to typical SV users.

So, after all that somewhat defensive prattle, the executive summary is: guilty as charged, but I'm not trying to change the world; I'm just aiming to make it a slightly more comfortable place to live. I'll leave the crusading to others who are better qualified and more articulate about it.

Once again, thanks for your interest and I hope I'll be able to deal with at least some of your concerns in the upcoming release (which I'm afraid I can't give a date for just yet, the day job somewhat getting in the way!).
Bryan said…
Great comments, Jonathan. This is exactly the kind of dialog that we can all benefit from that I was talking about in my reasons for putting this on bitbucket or sourceforge or whatever. It's always great to hear engineers explain *why* they did something the way they did (and concerning if they have no reason why...).

I completely understand not wanting to open up the development to the general public until you get it cleaned up a bit. I wouldn't call that arrogance, but maybe, taking pride in your work. Just don't spend *too* much time trying to make it completely perfect before going public :-)

On why you haven't seen much interest yet, here's my story. About a year ago I wrote 346 lines of SystemVerilog code for printing out a nice ascii-art table of debug information with columns that adjust width according to the information that is in each column. The output is beautiful (if I do say so myself) but the code to generate it is...tedious. I have a feeling that svlib's String methods would have made that a whole lot easier and I'd love to try rewriting it to find out. The problem is, it works and I have other things to get done now. Someday soon I'll have a good excuse to try svlib (I'm pretty good at coming up with excuses to try new things), but it just hasn't happened yet.
Tudor Timi said…
It's nice to see more momentum building up in the SV open source landscape. I for one hope for more now that SV 2012 is out and getting more popular.

Having the new "implements" and "interface class" features opens up the door to a rich collection of libraries the likes of Java's or C++'s. Hopefully there will be no more need for huge monolithic libraries like UVM that try to do everything...

Libraries could be more focused and users would be able to use the right one for the right job. UVM could then focus only on core verification aspects instead of on providing container objects, file handling, message processing, etc. (basically what they've been working on for the 1.2 release).
Unknown said…
This comment has been removed by the author.
Unknown said…
This comment has been removed by the author.
Unknown said…
Trying svlib is easy. It is available on EDA Playground: http://www.edaplayground.com/x/Uk

Popular posts from this blog

SystemVerilog Fork Disable "Gotchas"

'git revert' Is Not Equivalent To 'svn revert'

Git Rebase Explained