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

Reply

VHDL - choice in a case satement

 
Thread Tools Search this Thread
Old 12-03-2003, 12:22 PM   #1
Default choice in a case satement


Hello all,

I wondered if you could give me some insight into
why the choices of a case statement must be
locally static i.e. it can't be a generic value.

Is there some workaround to still be able to
generically specify the binary values of the
states of my state machine (eg. to chosse a one-hot
state machine when I implement the component)

:My symphony compiler complains about this.

--
JB Viviers




jan
  Reply With Quote
Old 12-03-2003, 04:10 PM   #2
VhdlCohen
 
Posts: n/a
Default Re: choice in a case satement
>I wondered if you could give me some insight into
>why the choices of a case statement must be
>locally static i.e. it can't be a generic value.
>
>Is there some workaround to still be able to
>generically specify the binary values of the
>states of my state machine (eg. to chosse a one-hot
>state machine when I implement the component)
>


Case choice must be locally static to protect the code from
illegal choices. If the choice was globally static, then errors could occur.
For example, assume a generic g of value 4, and a signal S declared as:
signal S : std_logic_vector(g-1 downto 0);
...
case S is
when "0000" => ...
when "0001" => ...
when others => ...
end case

Now in the component instantiation or in a configuration, I set g to 32.
The case choices are no longer valid.
In a way, it protects the user from making dumb mistakes.
----------------------------------------------------------------------------
Ben Cohen Publisher, Trainer, Consultant (310) 721-4830
http://www.vhdlcohen.com/
Author of following textbooks:
* Using PSL/SUGAR with Verilog and VHDL
Guide to Property Specification Language for ABV, 2003 isbn 0-9705394-4-4
* Real Chip Design and Verification Using Verilog and VHDL, 2002 isbn
0-9705394-2-8
* Component Design by Example ", 2001 isbn 0-9705394-0-1
* VHDL Coding Styles and Methodologies, 2nd Edition, 1999 isbn 0-7923-8474-1
* VHDL Answers to Frequently Asked Questions, 2nd Edition, isbn 0-7923-8115
------------------------------------------------------------------------------



VhdlCohen
  Reply With Quote
Old 12-04-2003, 08:13 AM   #3
Nicolas Matringe
 
Posts: n/a
Default Re: choice in a case satement
jan a écrit:
> Hello all,
>
> I wondered if you could give me some insight into
> why the choices of a case statement must be
> locally static i.e. it can't be a generic value.
>
> Is there some workaround to still be able to
> generically specify the binary values of the
> states of my state machine (eg. to chosse a one-hot
> state machine when I implement the component)


Hi
In the case of the state machine encoding, use an enumerated type for
your state vector and then either let your synthesizer choose the
encoding scheme or add some synthesis directives or attributes to
specify the encoding scheme:

type T_STATE is (IDLE, VALID, READ);
signal STATE : T_STATE;

attribute ENUM_ENCODING : string; -- attribute declaration
attribute ENUM_ENCODING of T_STATE : type is “100 010 001”;

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
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
Lian Li Tyr PC-X500 Case Review Admin Front Page News 0 07-11-2008 09:02 PM
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