Showing posts with label Verilog. Show all posts
Showing posts with label Verilog. Show all posts

Tuesday, August 25, 2009

Verilog Woes

As a language, Verilog is decent. It's a little too low level for my tastes, which is why I used to use Cryptol and now use my employer's fork of Cryptol called Quattro. Cryptol/Quattro allow us to write much more abstract, generic, and parametrized code, and to do so usually with no loss in performance.

Then there's the inconsistencies between simulation and synthesis tools, especially if your tools come from different companies. A language construct might be supported by your simulation tool but not your synthesis tool, or vice versa.

And then there's the case where your tool just does something batty. For example, lets say that I have an integer parameter P in module A, and I a string parameter P in module B, and I want to instantiate B inside A and have A's parameter determine B's parameter. So, I have something like this:
defparam B_inst.P = (P == 0) ? "TRUE" : "FALSE";
Fine and dandy right?

For whatever reason, my Verilog simulator decided that the two branches of the expression, the two strings, had to be the same length. So, it padded "TRUE" with a space at the beginning to become " TRUE". I did a lot of experimenting to verify that this is in fact what is happening. For example, if I change "FALSE" to a string of 4 characters when P is 0, it works fine.

Reblog this post [with Zemanta]

When to automate, abstract, generalize?

When you have a repetitive task to perform, at what point is it worth it to write a script to automate the task? When is it appropriate to abstract away the details? When should you write one highly parametrized function, and when should you write several specialized functions?

More importantly, how should you go about answering these questions beforehand so that you don't go down the wrong (i.e. inefficient) path?

At a conference a couple years ago I attended a talk that addressed some of these questions, but I do not really remember much about it...

I found myself dealing with all of these questions today. I had written some highly parametrized Verilog modules, but it was very tedious to support each variation. Furthermore, I ran into a bug in the simulator (described at the end of my next post), and I decided to circumvent the bug by splitting each module into a few specialized modules. I was then faced with the tedious task of factoring each module into its specialized variants, so I decided to write some elisp to do it for me.

So, in the end I found that I had made the wrong decision to implement parametrized modules, though I could not have predicted the ridiculous bug that I ran into and so was justified in the decision. I feel like writing the elisp to automate the rewrites of each module saved a lot of time, but I cannot really be sure.
Reblog this post [with Zemanta]