AHDL

Instance Declaration



Each individual usage, or instance, of a particular logic function can be declared as a variable with an Instance Declaration in the Variable Section. After it is declared, you can use the input and output ports of each logic function as ports in the Logic Section.

When you wish to implement an instance of a megafunction or macrofunction with an Instance Declaration, you must first ensure that its logic is defined in its own design file and a Function Prototype Statement specifies the ports and parameters of the function.

You can also use an Instance Declaration to implement an instance of a primitive. However, in contrast to megafunction and macrofunctions, primitive logic is predefined, so you do not need to define the primitive logic in a separate design file. In most cases, a Function Prototype Statement is not needed. See Function Prototype Statement for more information.

To use an Instance Declaration, you declare a variable of type <primitive>, <megafunction>, or <macrofunction> in the Variable Section. For a parameterized megafunction or macrofunction, the declaration includes a list of the parameters used by the instance and optional parameter values. Once you declare the variable, you can use ports of the instance of the function in the following format:

<instance name>.<port name>

For example, if you wish to incorporate the compare and adder functions (taken from the example in Function Prototype Statement) into your current Text Design File (.tdf), make the following Instance Declarations in the Variable Section:

VARIABLE
   comp  : compare;
   adder : lpm_add_sub WITH (LPM_WIDTH = 8);

The variables comp and adder are instances of the functions compare and lpm_add_sub, which have the following inputs and outputs:

a[3..0], b[3..0]           : INPUT;     -- inputs of compare 
less, equal, greater       : OUTPUT;	-- outputs of compare

a[8..1], b[8..1]           : INPUT; 	-- inputs of adder
sum[8..1]                  : OUTPUT;	-- outputs of adder

You can therefore use the following ports of comp and adder in the current Logic Section:

comp.a[], comp.b[], comp.less, comp.equal, comp.greater

adder.dataa[], adder.datab[], adder.result[]

These ports can be used in any behavioral statement in the same way as nodes.

Since all primitives have only one output, you can use the name of a primitive without a port name (that is, without .q or .out) on the right of an equation if you want to use the primitive's output. Similarly, for all primitives that have a single primary input (that is, all primitives except JKFF, JKFFE, SRFF, and SRFFE), you can use the name of a primitive without a port name (that is, without .d, .t, or .in) on the left of an equation to connect the primitive to its primary input. See Register Declaration for more information.

During compilation, the Compiler searches for parameter values for each instance of a megafunction or macrofunction as described in Parameter Value Search Order.


Back to Top

- Altera -

 

Created by chm2web html help conversion utility.