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

Reply

VHDL - Generic in CASE choice ?!?

 
Thread Tools Search this Thread
Old 04-28-2005, 07:53 AM   #1
Default Generic in CASE choice ?!?


Hello,

is it allowed to use a generic within a choice line of a CASE statement?

case "signal"
when "constant" =>
....
when "constant" to "constant" + "generic_value" =>
....
when others =>
....
end case;

ModelSIM (PE 6.0b) gives me the warning:

** Warning: ../SRC/RTL/arch_ADRDEC.vhd(1977): Case choice must be a locally
static expression.

Best regards,

Thorsten


Thorsten Bunte
  Reply With Quote
Old 04-28-2005, 11:05 AM   #2
Taras_96
 
Posts: n/a
Default Re: Generic in CASE choice ?!?
Hi

I've got a similar question, so I'll post it here, and maybe two birds
can be killed with one stone.

I have a bunch of constants:

constant NU_OPERATIONS : unsigned := "011";
constant FINAL_STATE : unsigned := NU_OPERATIONS + 1;
constant FIRST_STATE : unsigned := FINAL_STATE + 1;
constant INIT_STATE : unsigned := FIRST_STATE + 1;

I can not use FINAL_STATE or FIRST_STATE in any case expressions,
because I get a "Choice FIRST_STATE is not a locally static
expression."

I've read a number of bulletin board posts on the topic, but am still a
bit confused. Are the expressions not locally static because the
compiler need not evaluate the right hand side of the expressions
(doesn't have to add '1')?

"Unfortunately, the value of constant c_CS0Part is not
locally static as aggregates are not locally static (i.e. the
compiler doesn't have to evaluate the aggregate
expression at compile time)." -
http://groups-beta.google.com/group/...c9cac9fcf2c025

Furthermore, if I was to make NU_OPERATIONS a global constant, what
hope would there be in using it in a CASE statement?

These restrictions to me seem to be quite uneccesary, especially when
considering that constants are often defined with relation to other
constants, and are used globally - am I doomed to using an ugly if/else
statement?

Thanks

Taras



Taras_96
  Reply With Quote
Old 04-28-2005, 05:44 PM   #3
Andy Peters
 
Posts: n/a
Default Re: Generic in CASE choice ?!?
Taras_96 wrote:

> I have a bunch of constants:
>
> constant NU_OPERATIONS : unsigned := "011";
> constant FINAL_STATE : unsigned := NU_OPERATIONS + 1;
> constant FIRST_STATE : unsigned := FINAL_STATE + 1;
> constant INIT_STATE : unsigned := FIRST_STATE + 1;
>
> I can not use FINAL_STATE or FIRST_STATE in any case expressions,
> because I get a "Choice FIRST_STATE is not a locally static
> expression."
>
> I've read a number of bulletin board posts on the topic, but am still

a
> bit confused. Are the expressions not locally static because the
> compiler need not evaluate the right hand side of the expressions
> (doesn't have to add '1')?
>
> "Unfortunately, the value of constant c_CS0Part is not
> locally static as aggregates are not locally static (i.e. the
> compiler doesn't have to evaluate the aggregate
> expression at compile time)." -
>

http://groups-beta.google.com/group/...c9cac9fcf2c025
>
> Furthermore, if I was to make NU_OPERATIONS a global constant, what
> hope would there be in using it in a CASE statement?
>
> These restrictions to me seem to be quite uneccesary, especially when
> considering that constants are often defined with relation to other
> constants, and are used globally - am I doomed to using an ugly

if/else
> statement?


I think it is kind of odd that a constant plus a constant, evaluated at
compile time, isn't considered locally static; however, I think a
better solution to your problem is to simply use an enumerated type for
your case constants. this is actually the standard way of specifying
the states in a state machine, which I gather is your goal.

-a



Andy Peters
  Reply With Quote
Old 04-28-2005, 05:59 PM   #4
Mike Treseler
 
Posts: n/a
Default Re: Generic in CASE choice ?!?
Thorsten Bunte wrote:

> ** Warning: ../SRC/RTL/arch_ADRDEC.vhd(1977): Case choice must be a locally
> static expression.


This has been discussed here.
http://groups-beta.google.com/groups...tic+expression

-- Mike Treseler


Mike Treseler
  Reply With Quote
Old 04-29-2005, 11:37 AM   #5
Taras_96
 
Posts: n/a
Default Re: Generic in CASE choice ?!?
Hi

There are two problems with this approach for my particular problem.

(1) The first 'n' states will correspond to doing a particular
operation, while the remaining few states will correspond to setting up
and winding down the operations. 'n' must be parametisable, will be a
global consant, and can be a value of up to 2048, so assigning names to
the first 2048 states of the state machine in the type declaration
would be unecessary, if in fact, you could do it without typing out
2048 words. Secondly, it IS preferable that the remaining few states
ARE named (in my example FIRST, INIT, and LAST).

(2) Secondly, the encoding of the states must be in binary, and must
follow the order of the type declaration (ie: the first 'n' states mus
be encoded in binary from 0 -> n-1, FIRST state must be encoded n, LAST
state must be encoded n+1, and INIT state must be encoded n+2). The
encoding is specified in a string:

attribute ENUM_ENCODING of STATE_TYPE: type is "00 01 10 11"

The contents of my string must both be parametisable and have up to
around 2050 entries. Obviously just writing the string out like above
is not possible. I have looked at a number of encodings that Xilinx
provides, and binary seems to be the most promising. However, if
binary encoding is used, does Xilinx assign '0' to the first item in
the enumeration, '1' to the second item in the enumeration, '2' to the
third item in the enumeration, or does it assign binary values to the
state in some random order to optimise feedback logic? Does anyone
have any other ideas as to how to get around this problem?

Regards

Taras



Taras_96
  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
Cooler Master Gladiator 600 Case Admin Front Page News 0 07-10-2009 10:52 AM
ThermalTake DH 102 Home Theater Case Admin Front Page News 0 06-12-2009 08:22 AM
Thermaltake M9 Case Admin Front Page News 0 10-27-2008 11:44 AM
Judge: File-swapping tools are legal Citizen Bob DVD Video 140 11-08-2006 06:42 PM
Enermax Phoenix Case @ ThinkComputers.org Silverstrand Front Page News 0 10-20-2006 12:28 PM




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