Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > VHDL > Conditional declarations

Reply
Thread Tools

Conditional declarations

 
 
Colin Beighley
Guest
Posts: n/a
 
      07-20-2011
Hello,

I keep running across situations where a conditional variable or
signal declaration would be very useful in simulation (for instance,
declaring full range integers or reals), but I don't want any of these
to attempt to be synthesized. Is there an eloquent way of doing this?
I don't believe you can use the generate statement for declarations. I
have heard of people using the C preprocessor for this, but this seems
like a hack IMO.

Colin
 
Reply With Quote
 
 
 
 
Colin Beighley
Guest
Posts: n/a
 
      07-20-2011
On Jul 20, 11:14*am, Colin Beighley <(E-Mail Removed)> wrote:
> Hello,
>
> I keep running across situations where a conditional variable or
> signal declaration would be very useful in simulation (for instance,
> declaring full range integers or reals), but I don't want any of these
> to attempt to be synthesized. Is there an eloquent way of doing this?
> I don't believe you can use the generate statement for declarations. I
> have heard of people using the C preprocessor for this, but this seems
> like a hack IMO.
>
> Colin


Okay so I had a brain fart and forgot about --synthesis translate_off.
I've also looked into the archives and seen that it doesn't seem to be
supported for synthesis, though, except for within conditional
generate statements.
 
Reply With Quote
 
 
 
 
KJ
Guest
Posts: n/a
 
      07-20-2011
On Jul 20, 2:14*pm, Colin Beighley <(E-Mail Removed)> wrote:
> Hello,
>
> I keep running across situations where a conditional variable or
> signal declaration would be very useful in simulation (for instance,
> declaring full range integers or reals), but I don't want any of these
> to attempt to be synthesized. Is there an eloquent way of doing this?
> I don't believe you can use the generate statement for declarations. I
> have heard of people using the C preprocessor for this, but this seems
> like a hack IMO.
>


You can declare signals within a generate statement. Then set the
generate condition appropriately to not generate for synthesis.

if xxx generate
signal xyz_real: real;
begin
xyz <= to_real(xyz_fp);
end generate xxx;

Kevin Jennings
 
Reply With Quote
 
Colin Beighley
Guest
Posts: n/a
 
      07-21-2011
On Jul 20, 2:03*pm, KJ <(E-Mail Removed)> wrote:
> On Jul 20, 2:14*pm, Colin Beighley <(E-Mail Removed)> wrote:
>
> > Hello,

>
> > I keep running across situations where a conditional variable or
> > signal declaration would be very useful in simulation (for instance,
> > declaring full range integers or reals), but I don't want any of these
> > to attempt to be synthesized. Is there an eloquent way of doing this?
> > I don't believe you can use the generate statement for declarations. I
> > have heard of people using the C preprocessor for this, but this seems
> > like a hack IMO.

>
> You can declare signals within a generate statement. *Then set the
> generate condition appropriately to not generate for synthesis.
>
> if xxx generate
> * *signal xyz_real: *real;
> begin
> * *xyz <= to_real(xyz_fp);
> end generate xxx;
>
> Kevin Jennings


So I think the --synthesis translate_off/on statements will give me
the functionality I need for simulation vs synthesis, but a
conditional declaration of the #ifdef type would still be useful.
Signals declared in generate statements are limited in scope to their
generate statement, correct?
 
Reply With Quote
 
KJ
Guest
Posts: n/a
 
      07-21-2011
On Jul 21, 12:13*pm, Colin Beighley <(E-Mail Removed)> wrote:
> On Jul 20, 2:03*pm, KJ <(E-Mail Removed)> wrote:
>
>
>
>
>
> > On Jul 20, 2:14*pm, Colin Beighley <(E-Mail Removed)> wrote:

>
> > > Hello,

>
> > > I keep running across situations where a conditional variable or
> > > signal declaration would be very useful in simulation (for instance,
> > > declaring full range integers or reals), but I don't want any of these
> > > to attempt to be synthesized. Is there an eloquent way of doing this?
> > > I don't believe you can use the generate statement for declarations. I
> > > have heard of people using the C preprocessor for this, but this seems
> > > like a hack IMO.

>
> > You can declare signals within a generate statement. *Then set the
> > generate condition appropriately to not generate for synthesis.

>
> > if xxx generate
> > * *signal xyz_real: *real;
> > begin
> > * *xyz <= to_real(xyz_fp);
> > end generate xxx;

>
> > Kevin Jennings

>
> So I think the --synthesis translate_off/on statements will give me
> the functionality I need for simulation vs synthesis, but a
> conditional declaration of the #ifdef type would still be useful.
> Signals declared in generate statements are limited in scope to their
> generate statement, correct?- Hide quoted text -
>


Yes, the signals are limited in scope to being within the generate
statement. But that doesn't mean that they can't access things that
are outside of scope.

You asked for a conditional method to declare signals (and presumably
use them) for simulation but not synthesis. That's precisely what the
language itself can provide you with the generate statement. The
translate_off/on has some limitations:
- translate_off/on is not conditional 'as-is' (which would seem to
violate what you said you were looking for). People do play games
with how they write the text to accomplish their specific goals, but
it is always kludgy
- translate_off/on is a pragma that is embedded within a comment...so
it rightfully gets ignored by other tools. This implies that your
simulations will compile and run just fine, only when you run the
synthesis tool do you find that you have an 'off' without an 'on' or
typed 'translate off' or 'translate on' or some other simple
misspelling. They don't necessarily take long to clean up and fix,
but why bother when the generate statement is accepted by all tools
since it is part of the language and does what it appears that you
need? If it doesn't perhaps you should explain a bit more about how
the example I gave you doesn't meet your needs and we can go from
there.

About the only limitation of the generate statement I can think of is
that it is only applicable inside the architecture of an entity. In
particular it cannot be used in code that is in a package. There you
would have to use translate_off/on.

Kevin Jennings
 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Do you still use component declarations? Srinivasan Venkataramanan VHDL 3 09-19-2005 07:21 PM
? ELSE Conditional Comment / Using Conditional Comments Inside Other Tags To Comment Out Attributes Alec S. HTML 10 04-16-2005 02:21 AM
Pin declarations in EC/ECP FPGAs =?ISO-8859-1?Q?Andr=E9s?= VHDL 11 03-11-2005 05:35 AM
[VHDL] Comparing entity and component declarations M.D. van de Burgwal VHDL 3 10-07-2004 08:58 AM
Re: Procedure declarations: parameter lists with default values deep VHDL 0 04-15-2004 08:06 AM



Advertisments