Top Banner
Fast Carry Algorithm a0 a1 a2 a3 a4 a5 a6 a7 a8 a9 a10 a11 a12 a13 a14 a15 b0 b1 b2 b3 b4 b5 b6 b7 b8 b9 b10 b11 b12 b13 b14 b15 c0
21

Fast Carry Algorithm a0 a1 a2 a3 a4 a5 a6 a7 a8 a9 a10 a11 a12 a13 a14 a15 b0 b1 b2 b3 b4 b5 b6 b7 b8 b9 b10 b11 b12 b13 b14 b15 c0.

Jan 14, 2016

Download

Documents

Welcome message from author
This document is posted to help you gain knowledge. Please leave a comment to let me know what you think about it! Share it to your friends and learn new things together.
Transcript
Page 1: Fast Carry Algorithm a0 a1 a2 a3 a4 a5 a6 a7 a8 a9 a10 a11 a12 a13 a14 a15 b0 b1 b2 b3 b4 b5 b6 b7 b8 b9 b10 b11 b12 b13 b14 b15 c0.

Fast Carry Algorithm

a0 a1 a2 a3 a4 a5 a6 a7 a8 a9 a10 a11 a12 a13 a14 a15b0 b1 b2 b3 b4 b5 b6 b7 b8 b9 b10 b11 b12 b13 b14 b15

c0

Page 2: Fast Carry Algorithm a0 a1 a2 a3 a4 a5 a6 a7 a8 a9 a10 a11 a12 a13 a14 a15 b0 b1 b2 b3 b4 b5 b6 b7 b8 b9 b10 b11 b12 b13 b14 b15 c0.

a0 a1 a2 a3 a4 a5 a6 a7 a8 a9 a10 a11 a12 a13 a14 a15b0 b1 b2 b3 b4 b5 b6 b7 b8 b9 b10 b11 b12 b13 b14 b15

Step 1: calculate pi’s, gi’s

c0

p0 p1 p2 p3 p4 p5 p6 p7 p8 p9 p10 p11 p12 p13 p14 p15g0 g1 g2 g3 g4 g5 g6 g7 g8 g9 g10 g11 g12 g13 g14 g15

pi = ai + bi gi = ai∙bi

Page 3: Fast Carry Algorithm a0 a1 a2 a3 a4 a5 a6 a7 a8 a9 a10 a11 a12 a13 a14 a15 b0 b1 b2 b3 b4 b5 b6 b7 b8 b9 b10 b11 b12 b13 b14 b15 c0.

p0 p1 p2 p3 p4 p5 p6 p7 p8 p9 p10 p11 p12 p13 p14 p15g0 g1 g2 g3 g4 g5 g6 g7 g8 g9 g10 g11 g12 g13 g14 g15

a0 a1 a2 a3 a4 a5 a6 a7 a8 a9 a10 a11 a12 a13 a14 a15b0 b1 b2 b3 b4 b5 b6 b7 b8 b9 b10 b11 b12 b13 b14 b15

Step 2: Calculate global Pi’s, Gi’s

c0

P0 = p0∙p1∙p2∙p3 G0 = g3+(p3∙g2)+(p3∙p2∙g1)+(p3∙p2∙p1∙g0)P1 = p4∙p5∙p6∙p7 G1 = g7+(p7∙g6)+(p7∙p6∙g5)+(p7∙p6∙p5∙g4)P2 = p8∙p9∙p10∙p11 G2 = g11+(p11∙g10)+(p11∙p10∙g9)+(p11∙p10∙p9∙g8)P3 = p12∙p13∙p14∙p15 G3 = g15+(p15∙g14)+(p15∙p14∙g13)+(p15∙p14∙p13∙g12)

P0G0

P1G1

P2G2

P3G3

Page 4: Fast Carry Algorithm a0 a1 a2 a3 a4 a5 a6 a7 a8 a9 a10 a11 a12 a13 a14 a15 b0 b1 b2 b3 b4 b5 b6 b7 b8 b9 b10 b11 b12 b13 b14 b15 c0.

