Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations IamaSherpa on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

if before case?

Status
Not open for further replies.

fantastico

Technical User
Jan 19, 2004
1
US
Does IF statement implies priority whereas a CASE statement does not.
 
esentially yes. to describe some more:

if creates a prioritised list of condiions for example
if a = b then
blah1;
elsif d = c then
blah2;
else
blah3;
end if;

Note that the conditions in each if statement can be made up of any variable/signal that you would like.

A case statement, enables you to provide a statement (blahx) for EVERY different possible setting of a particular signal: for eaxmple

case signala is
when "00" =>
blah1;
when "01" =>
blah2;
when others =>
blah3;
end case;

note that in most situations you *MUST* have a statement for EVERY possible situation that signala can get into. In most cases that requires a "when others" (kind of equivalent of else). Or if using enumerated types you can just list all the possible types that you created.

So in the case statement there is no priority. It is a MUX with signala as the select logic.

The above example written with an if statement:
if signala = "00" then
blah1;
elsif signala = "01" then
blah2;
else
blah3;
end if;

this will create a combinatorial tree (or AND, OR gates etc) such that it first checks for signala = 00, then 01 and finally all other conditions. So if your logic doesn't really need the priority then you create a longer delay than really needed.

hmm. Not sure how good of an explanation that is, but it will do for now, and all books will explain this one.


--
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top