AHDL

Using an If Then Statement vs. a Case Statement



If Then and Case Statements are similar. In some cases, you can use either statement to achieve the same results. The following example shows the same operation expressed in both If Then and Case Statement formats:

If Then Statement: Case Statement:
				
IF a[] == 0 THEN
	y = c & d;
ELSIF a[] == 1 THEN	
	y = e & f;
ELSIF a[] == 2 THEN
	y = g & h;
ELSIF a[] == 3 THEN	
	y = i;
ELSE 
	y = GND;
END IF;
      
CASE a[] IS
   WHEN 0 =>
      y = c & d;
   WHEN 1 =>
      y = e & f;
   WHEN 2 =>
      y = g & h;
   WHEN 3 =>
      y = i;
   WHEN OTHERS =>
      y = GND;
END CASE;
      

Important differences exist between If Then and Case Statements:


Back to Top

- PLDWorld -

 

Created by chm2web html help conversion utility.