The Define Statement allows you to substitute a meaningful
symbolic name (an evaluated function)
for the value of an arithmetic expression. When you use an
evaluated function in a Text Design File
(.tdf), the Compiler replaces the evaluated
function with the value of the arithmetic expression assigned to
the evaluated function in the Define Statement. The value of the
arithmetic expression is a number or text string, and is based on
optional arguments for the expression.
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.
- You can use evaluated functions in arithmetic
expressions only; you cannot use evaluated functions in Boolean
expressions.
The following example defines and uses the evaluated function
EX to ensure that the Subdesign Section declares at
least one port,.
DEFINE EX(a,b) = (a > b) ? a : b;
SUBDESIGN
(
dataa[EX(WIDTH,0)..0]: INPUT;
datab[EX(WIDTH,0)..0]: OUTPUT;
)
BEGIN
datab[] = dataa[];
END;
The Define Statement has the following characteristics:
Define Statements must conform to the following rules:
- An evaluated expression 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. However, AHDL
includes several predefined evaluated functions that do not need to
be defined.
- Each evaluated function must be unique in a TDF.
- The evaluated function name cannot contain spaces. Use
underscores to separate the words in the name and improve
readability.
- The Define Statement can be used any number of times in a
TDF.
- The Define Statement must be placed outside all other AHDL
sections.