Megafunction

lpm_abs (Absolute Value) Megafunction



Parameterized absolute value megafunction. Altera® recommends using the lpm_abs function to replace all other types of absolute value functions.

Altera also recommends instantiating this function as described in Using the MegaWizard® Plug-In Manager.

This topic contains the following information:

 

AHDL Function Prototype (port name and order also apply to Verilog HDL):

FUNCTION lpm_abs (data[LPM_WIDTH-1..0])
   WITH (LPM_WIDTH, ADDERTYPE)
   RETURNS (result[LPM_WIDTH-1..0], overflow);

 

VHDL Component Declaration:

COMPONENT lpm_abs
   GENERIC (LPM_WIDTH : POSITIVE;
      LPM_TYPE: STRING := "LPM_ABS";
      LPM_HINT: STRING := "UNUSED");
   PORT (data : IN STD_LOGIC_VECTOR(LPM_WIDTH-1 DOWNTO 0);
      result : OUT STD_LOGIC_VECTOR(LPM_WIDTH-1 DOWNTO 0);
      overflow: OUT STD_LOGIC);
END COMPONENT;
NOTE The ADDERTYPE parameter is supported only for backward compatibility, but should not be used in newer projects.

 

VHDL LIBRARY-USE Declaration

LIBRARY lpm;
USE lpm.lpm_components.all;

 

Port Descriptions:

INPUT PORTS

Port Name Required Description Comments
data[] Yes Signed number. Input port LPM_WIDTH wide.

OUTPUT PORTS

Port Name Required Description Comments
result[] Yes Absolute value of data[]. Output port LPM_WIDTH wide.
overflow No High if data = -2 ^ (LPM_WIDTH-1). Two's complement allows one more negative number than positive. The overflow port detects that singular instance and goes high to indicate that no positive equivalent exists.

 

Parameter Descriptions:

Parameter Type Required Description
LPM_WIDTH Integer Yes Width of the data[] and result[] ports.
LPM_HINT String No Allows you to specify Altera-specific parameters in VHDL Design Files (.vhd). The default is "UNUSED".
LPM_TYPE String No Identifies the library of parameterized modules (LPM) entity name in VHDL Design Files.

 

Truth Table/Functionality:

Inputs Outputs
data[LPM_WIDTH-1..0] result[LPM_WIDTH-1..0] overflow
>= 0 data[LPM_WIDTH-1..0] 0
< 0 data[LPM_WIDTH-1..0] 0
100... 100... 1

 

Resource Usage:

The following table summarizes the resource usage for an lpm_abs function used to implement a 16-bit absolute value converter with an up/down control and an overflow output.

Design Goals Design Results
Device Family Optimization
APEX 20K Routability
  Speed
Width Logic Cells
16 23
16 17

Numbers of shared expanders used are shown in parentheses ( ).

NOTE This topic prints best in Landscape orientation.


Back to Top

- PLDWorld -

 

Created by chm2web html help conversion utility.