p0 p1 p2 p3 p4 p5 p6 p7 p8 p9 p10 p11 p12 p13 p14 p15g0 g1 g2 g3 g4 g5 g6 g7 g8 g9 g10 g11 g12 g13 g14 g15

a0 a1 a2 a3 a4 a5 a6 a7 a8 a9 a10 a11 a12 a13 a14 a15b0 b1 b2 b3 b4 b5 b6 b7 b8 b9 b10 b11 b12 b13 b14 b15

Step 3: Calculate global Ci’s

c0

C1 = G0+(P0∙c0)C2 = G1+(P1∙G0)+(P1∙P0∙c0)C3 = G2+(P2∙G1)+(P2∙P1∙G0)+(P2∙P1∙P0∙c0)C4 = G3+(P3∙G2)+(P3∙P2∙G1)+(P3∙P2∙P1∙G0)+(P3∙P2∙P1∙P0∙c0)

P0G0

P1G1

P2G2

P3G3

C1 C2 C3 C4

Page 5: Fast Carry Algorithm a0 a1 a2 a3 a4 a5 a6 a7 a8 a9 a10 a11 a12 a13 a14 a15 b0 b1 b2 b3 b4 b5 b6 b7 b8 b9 b10 b11 b12 b13 b14 b15 c0.

p0 p1 p2 p3 p4 p5 p6 p7 p8 p9 p10 p11 p12 p13 p14 p15g0 g1 g2 g3 g4 g5 g6 g7 g8 g9 g10 g11 g12 g13 g14 g15

a0 a1 a2 a3 a4 a5 a6 a7 a8 a9 a10 a11 a12 a13 a14 a15b0 b1 b2 b3 b4 b5 b6 b7 b8 b9 b10 b11 b12 b13 b14 b15

Step 4: Calculate ri’s in groups of 4

c0

r0 = a0+b0+c0r1 = a1+b1+g0+(p0∙c0)r2 = a2+b2+g1+(p1∙g0)+(p1∙p0∙c0)r3 = a3+b3+g2+(p2∙g1)+(p2∙p1∙g0)+(p2∙p1∙p0∙c0)

P0G0

P1G1

P2G2

P3G3

C1 C2 C3 C4

r0 r1 r2 r3

Page 6: Fast Carry Algorithm a0 a1 a2 a3 a4 a5 a6 a7 a8 a9 a10 a11 a12 a13 a14 a15 b0 b1 b2 b3 b4 b5 b6 b7 b8 b9 b10 b11 b12 b13 b14 b15 c0.

p0 p1 p2 p3 p4 p5 p6 p7 p8 p9 p10 p11 p12 p13 p14 p15g0 g1 g2 g3 g4 g5 g6 g7 g8 g9 g10 g11 g12 g13 g14 g15

a0 a1 a2 a3 a4 a5 a6 a7 a8 a9 a10 a11 a12 a13 a14 a15b0 b1 b2 b3 b4 b5 b6 b7 b8 b9 b10 b11 b12 b13 b14 b15

Step 4: Calculate ri’s in groups of 4

c0

r4 = a4+b4+C1r5 = a5+b5+g4+(p4∙C1)r6 = a6+b6+g5+(p5∙g4)+(p5∙p4∙C1)r7 = a7+b7+g6+(p6∙g5)+(p6∙p5∙g4)+(p6∙p5∙p4∙C1)

P0G0

P1G1

P2G2

P3G3

C1 C2 C3 C4

r0 r1 r2 r3 r4 r5 r6 r7

Page 7: Fast Carry Algorithm a0 a1 a2 a3 a4 a5 a6 a7 a8 a9 a10 a11 a12 a13 a14 a15 b0 b1 b2 b3 b4 b5 b6 b7 b8 b9 b10 b11 b12 b13 b14 b15 c0.

