Using the Assert Statement

You can use the Assert Statement to test the validity of any arbitrary expression that uses parameters, numbers, evaluated functions, or the used or unused status of a port. You might, for example, use the Assert Statement to determine whether the value of an optional parameter falls within a range determined by the value of a second parameter.

When you use an Assert Statement with conditions, you list the acceptable values for the assertion conditions. If a value is unacceptable, the assertion is activated and a message is issued. If you use an Assert Statement without conditions, the assertion is always activated.

The Compiler evaluates each assertion condition only once, after the Compiler has resolved all parameter values. An assertion cannot depend on the value of a signal that is implemented in the device. For example, if an Assert Statement is placed after an If Then Statement of the form IF a = VCC THEN c = d, the assertion condition cannot depend on the value of a.

The condlog2.tdf file shown below has the same functionality as condlog1.tdf (shown in Using Conditionally Generated Logic), but uses Assert Statements in the Logic Section to report which logic was generated by the If Generate Statement:

More Details


SUBDESIGN condlog2
   input_a : INPUT;
   output_b : OUTPUT;
      output_b = input_a;
      -- Assertion is always activated if there is no condition 
         REPORT "Compiling for FLEX6000 family"
      output_b = LCELL(input_a);
      -- Assertion is activated if current family is not FLEX 10K®
      -- or FLEX6000. Severity defaults to ERROR
         REPORT "Compiling for % family", DEVICE_FAMILY;
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).

Back to Top

- Altera -


Created by chm2web html help conversion utility.