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 illusions ?

 
Thread Tools Search this Thread
Old 05-02-2005, 06:23 AM   #11
Default Re: one hot decoder


Info,
The code above given by you for onehot did sysnthesize differently. the
"case" version systhesized to 3 LUT's involving only OR gates and didnt
infer priority structure infact it optimized as you have mentioned to a
series of OR gates. But the "if" version systhesiszed to 6 LUT's and
inferred a priority structure. Leonardo was used for the systhesis.



Neo
  Reply With Quote
Old 05-02-2005, 07:20 AM   #12
backhus
 
Posts: n/a
Default Re: Case statement illusions ?
Hi Symon,
for (most) of the given examples case and if-elsif will give the same result.
Why?
Because in both cases your selector is fully covered (uses all of the bits of a vector or whatever you use as a
selector). Your if-elsif collapses into a parallel structure, because there is no priority of one value over the other
possible.

but how about this:

Selector <= A&B&C; -- I MUST do this for a case statement !
case Selector is
when "001" => Output <= Input1;
when "010" => Output <= Input2;
when "100" => Output <= Input2;
when others => Output <= (others => 'Z');
end case;

vs.

If C = '1' then
Output <= Input1;
elsif B= '1' then
Output <= Input2;
elsif C= '1' then
Output <= Input3;
else
Output <= (others => 'Z');
end if;

NOW the case produces a parallel multiplexer structure that is sensitive for the given code of Selector.
The if-elsif does something different. Whenever C becomes '1' (No matter how unlikely or unneccesary this might be in
your particular design) it switches Input1 to the output. Here we have the always cited priority encoder.

To get the same functionality with a case you have to write a different code:

Selector <= A&B&C; -- I MUST do this for a case statement !
case Selector is
when "--1" => Output <= Input1;
when "-10" => Output <= Input2;
when "100" => Output <= Input2;
when others => Output <= (others => 'Z');
end case;

Now the first >when< hits whenever C becomes '1'.
This code might produce something more "parallel" than the if-elsif, but who knows about the tricks of modern synthesis
tools.

Have a nice synthesis

Eilert





backhus
  Reply With Quote
Old 05-04-2005, 09:37 PM   #13
info_
 
Posts: n/a
Default Re: one hot decoder
Neo wrote:
> Info,
> The code above given by you for onehot did sysnthesize differently. the
> "case" version systhesized to 3 LUT's involving only OR gates and didnt
> infer priority structure infact it optimized as you have mentioned to a
> series of OR gates. But the "if" version systhesiszed to 6 LUT's and
> inferred a priority structure. Leonardo was used for the systhesis.
>

Yes my point exactly. Not all tools do this correctly. Leoanrdo is right.
Just try Precision Synthesis (or other tools) if you can and compare
the results.

The if .. elsif is a priority encoder which has a well defined behavior
for the overlapping cases (more than one 1 in the vector), and this
requires more logic than the "pure one hot". This edscription is
more predictible acroos tools.


Bert


info_
  Reply With Quote
Old 05-04-2005, 09:49 PM   #14
info_
 
Posts: n/a
Default Re: Case statement illusions ?
backhus wrote:

> Hi Symon,
> for (most) of the given examples case and if-elsif will give the same
> result.
> Why?
> Because in both cases your selector is fully covered (uses all of
> the bits of a vector or whatever you use as a selector). Your if-elsif
> collapses into a parallel structure, because there is no priority of one
> value over the other possible.
>
> but how about this:
>
> Selector <= A&B&C; -- I MUST do this for a case statement !
> case Selector is
> when "001" => Output <= Input1;
> when "010" => Output <= Input2;
> when "100" => Output <= Input2;
> when others => Output <= (others => 'Z');
> end case;
>
> vs.
>
> If C = '1' then
> Output <= Input1;
> elsif B= '1' then
> Output <= Input2;
> elsif C= '1' then
> Output <= Input3;
> else
> Output <= (others => 'Z');
> end if;
>
> NOW the case produces a parallel multiplexer structure that is sensitive
> for the given code of Selector.
> The if-elsif does something different. Whenever C becomes '1' (No matter
> how unlikely or unneccesary this might be in your particular design) it
> switches Input1 to the output. Here we have the always cited priority
> encoder.
>
> To get the same functionality with a case you have to write a different
> code:
>
> Selector <= A&B&C; -- I MUST do this for a case statement !
> case Selector is
> when "--1" => Output <= Input1;
> when "-10" => Output <= Input2;
> when "100" => Output <= Input2;
> when others => Output <= (others => 'Z');
> end case;
>
> Now the first >when< hits whenever C becomes '1'.
> This code might produce something more "parallel" than the if-elsif, but
> who knows about the tricks of modern synthesis tools.
>
> Have a nice synthesis
>
> Eilert


Just a few errors :

1. you can in fact qualify the expression and not use a signal.
A variable is usually preferable if you want one (otherwise,
you must add Selector in your sensitivity list, and this slows down
the simulation without usefulness).

case SLV3'(A&B&C) is -- with subtype SLV3 is std_logic_vector (3 downto 0);

2.
output <= 'Z' infers a tristate, nothing to do with a don't care!
A don't care '-' does eliminate C from the result.

3. case ... is when "--1" is wrong !
Comparing anything (but a '-') to '-' produces a false.
Comparing with '-' (to ignore the comparison) requires the use
of std_match (not usable in case statement).


VHDL is not always intuitive...


Bert Cuzeau


info_
  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