![]() |
|
|
|||||||
![]() |
VHDL - case statement concatenation condition |
|
|
Thread Tools | Search this Thread |
|
|
#1 |
|
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 |
|
|
|
|
#2 |
|
Posts: n/a
|
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 |
|
![]() |
| Thread Tools | Search this Thread |
|
|
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 |