Open side-bar Menu
 Real Talk
Jim Foley, Director of R&D, Real Intent
Jim Foley, Director of R&D, Real Intent
Jim Foley, prior to his role as R&D Director at Real Intent, was Head for Power Analysis Products at Sequence Design, and has held product management and development roles at Cadence Design Systems. Jim received a BS in Electrical Engineering from Worcester Polytechnic Institute. Go Engineers!

Ascent Lint Rule of the Month: MIN_ID_LEN

January 10th, 2013 by Jim Foley, Director of R&D, Real Intent

Some lint rules point out things that are probably wrong, something missing, or code that may not do what you intended. Others enforce naming and coding rules to make code more clear, consistent, and easier to maintain.  MIN_ID_LEN is in the later group. It checks all names in your design to make sure they are at least as long as the minimum length you specify, and reports when it sees a name that is too short.

How often have we written code like the following:

for (i = 0; i < N; i = i+1) …

This ubiquitous for statement works just as well in Verilog, SystemVerilog, C, and C++.  But consider what happens when the block that follows uses the variable ‘i’ several times, and then sometime later someone needs to search through it to find out what’s happening or to debug some problem.

When I write code for either hardware design or programming, I’ve developed the habit of using at least two characters for identifier names, as in:

for(ii =0; ii < NN; ii++)  …

This turns out to be very useful later on when I need to search for the identifier name.  If the variable is named “ii”, I can find it easily a text search. On the other hand, if the variable is ‘i’ and I search for that, I’ll find every ‘if’ statement, and likely more variables containing ‘i’ that are irrelevant to what I’m looking for. Blech.

Some coding policies require that every variable be given a meaningful name.  Most RTL designers can benefit from an exercise in creative writing. Ascent Lint doesn’t yet have an automated check to search names for meaning, but if “meaningful” requires that the name have at least four characters, that’s a job that Lint can do. Over time, I’ve come to appreciate maintaining code that avoids one-character names, but you can choose whatever length is sufficient to make your code maintainable.

If you’re building an ASIC that will take umpteen millions of dollars to fabricate, let alone to verify, adding that one extra key stroke is not too much to ask.  So make it a New Year’s resolution!  Try using double-character names or some other convention to avoid the single character search problem, and use MIN_ID_LEN to prevent this problem from causing trouble downsteam in your design and verification flow.

Related posts:

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>

CST Webinar Series
Verific: SystemVerilog & VHDL Parsers
TrueCircuits: IoTPLL

Internet Business Systems © 2016 Internet Business Systems, Inc.
595 Millich Dr., Suite 216, Campbell, CA 95008
+1 (408)-337-6870 — Contact Us, or visit our other sites:
TechJobsCafe - Technical Jobs and Resumes EDACafe - Electronic Design Automation GISCafe - Geographical Information Services  MCADCafe - Mechanical Design and Engineering ShareCG - Share Computer Graphic (CG) Animation, 3D Art and 3D Models
  Privacy Policy