p0 p1 p2 p3 p4 p5 p6 p7 p8 p9 p10 p11 p12 p13 p14 p15g0 g1 g2 g3 g4 g5 g6 g7 g8 g9 g10 g11 g12 g13 g14 g15

a0 a1 a2 a3 a4 a5 a6 a7 a8 a9 a10 a11 a12 a13 a14 a15b0 b1 b2 b3 b4 b5 b6 b7 b8 b9 b10 b11 b12 b13 b14 b15

Step 4: Calculate ri’s in groups of 4

c0

r8 = a8+b8+C2 r9 = a9+b9+g8+(p8∙C2)r10 = a10+b10+g9+(p9∙g8)+(p9∙p8∙C2)r11 = a11+b11+g10+(p10∙g9)+(p10∙p9∙g8)+(p10∙p9∙p8∙C2)

P0G0

P1G1

P2G2

P3G3

C1 C2 C3 C4

r0 r1 r2 r3 r4 r5 r6 r7 r8 r9 r10 r11

Page 8: Fast Carry Algorithm a0 a1 a2 a3 a4 a5 a6 a7 a8 a9 a10 a11 a12 a13 a14 a15 b0 b1 b2 b3 b4 b5 b6 b7 b8 b9 b10 b11 b12 b13 b14 b15 c0.

p0 p1 p2 p3 p4 p5 p6 p7 p8 p9 p10 p11 p12 p13 p14 p15g0 g1 g2 g3 g4 g5 g6 g7 g8 g9 g10 g11 g12 g13 g14 g15

a0 a1 a2 a3 a4 a5 a6 a7 a8 a9 a10 a11 a12 a13 a14 a15b0 b1 b2 b3 b4 b5 b6 b7 b8 b9 b10 b11 b12 b13 b14 b15

Step 4: Calculate ri’s in groups of 4

c0

r12 = a12+b12+C3r13 = a13+b13+g12+(p12∙C3)r14 = a14+b14+g13+(p13∙g12)+(p13∙p12∙C3)r15 = a15+b15+g14+(p14∙g13)+(p14∙p13∙g12)+(p14∙p13∙p12∙C3)

P0G0

P1G1

P2G2

P3G3

C1 C2 C3 C4

r0 r1 r2 r3 r4 r5 r6 r7 r8 r9 r10 r11 r12 r13 r14 r15

Page 9: Fast Carry Algorithm a0 a1 a2 a3 a4 a5 a6 a7 a8 a9 a10 a11 a12 a13 a14 a15 b0 b1 b2 b3 b4 b5 b6 b7 b8 b9 b10 b11 b12 b13 b14 b15 c0.

p0 p1 p2 p3 p4 p5 p6 p7 p8 p9 p10 p11 p12 p13 p14 p15g0 g1 g2 g3 g4 g5 g6 g7 g8 g9 g10 g11 g12 g13 g14 g15

a0 a1 a2 a3 a4 a5 a6 a7 a8 a9 a10 a11 a12 a13 a14 a15b0 b1 b2 b3 b4 b5 b6 b7 b8 b9 b10 b11 b12 b13 b14 b15

Example

c0

a = 31980b = -16354

= 0111110011101100 = 1100000000011110

P0G0

P1G1

P2G2

P3G3

C1 C2 C3 C4

Page 10: Fast Carry Algorithm a0 a1 a2 a3 a4 a5 a6 a7 a8 a9 a10 a11 a12 a13 a14 a15 b0 b1 b2 b3 b4 b5 b6 b7 b8 b9 b10 b11 b12 b13 b14 b15 c0.

p0 p1 p2 p3 p4 p5 p6 p7 p8 p9 p10 p11 p12 p13 p14 p15g0 g1 g2 g3 g4 g5 g6 g7 g8 g9 g10 g11 g12 g13 g14 g15

0 0 1 1 0 1 1 1 0 0 1 1 1 1 1 00 1 1 1 1 0 0 0 0 0 0 0 0 0 1 1

