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

Reply

VHDL - case statement concatenation condition

 
Thread Tools Search this Thread
Old 06-10-2009, 04:01 PM   #1
Default case statement concatenation condition


One syntax I've favored in verilog for compactness (and to see that
all variable conditions are covered) is to express logic in a truth
table as:

casez( {a,b,c} )
3'b000: z <= ...
3'b001: z <= ...

I'm trying to use a similar style in VHDL, and am wondering if there
is an elegant way to do this. My first attempt was:

case a & b & c is
when "000" => z <= ...
when "001" => z <= ..

With the error, "Ambiguous type in infix expression; unsigned or
signed."

OK. Strong typing... doesn't know what type the concatenation should
resolve to... so I write:

case std_logic_vector'(a & b & c) is
when "000" => z <= ...
when "001" => z <= ..

I get the model sim warning "Array type case expression must be of a
locally static subtype."

I could assign the concatenation first to a variable (verbose), or I
could disabled the warning in modelsim (but it does seem to be a valid
violation of the VHDL language), but does anyone have a suggestion on
how to write this in both a terse and correct way?

Thanks,

Mark






Mark
  Reply With Quote
Old 06-10-2009, 04:26 PM   #2
Mark
 
Posts: n/a
Default Re: case statement concatenation condition
On Jun 10, 10:11*am, Jonathan Bromley <jonathan.brom...@MYCOMPANY.com>
wrote:
> On Wed, 10 Jun 2009 08:01:17 -0700 (PDT), Mark wrote:
> >One syntax I've favored in verilog for compactness (and to see that
> >all variable conditions are covered) is to express logic in a truth
> >table as:

>
> >casez( {a,b,c} )
> > * 3'b000: z <= ...
> > * 3'b001: z <= ...

>
> >I'm trying to use a similar style in VHDL, and am wondering if there
> >is an elegant way to do this. *My first attempt was:

>
> >case a & b & c is
> > * when "000" => z <= ...
> > * when "001" => z <= ..

>
> >With the error, "Ambiguous type in infix expression; unsigned or
> >signed."

>
> >OK. Strong typing... doesn't know what type the concatenation should
> >resolve to... so I write:

>
> >case std_logic_vector'(a & b & c) is

>
> You need to be even stronger... the *subtype* of the
> case expressions is still not "locally static". *And
> yes, it's a pain and everyone agrees it's a pain. *It
> just falls out of the language rules like that.
>
> Luckily there's a relatively simple fix. *Declare
> a subtype of std_logic_vector (typically in the
> declarative region of your process):
>
> * subtype slv3 is std_logic_vector(2 downto 0);
>
> And then you can qualify the case expression with
> the locally-static subtype:
>
> * case slv3'(a & b & c) is
> * * when "000" => ...
>
> and all will be well.
>
> Of course, you may well need rather a lot of such
> subtype declarations, if you have numerous different
> case statements.
>
> Enjoy
> --
> 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
> jonathan.brom...@MYCOMPANY.comhttp://www.MYCOMPANY.com
>
> The contents of this message may contain personal views which
> are not the views of Doulos Ltd., unless specifically stated.- Hide quoted text -
>
> - Show quoted text -


Jonathan,

Thanks! Like that much better than the alternatives I was considering.

Mark


Mark
  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
Re: Condition Jay Santos DVD Video 0 12-23-2004 07:28 PM
FA: 2 perfect condition OOP Criterion DVD's - Last 24 hours!!! SJG DVD Video 0 03-07-2004 08:57 AM
Lot of 44 Used DVD Titles - MINT condition Sean McLean DVD Video 0 02-03-2004 09:46 AM
FS: Alien Legacy Region 1 Box Set - Mint Condition - Bargain! WORX A4 DVD Video 0 01-22-2004 08:57 AM
FS: Certification books (A+, Network +). New condition. Skywarner A+ Certification 1 01-02-2004 10:03 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