4.3.1 LPM_ADD_SUB

 

Copyright © 1998 University of Manchester


Ports
Port Name
Type
Usage
Description Comments
DataA
I
Required
Augend/Minuend Vector, LPM_Width wide
DataB
I
Required
Addend/Subtrahend Vector, LPM_Width wide
Cin
I
Optional
Carry in to the low order bit

OP=ADD Low= 0 High= +1

OP=SUB Low = -1 High= 0

If not connected, default value is LOW.
Add_Sub
I
Optional
The Operation to be performed

=H: OP = ADD

=L: OP = SUB

Cannot be used it LPM_Direction property is used. If not connected, defaults value is ADD.
Result
O
Required
DataA ± DataB ± Cin Vector, LPM_Width wide
Cout
O
Optional
Carry-out (~Borrow-in) of Most Significant Bit (MSB) Note 1
Overflow
O
Optional
Result exceeds available precision. Note 2
Clock
I
Optional
Clock for pipelined usage Note 3
Aclr
I
Optional
Asynchronous Clear Note 4

Note 1: Cout has a physical interpretation as the carry-out (~borrow-in) of the most significant bit. Cout is most meaningful for detecting overflow in unsigned numbers. See Table 1 for the arithmetic interpretation of Cout = 1.

Note 2: Overflow has a physical interpretation as the XOR (exclusive or) of the carry into the MSB with the carry out of the MSB. Overflow is only meaningful when the LPM_Representation is signed. It indicates that the Result has exceeded the available precision. See Table 2 for the arithmetic interpretation of Overflow = 1.

Note 3: The clock port provides for pipelined operation of the LPM_ADD_SUB. If a latency other 0 (default value) is specified, then the clock port must be connected.

Note 4: The pipelined initializes to undefined. The Aclr port may be used at any time to reset the pipeline to all 0's asynchronously to clock.

Table 1
OP = ADD
OP = SUB
Unsigned(DataA + DataB + Cin) > 2LPM_Width-1 Normal Subtract. However, if Cout = 0, then (DataA - DataB - Cin) < 0
SignedNormal result of adding two negative numbers, or possible overflow. Normal result when subtracting a positive number from a negative number, or possible overflow.

Table 2OP=ADDOP=SUB
UnsignedNot meaningful Not meaningful
Signed(DataA + DataB + Cin) > 2LPM_Width-1-1

or

(DataA + DataB + Cin) < -2LPM_Width-1

(DataA - DataB - Cin) > 2LPM_Width-1-1

or

(DataA - DataB - Cin) < -2LPM_Width-1

Properties
Property
Usage
Value Comments
LPM_Width
Required
LPM Value > 0Width of DataA, DataB and Result
LPM_Direction
Optional
ADD | SUBDefault is ADD. Add_Sub port may not be used if this property is used.
LPM_Representation
Optional
UNSIGNED or SIGNEDDefault is SIGNED
LPM_Pipeline
Optional
LPM Value > = 0Default is 0 - non-pipelined

Functions
Resulti = DataAi ^ DataBi ^ Cini ^ (~ Add_Sub)
Cout = carry out of the MSB
Overflow = the XOR of the carry into the MSB and Cout

When Cout is prepended to the Result, the result is a vector that always has sufficient precision to represent the result of the operation.
{Cout,Result} = DataA + Cin ± DataB

 

Copyright © 1998 University of Manchester