This example uses the lpm_mult function and a constant to implement a parameterized multiplier that multiplies two 4-bit values. You can adjust the size of the multiplier by changing the value of the constant WIDTH. This example uses an Include Statement (shown in blue text) to import the contents of the Include File containing the Function Prototype for the lpm_mult function. An Instance Declaration (shown in red text) implements an instance of the function.
For more information on using this example in your project, go to:
tmul3t.tdf
CONSTANT WIDTH = 4;
INCLUDE "lpm_mult.inc";
SUBDESIGN tmul3t
(
a[WIDTH-1..0] : INPUT;
b[WIDTH-1..0] : INPUT;
out[2*WIDTH-1..0] : OUTPUT;
)
VARIABLE
mult : lpm_mult WITH (LPM_REPRESENTATION=
"SIGNED",LPM_WIDTHA=WIDTH,LPM_WIDTHB=
WIDTH,LPM_WIDTHS=WIDTH,LPM_WIDTHP=WIDTH*2);
BEGIN
mult.dataa[] = a[];
mult.datab[] = b[];
out[] = mult.result[];
END;
Design Examples Disclaimer
These design examples may only be used within Altera Corporation devices and remain the property of Altera. They are being provided on an “as-is” basis and as an accommodation; therefore, all warranties, representations, or guarantees of any kind (whether express, implied, or statutory) including, without limitation, warranties of merchantability, non-infringement, or fitness for a particular purpose, are specifically disclaimed. Altera expressly does not recommend, suggest, or require that these examples be used in combination with any other product not provided by Altera.

