AHDL: Parameterized Multiplier (lpm_mult)
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;
Feedback
Did this information help you?
If not, please log onto mySupport to file a technical request or enhancement.
Altera does not warrant that this solution will work for the customer's intended purpose and disclaims all liability for use of or reliance on the solution.
|