Example

0

a = 31980b = -16354

= 0111110011101100 = 1100000000011110

P0G0

P1G1

P2G2

P3G3

C1 C2 C3 C4

Page 11: Fast Carry Algorithm a0 a1 a2 a3 a4 a5 a6 a7 a8 a9 a10 a11 a12 a13 a14 a15 b0 b1 b2 b3 b4 b5 b6 b7 b8 b9 b10 b11 b12 b13 b14 b15 c0.

p0 p1 p2 p3 p4 p5 p6 p7 p8 p9 p10 p11 p12 p13 p14 p15g0 g1 g2 g3 g4 g5 g6 g7 g8 g9 g10 g11 g12 g13 g14 g15

0 0 1 1 0 1 1 1 0 0 1 1 1 1 1 00 1 1 1 1 0 0 0 0 0 0 0 0 0 1 1

Step 1: calculate pi’s, gi’s

0

P0G0

P1G1

P2G2

P3G3

C1 C2 C3 C4

pi = ai + bi gi = ai∙bi

Page 12: Fast Carry Algorithm a0 a1 a2 a3 a4 a5 a6 a7 a8 a9 a10 a11 a12 a13 a14 a15 b0 b1 b2 b3 b4 b5 b6 b7 b8 b9 b10 b11 b12 b13 b14 b15 c0.

0 1 1 1 1 1 1 1 0 0 1 1 1 1 1 10 0 1 1 0 0 0 0 0 0 0 0 0 0 1 0

0 0 1 1 0 1 1 1 0 0 1 1 1 1 1 00 1 1 1 1 0 0 0 0 0 0 0 0 0 1 1

Step 1: calculate pi’s, gi’s

0

P0G0

P1G1

P2G2

P3G3

C1 C2 C3 C4

pi = ai + bi gi = ai∙bi

Page 13: Fast Carry Algorithm a0 a1 a2 a3 a4 a5 a6 a7 a8 a9 a10 a11 a12 a13 a14 a15 b0 b1 b2 b3 b4 b5 b6 b7 b8 b9 b10 b11 b12 b13 b14 b15 c0.

0 1 1 1 1 1 1 1 0 0 1 1 1 1 1 10 0 1 1 0 0 0 0 0 0 0 0 0 0 1 0

0 0 1 1 0 1 1 1 0 0 1 1 1 1 1 00 1 1 1 1 0 0 0 0 0 0 0 0 0 1 1

Step 2: Calculate global Pi’s, Gi’s

0

P0G0

P1G1

P2G2

P3G3

C1 C2 C3 C4

P0 = p0∙p1∙p2∙p3 G0 = g3+(p3∙g2)+(p3∙p2∙g1)+(p3∙p2∙p1∙g0)P1 = p4∙p5∙p6∙p7 G1 = g7+(p7∙g6)+(p7∙p6∙g5)+(p7∙p6∙p5∙g4)P2 = p8∙p9∙p10∙p11 G2 = g11+(p11∙g10)+(p11∙p10∙g9)+(p11∙p10∙p9∙g8)P3 = p12∙p13∙p14∙p15 G3 = g15+(p15∙g14)+(p15∙p14∙g13)+(p15∙p14∙p13∙g12)

Page 14: Fast Carry Algorithm a0 a1 a2 a3 a4 a5 a6 a7 a8 a9 a10 a11 a12 a13 a14 a15 b0 b1 b2 b3 b4 b5 b6 b7 b8 b9 b10 b11 b12 b13 b14 b15 c0.

0 1 1 1 1 1 1 1 0 0 1 1 1 1 1 10 0 1 1 0 0 0 0 0 0 0 0 0 0 1 0

0 0 1 1 0 1 1 1 0 0 1 1 1 1 1 00 1 1 1 1 0 0 0 0 0 0 0 0 0 1 1

Step 2: Calculate global Pi’s, Gi’s

0

01

10

00

11

C1 C2 C3 C4

