You can create a user-defined megafunction or macrofunction in
AHDL by generating an AHDL AHDL Include File
(.inc), which contains an AHDL Function
Prototype, for each lower-level logic function that is instantiated
in the top-level Text Design File
(.tdf). You can either manually create the AHDL
Include File, or create an AHDL Include
File from any Quartus® Prime-supported design file in the
Quartus® Prime Text Editor, Block Editor, or Symbol Editor. In
addition, the Quartus® Prime IP Catalog automatically generates an
AHDL Include File containing a Function Prototype when you use it
to create a custom megafunction variation.
After you create the user-defined function, you can then
instantiate the function in a TDF as described in Using an Altera Unparameterized
Function or Using an Altera
Parameterized Function.
Note:
- The AHDL Include File must have the same file
name as the design file, with the extension .inc.
- To use a particular logic function in multiple
projects, use the Libraries page of the Settings dialog box to specify the directory that
contains the function's design file and AHDL Include File as a user
library for each project. Make sure you use the User
Libraries page for each project. You can also save copies of
the files to the directory of an existing user library. Otherwise,
you must save copies of the files to the directory containing the
project that will use the custom function.
- There is no distinction between output ports
and bidirectional ports in Function Prototypes; instead, all ports
listed after the RETURNS keyword are treated as output
ports. As a result, if you specify a bidirectional port in a logic
function's Function Prototype and do not connect the port to a top-level
bidirectional pin or to other logic in the design where you
instantiate the logic function, an error can occur.