AHDL

Using Conditionally Generated Logic



You can generate logic conditionally with If Generate Statements, if, for example, you wish to implement different behavior based on the value of an arithmetic expression. An If Generate Statement lists a series of behavioral statements that are activated after the positive evaluation of one or more arithmetic expressions.

The condlog1.tdf file shown below uses an If Generate Statement to implement different behavior for the output_b output on the basis of the current device family:

More Details

PARAMETERS (DEVICE_FAMILY);

SUBDESIGN condlog1
(
   input_a : INPUT;
   output_b : OUTPUT;
)
BEGIN
   IF DEVICE_FAMILY == "FLEX®6000" GENERATE
      output_b = input_a;
   ELSE GENERATE
      output_b = LCELL(input_a);
   END GENERATE;
END;
NOTE This example uses the predefined Altera® parameter DEVICE_FAMILY, which represents the target device family that you specified for the current design with the Device page of the Settings dialog box (Assignments menu).

The If Generate Statement can be used with For Generate Statements that handle special cases differently, for example, the first and last stages of a multiple stage multiplier. See Using Iteratively Generated Logic for more information on For Generate Statements.

The Quartus® II software supports the predefined evaluated function USED, which can be used in arithmetic expressions to test whether an option port has been used in an If Generate Statement.


Back to Top

- Altera -

 

Created by chm2web html help conversion utility.