Function Prototype Statements have the same function as symbols in schematic design files. Both provide a shorthand description of a logic function, listing its name and its input, output, and bidirectional ports.
However, megafunction and macrofunction input port default values are not automatically assigned as they are in Block Editor files; you must assign them explicitly in the Subdesign Section of a Text Design File (.tdf). You can also assign a default value for bidirectional ports in the Subdesign Section. However, output ports cannot be assigned a default value.
When you wish to implement an instance of a megafunction or macrofunction, you must ensure that its logic is defined in its own design file. You then use a Function Prototype Statement to specify the ports of the function, and implement an instance of the function with an in-line logic function reference or an Instance Declaration.
To implement an instance of a primitive, you also use an in-line logic function reference or an Instance Declaration. However, in contrast to megafunctions and macrofunctions, primitive logic is predefined, so you do not need to define the primitive logic in a separate design file. In addition, you do not need to use a Function Prototype Statement unless you wish to change the order of the primitive inputs. Example
The following examples show Function Prototype Statements. The first is for the parameterized function
lpm_add_sub; the second is for the unparameterized function
FUNCTION lpm_add_sub (cin, dataa[LPM_WIDTH-1..0], datab[LPM_WIDTH-1..0], add_sub) WITH (LPM_WIDTH, LPM_REPRESENTATION, LPM_DIRECTION, ADDERTYPE, ONE_INPUT_IS_CONSTANT) RETURNS (result[LPM_WIDTH-1..0], cout, overflow); FUNCTION compare (a[3..0], b[3..0]) RETURNS (less, equal, greater);
The Function Prototype Statement has the following characteristics:
is followed by the name of the function. In the examples shown above, the
function names are
When you specify the function name, you can use the name substitution feature to specify a text string for the name that is replaced by a different text string when the design is compiled. Before you can use the name substitution feature, you must turn on the
NAME_SUBSTITUTION option in the TDF's Options Statement and specify the replacement string for the name in the TDF's Parameters Statement. You can then specify the text string to be replaced in the Function Prototype Statement using the format
@<text string>. Example
A list of input ports to the function follows the name. In
the first example shown above, the input ports are
datab[LPM_WIDTH-1..0]; in the second, they are
In a parameterized function, the keyword
and a parameter name list follow the input port list. The list is enclosed
(); the individual parameter names are separated
by commas (
RETURNS is followed by a list of
output and bidirectional ports of the function. In the first example shown
above, the output ports are
overflow; in the second, they are
|There is no distinction between output ports and bidirectional ports in Function Prototypes; instead, all ports listed after the
Both the input and output lists are enclosed in parentheses; the individual port names are separated by commas.
The Function Prototype Statement ends with a semicolon (
A Function Prototype Statement must be placed outside of the Subdesign Section in a TDF, and it must be placed before the logic function is instantiated in an in-line logic function reference or Instance Declaration.
As an alternative to using a Function Prototype Statement in a file, you can use an Include Statement to call an AHDL Include File (.inc) that contains a Function Prototype Statement.
Function Prototypes for all Quartus® II megafunctions are stored in AHDL Include Files in the \quartus\libraries\megafunctions directory; Function Prototypes for Quartus II primitives are built into the Quartus II software. Online help for all megafunctions and primitives shows the Function Prototype for each Altera-provided function.
Back to Top
- Altera -
|Created by chm2web html help conversion utility.|