P0 = p0∙p1∙p2∙p3 G0 = g3+(p3∙g2)+(p3∙p2∙g1)+(p3∙p2∙p1∙g0)P1 = p4∙p5∙p6∙p7 G1 = g7+(p7∙g6)+(p7∙p6∙g5)+(p7∙p6∙p5∙g4)P2 = p8∙p9∙p10∙p11 G2 = g11+(p11∙g10)+(p11∙p10∙g9)+(p11∙p10∙p9∙g8)P3 = p12∙p13∙p14∙p15 G3 = g15+(p15∙g14)+(p15∙p14∙g13)+(p15∙p14∙p13∙g12)

Page 15: Fast Carry Algorithm a0 a1 a2 a3 a4 a5 a6 a7 a8 a9 a10 a11 a12 a13 a14 a15 b0 b1 b2 b3 b4 b5 b6 b7 b8 b9 b10 b11 b12 b13 b14 b15 c0.

0 1 1 1 1 1 1 1 0 0 1 1 1 1 1 10 0 1 1 0 0 0 0 0 0 0 0 0 0 1 0

0 0 1 1 0 1 1 1 0 0 1 1 1 1 1 00 1 1 1 1 0 0 0 0 0 0 0 0 0 1 1

Step 3: Calculate global Ci’s

0

01

10

00

11

C1 C2 C3 C4

C1 = G0+(P0∙c0)C2 = G1+(P1∙G0)+(P1∙P0∙c0)C3 = G2+(P2∙G1)+(P2∙P1∙G0)+(P2∙P1∙P0∙c0)C4 = G3+(P3∙G2)+(P3∙P2∙G1)+(P3∙P2∙P1∙G0)+(P3∙P2∙P1∙P0∙c0)

Page 16: Fast Carry Algorithm a0 a1 a2 a3 a4 a5 a6 a7 a8 a9 a10 a11 a12 a13 a14 a15 b0 b1 b2 b3 b4 b5 b6 b7 b8 b9 b10 b11 b12 b13 b14 b15 c0.

0 1 1 1 1 1 1 1 0 0 1 1 1 1 1 10 0 1 1 0 0 0 0 0 0 0 0 0 0 1 0

0 0 1 1 0 1 1 1 0 0 1 1 1 1 1 00 1 1 1 1 0 0 0 0 0 0 0 0 0 1 1

Step 3: Calculate global Ci’s

0

01

10

00

11

1 1 0 1

C1 = G0+(P0∙c0)C2 = G1+(P1∙G0)+(P1∙P0∙c0)C3 = G2+(P2∙G1)+(P2∙P1∙G0)+(P2∙P1∙P0∙c0)C4 = G3+(P3∙G2)+(P3∙P2∙G1)+(P3∙P2∙P1∙G0)+(P3∙P2∙P1∙P0∙c0)

Page 17: Fast Carry Algorithm a0 a1 a2 a3 a4 a5 a6 a7 a8 a9 a10 a11 a12 a13 a14 a15 b0 b1 b2 b3 b4 b5 b6 b7 b8 b9 b10 b11 b12 b13 b14 b15 c0.

0 1 1 1 1 1 1 1 0 0 1 1 1 1 1 10 0 1 1 0 0 0 0 0 0 0 0 0 0 1 0

0 0 1 1 0 1 1 1 0 0 1 1 1 1 1 00 1 1 1 1 0 0 0 0 0 0 0 0 0 1 1

Step 4: Calculate ri’s in groups of 4

0

01

10

00

11

1 1 0 1

r0 = a0+b0+c0r1 = a1+b1+g0+(p0∙c0)r2 = a2+b2+g1+(p1∙g0)+(p1∙p0∙c0)r3 = a3+b3+g2+(p2∙g1)+(p2∙p1∙g0)+(p2∙p1∙p0∙c0)

0 1 0 1

