The Constant Statement allows you to substitute a meaningful
symbolic name (a constant) for a number, text string, or value of
an arithmetic expression (where the value is a number or text
string). When you use a constant in a Text Design File
(.tdf), the Compiler replaces the constant with
the number, text string, or value assigned to the constant in the
Constant Statement.
Note: The Compiler evaluates each arithmetic operator in the arithmetic expression for the
evaluated function, and reduces the expression to a value (a number or text string). The
Compiler does not generate logic for the expression.
The following examples show Constant Statements:
CONSTANT UPPER_LIMIT = 130;
CONSTANT BAR = 1 + 2 DIV 3 + LOG2(256);
The Constant Statement has the following characteristics:
- The Constant Statement begins with the keyword
CONSTANT, followed by a symbolic name, an equals
symbol (=), and a number (including a radix, if
necessary), text string, or arithmetic expression.
- The statement ends with a semicolon (;).
- Once a constant is declared, you can use it to represent the
number, text string, or value throughout a TDF. For example, you
can use the UPPER_LIMIT constant shown above to
represent the decimal number 130 anywhere in the TDF
where you declare the constant.
- In arithmetic expressions, you can use previously defined constants, evaluated
functions, or parameters to define constants.
- The value of the arithmetic expression that you use to define a
constant can be a text string. These text strings can be the values
of previously defined parameters, constants, or evaluated
functions.
Constant Statements must conform to the following rules:
- A constant can be used in a TDF only after it is defined in the
TDF, or in an AHDL Include File
(.inc) that is included in the TDF.
- Each constant name must be unique in a TDF.
- The constant name cannot contain spaces. Use underscores to
separate the words in the name and improve readability.
- The Constant Statement can be used any number of times in a
TDF.
- The Constant Statement must be placed outside all other AHDL
sections.