Go Back   Velocity Reviews > Newsgroups > VHDL
User Name
Password
Register FAQ Members List Calendar Search Today's Posts Mark Forums Read

Reply

VHDL - generate statement inside a process (conditional variable declaration)

 
Thread Tools Search this Thread
Old 04-18-2007, 09:02 AM   #1
Default generate statement inside a process (conditional variable declaration)


Hello
I think it is not possible to use a generate inside the declarative
part of a process.
I would need it just now so it seems a good idea, but maybe it is not.
Any argument ?

Nicolas



Nicolas Matringe
  Reply With Quote
Old 04-18-2007, 12:51 PM   #2
Jonathan Bromley
 
Posts: n/a
Default Re: generate statement inside a process (conditional variable declaration)
On 18 Apr 2007 01:02:35 -0700, Nicolas Matringe <>
wrote:

>Hello
>I think it is not possible to use a generate inside the declarative
>part of a process.
>I would need it just now so it seems a good idea, but maybe it is not.
>Any argument ?


Nicolas,

I don't really see the problem. All variables are initialised
anyhow - to the 'LEFT value of their subtype - so surely it is
OK simply to create a generic that defaults to this value,
and use that generic as the initialiser?

entity Foo is
generic (initval: SOME_TYPE := SOME_TYPE'left);
port ....
end;
architecture A of Foo is
begin
process
variable V: SOME_TYPE := initval;
begin
end process;
end;

Now, if I leave the generic "initval" at its default
value, the process behaves exactly as though V had
no explicit initialisation.

Have I missed the point of your problem?

regards
--
Jonathan Bromley, Consultant

DOULOS - Developing Design Know-how
VHDL * Verilog * SystemC * e * Perl * Tcl/Tk * Project Services

Doulos Ltd., 22 Market Place, Ringwood, BH24 1AW, UK

http://www.MYCOMPANY.com

The contents of this message may contain personal views which
are not the views of Doulos Ltd., unless specifically stated.


Jonathan Bromley
  Reply With Quote
Old 04-18-2007, 01:11 PM   #3
Ben Jones
 
Posts: n/a
Default Re: generate statement inside a process (conditional variable declaration)

"Jonathan Bromley" <> wrote in message
news:...
> On 18 Apr 2007 01:02:35 -0700, Nicolas Matringe <>
> wrote:
>>I think it is not possible to use a generate inside the declarative
>>part of a process.
>>I would need it just now so it seems a good idea, but maybe it is not.
>>Any argument ?


> I don't really see the problem. All variables are initialised
> anyhow - to the 'LEFT value of their subtype - so surely it is
> OK simply to create a generic that defaults to this value,
> and use that generic as the initialiser?
>
> Have I missed the point of your problem?


I'm not sure what Nicolas's problem actually was, but I assumed that he
wanted to surround some declaration at the start of a process - for example
the declaration of some unwieldy variable - with an IF... GENERATE block so
that it's only created under certain conditions. I can see how that might
make certain code more efficient.

However, I can't think of anything that you actually *cannot* do unless you
have that feature.

It's entirely possible that I've missed the point as well. Probably in the
opposite direction. So on average, the problem is solved

-Ben-




Ben Jones
  Reply With Quote
Old 04-18-2007, 02:18 PM   #4
Andy
 
Posts: n/a
Default Re: generate statement inside a process (conditional variable declaration)
On Apr 18, 7:11 am, "Ben Jones" <ben.jo...@xilinx.com> wrote:
> "Jonathan Bromley" <jonathan.brom...@MYCOMPANY.com> wrote in message
>
> news:...
>
> > On 18 Apr 2007 01:02:35 -0700, Nicolas Matringe <nic_o_...@msn.com>
> > wrote:
> >>I think it is not possible to use a generate inside the declarative
> >>part of a process.
> >>I would need it just now so it seems a good idea, but maybe it is not.
> >>Any argument ?

> > I don't really see the problem. All variables are initialised
> > anyhow - to the 'LEFT value of their subtype - so surely it is
> > OK simply to create a generic that defaults to this value,
> > and use that generic as the initialiser?

>
> > Have I missed the point of your problem?

>
> I'm not sure what Nicolas's problem actually was, but I assumed that he
> wanted to surround some declaration at the start of a process - for example
> the declaration of some unwieldy variable - with an IF... GENERATE block so
> that it's only created under certain conditions. I can see how that might
> make certain code more efficient.
>
> However, I can't think of anything that you actually *cannot* do unless you
> have that feature.
>
> It's entirely possible that I've missed the point as well. Probably in the
> opposite direction. So on average, the problem is solved
>
> -Ben-


If there was a generate around the variable declaration, there would
also have to be one around the subsequent code that called it. Since
generate statements have their own declarative region, it would be
better to put the generate in the statement region, rather than one in
the declarative region and one in the statement region. Note that
generate statements are not currently allowed in ANY declarative
region either.

In sequential code there is very little need of a generate capability
that cannot be met with static conditions on if/case/loop statements,
that a decent optimizing compiler would not handle well anyway.

On the other hand, if a variable or constant had a complex, time-
consuming initialization (via a function call), compilers may not be
able to take that out just because it never gets used (due to static
conditions). In such a case, I'd be inclined to create separate
versions of the same process, each wrapped in a generate statement.
Perhaps through the use of common procedures and/or functions, the
amount of duplicate code in these process versions could be minimized.

Andy



Andy
  Reply With Quote
Old 04-18-2007, 04:12 PM   #5
Mike Treseler
 
Posts: n/a
Default Re: generate statement inside a process (conditional variable declaration)
Nicolas Matringe wrote:

> I think it is not possible to use a generate inside the declarative
> part of a process.
> I would need it just now so it seems a good idea, but maybe it is not.
> Any argument ?


If I have alternate or optional blocks of code,
I declare procedures in process scope.
These can be conditionally called after the BEGIN.

Sometimes I even preserve unused code this
way in case I change my mind. Unlike a commented
block of code, an uncalled procedure gets
analyzed at each compile.

-- Mike Treseler


Mike Treseler
  Reply With Quote
Old 04-19-2007, 08:38 PM   #6
Nicolas Matringe
 
Posts: n/a
Default Re: generate statement inside a process (conditional variable declaration)
On 18 avr, 13:51, Jonathan Bromley <jonathan.brom...@MYCOMPANY.com>
wrote:
> On 18 Apr 2007 01:02:35 -0700, Nicolas Matringe <nic_o_...@msn.com>
> wrote:
>
> >Hello
> >I think it is not possible to use a generate inside the declarative
> >part of a process.
> >I would need it just now so it seems a good idea, but maybe it is not.
> >Any argument ?

>
> Nicolas,
>
> I don't really see the problem. All variables are initialised
> anyhow - to the 'LEFT value of their subtype - so surely it is
> OK simply to create a generic that defaults to this value,
> and use that generic as the initialiser?

[...]
> Now, if I leave the generic "initval" at its default
> value, the process behaves exactly as though V had
> no explicit initialisation.
>
> Have I missed the point of your problem?


Well yes )

My problem was quite simple. I have an interrupt controller that must
handle interrupt priority (nothing fancy)
Now I am not sure what this priority must be because the documents I
have are not clear on this point. An easy way I have come up with was
to declare an std_logic_vector variable with ascending or descending
range, depending on the priority order (my priority decoder is hard-
coded because synthesis tool did not give me a fast enough result, it
is not possible to use a for ... loop)

Anyway I know I can use a for ... loop to revert my vector and make
this dependant on a generic but I also wanted to check if my idea was
good, bad, or utterly stupid.

Thank you all for your answers
Nicolas



Nicolas Matringe
  Reply With Quote
Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search

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

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

Similar Threads
Thread Thread Starter Forum Replies Last Post
Cisco VPN Restrict Access by IP ? samirise Hardware 1 12-16-2007 03:17 PM
Spoke to Spoke Enhanced Config (ASA-PIX) NEED HELP ASAP!! T-Mak Hardware 1 10-27-2006 11:56 AM




SEO by vBSEO 3.3.2 ©2009, Crawlability, Inc.

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46