Page 18: Fast Carry Algorithm a0 a1 a2 a3 a4 a5 a6 a7 a8 a9 a10 a11 a12 a13 a14 a15 b0 b1 b2 b3 b4 b5 b6 b7 b8 b9 b10 b11 b12 b13 b14 b15 c0.

0 1 1 1 1 1 1 1 0 0 1 1 1 1 1 10 0 1 1 0 0 0 0 0 0 0 0 0 0 1 0

0 0 1 1 0 1 1 1 0 0 1 1 1 1 1 00 1 1 1 1 0 0 0 0 0 0 0 0 0 1 1

Step 4: Calculate ri’s in groups of 4

0

01

10

00

11

1 1 0 1

0 1 0 1

r4 = a4+b4+C1r5 = a5+b5+g4+(p4∙C1)r6 = a6+b6+g5+(p5∙g4)+(p5∙p4∙C1)r7 = a7+b7+g6+(p6∙g5)+(p6∙p5∙g4)+(p6∙p5∙p4∙C1)

0 0 0 0

Page 19: Fast Carry Algorithm a0 a1 a2 a3 a4 a5 a6 a7 a8 a9 a10 a11 a12 a13 a14 a15 b0 b1 b2 b3 b4 b5 b6 b7 b8 b9 b10 b11 b12 b13 b14 b15 c0.

0 1 1 1 1 1 1 1 0 0 1 1 1 1 1 10 0 1 1 0 0 0 0 0 0 0 0 0 0 1 0

0 0 1 1 0 1 1 1 0 0 1 1 1 1 1 00 1 1 1 1 0 0 0 0 0 0 0 0 0 1 1

Step 4: Calculate ri’s in groups of 4

0

01

10

00

11

1 1 0 1

0 1 0 1 0 0 0 0

r8 = a8+b8+C2 r9 = a9+b9+g8+(p8∙C2)r10 = a10+b10+g9+(p9∙g8)+(p9∙p8∙C2)r11 = a11+b11+g10+(p10∙g9)+(p10∙p9∙g8)+(p10∙p9∙p8∙C2)

1 0 1 1

Page 20: Fast Carry Algorithm a0 a1 a2 a3 a4 a5 a6 a7 a8 a9 a10 a11 a12 a13 a14 a15 b0 b1 b2 b3 b4 b5 b6 b7 b8 b9 b10 b11 b12 b13 b14 b15 c0.

0 1 1 1 1 1 1 1 0 0 1 1 1 1 1 10 0 1 1 0 0 0 0 0 0 0 0 0 0 1 0

0 0 1 1 0 1 1 1 0 0 1 1 1 1 1 00 1 1 1 1 0 0 0 0 0 0 0 0 0 1 1

Step 4: Calculate ri’s in groups of 4

0

01

10

00

11

1 1 0 1

0 1 0 1 0 0 0 0 1 0 1 1

r12 = a12+b12+C3r13 = a13+b13+g12+(p12∙C3)r14 = a14+b14+g13+(p13∙g12)+(p13∙p12∙C3)r15 = a15+b15+g14+(p14∙g13)+(p14∙p13∙g12)+(p14∙p13∙p12∙C3)

1 1 0 0

Page 21: Fast Carry Algorithm a0 a1 a2 a3 a4 a5 a6 a7 a8 a9 a10 a11 a12 a13 a14 a15 b0 b1 b2 b3 b4 b5 b6 b7 b8 b9 b10 b11 b12 b13 b14 b15 c0.

0 1 1 1 1 1 1 1 0 0 1 1 1 1 1 10 0 1 1 0 0 0 0 0 0 0 0 0 0 1 0

0 0 1 1 0 1 1 1 0 0 1 1 1 1 1 00 1 1 1 1 0 0 0 0 0 0 0 0 0 1 1

Final Result

0

01

10

00

11

1 1 0 1

0 1 0 1 0 0 0 0 1 0 1 1

a = 31980b = -16354

= 0111110011101100 = 1100000000011110 = 0011110100001010r = 15626

1 1 0 0