AHDL


- 2


SUBDESIGN lpm_add1

(

a[8..1], b[8..1] : INPUT;

c[8..1] : OUTPUT;

carry_out : OUTPUT;

)

BEGIN

% %

(c[], carry_out, ) = lpm_add_sub(GND, a[], b[], GND,,)

WITH (LPM_WIDTH=8,

LPM_REPRESENTATION="unsigned");

% %

--(c[],carry_out,)= lpm_add_sub(.dataa[]=a[],.datab[]=b[],

-- .cin=GND, .add_sub=GND)

-- WITH (LPM_WIDTH=8,

LPM_REPRESENTATION="unsigned");

END;

 

lpm_add_sub :

 

FUNCTION lpm_add_sub(cin, dataa[LPM_WIDTH-1..0], datab[LPM_WIDTH-1..0], add_sub)

WITH (LPM_WIDTH, LPM_REPRESENTATION, LPM_DIRECTION, ADDERTYPE,

ONE_INPUT_IS_CONSTANT)

RETURNS (result[LPM_WIDTH-1..0], cout, overflow);

 

LPM_WIDTH lpm_add_sub lpm_add1.tdf LPM_WIDTH LPM_REPRESENTATION.

lpm_add2.tdf, , lpm_add1.tdf, 8- Instance.

 

INCLUDE "lpm_add_sub.inc";

SUBDESIGN lpm_add2

(

a[8..1], b[8..1] : INPUT;

c[8..1] : OUTPUT;

carry_out : OUTPUT;

)

VARIABLE

8bitadder : lpm_add_sub WITH (LPM_WIDTH=8,

LPM_REPRESENTATION="unsigned");

BEGIN

8bitadder.cin = GND

8bitadder.dataa[] = a[]

8bitadder.datab[] = b[]

8bitadder.add_sub = GND

c[] = 8bitadder.result[]

carry_out = 8bitadder.cout

END;