Re: [vhdl-200x] conditional compilation proposal

From: Evan Lavelle <>
Date: Tue Aug 16 2011 - 10:44:26 PDT

On 16/08/2011 17:31, Higgs, Chris wrote:

> If generate were extended to support sequential statements this use case
> could be satisfied? Assuming of course that we solve the issue of
> allowing "tools to provide information in the form of predefined
> variables"...

I think the generate discussion is something of a red herring - we might
just as well be talking about if/else; there's nothing special about
generate. The specific issue in my code example, and lots of similar
examples, is the static evaluation of a condition.

D does precisely this (I think this is unique to D; I'm not sure). What
they call "conditional compilation" is controlled by (among other
things) a "static if"; see There's also a static
assert to handle #error.

It doesn't introduce a new scope (good), but excluded code must still be
valid (bad; "conditional compilation" is clearly not a good name in this
case). There's also a nesting comment to completely exclude code.

One downside is that there's no way to get arbitrary conditions in from
the command line. The conditions are largely predefined (version levels,
debug conditions, that sort of thing), together with the 'static if'
bit: conditions which can be evaluated at compile time. See also, to compare the D way
against C/C++.

How much better this is that the old pre-processor view is debatable -
you need to read their comparison keeping in mind that they're trying to
sell their language. One other thing that you need to keep in mind is
that the term "pre-processor" is certainly pejorative. People see it,
and they turn off. In practice, nobody needs to know that there's an
invisible first stage of translation, built into the compiler. The real
issue, which is much harder to grasp, is that "pre-processor"
functionality requires the use of special tokens (ie. '#') to allow a
dumb first stage to *really* exclude code from compilation. An
alternative is to use nesting comments, which have their own issues, as
you suggested, and as D has with /+...+/, but this only handles #if(0).

So, at one level, this could be a discussion on whether this should be
done the C way, or the D way. My own take is that VHDL is an old
language, and grafting on D-style functionality is not really
appropriate at this stage. If you're going to go to this sort of
trouble, your time would be (much) better spent defining a new language.
Grafting on C-style functionality is not really appropriate either,
except for the obvious fact that people have spent a lot of time asking
for it, and implementing conditional compilation as a pre-processor is
relatively easy, and has the minimum impact on existing tools. It is
also what the users know about, and it gives a handle on Unicode support.


This message has been scanned for viruses and
dangerous content by MailScanner, and is
believed to be clean.
Received on Tue Aug 16 10:45:06 2011

This archive was generated by hypermail 2.1.8 : Tue Aug 16 2011 - 10:45:25 PDT