// ************************************************************************** //
//                                                                            //
//    eses                   eses                                             //
//   eses                     eses                                            //
//  eses    eseses  esesese    eses   Embedded Systems Group                  //
//  ese    ese  ese ese         ese                                           //
//  ese    eseseses eseseses    ese   Department of Computer Science          //
//  eses   eses          ese   eses                                           //
//   eses   eseses  eseseses  eses    University of Kaiserslautern            //
//    eses                   eses                                             //
//                                                                            //
// ************************************************************************** //


[32]nat x;
[32]nat y;
[33]nat s;

thread RadixBAddCarryLookahead32 {
    bool g0,g1,g2,g3,g4,g5,g6,g7,g8,g9,g10,g11,g12,g13,g14,g15,g16,g17,g18,g19,g20,g21,g22,g23,g24,g25,g26,g27,g28,g29,g30,g31;
    bool p0,p1,p2,p3,p4,p5,p6,p7,p8,p9,p10,p11,p12,p13,p14,p15,p16,p17,p18,p19,p20,p21,p22,p23,p24,p25,p26,p27,p28,p29,p30,p31;
    nat x0,x1,x2,x3,x4,x5,x6,x7,x8,x9,x10,x11,x12,x13,x14,x15,x16,x17,x18,x19,x20,x21,x22,x23,x24,x25,x26,x27,x28,x29,x30,x31;
    nat y0,y1,y2,y3,y4,y5,y6,y7,y8,y9,y10,y11,y12,y13,y14,y15,y16,y17,y18,y19,y20,y21,y22,y23,y24,y25,y26,y27,y28,y29,y30,y31;
    nat s0,s1,s2,s3,s4,s5,s6,s7,s8,s9,s10,s11,s12,s13,s14,s15,s16,s17,s18,s19,s20,s21,s22,s23,s24,s25,s26,s27,s28,s29,s30,s31,s32;
    x0 = x[0];
    x1 = x[1];
    x2 = x[2];
    x3 = x[3];
    x4 = x[4];
    x5 = x[5];
    x6 = x[6];
    x7 = x[7];
    x8 = x[8];
    x9 = x[9];
    x10 = x[10];
    x11 = x[11];
    x12 = x[12];
    x13 = x[13];
    x14 = x[14];
    x15 = x[15];
    x16 = x[16];
    x17 = x[17];
    x18 = x[18];
    x19 = x[19];
    x20 = x[20];
    x21 = x[21];
    x22 = x[22];
    x23 = x[23];
    x24 = x[24];
    x25 = x[25];
    x26 = x[26];
    x27 = x[27];
    x28 = x[28];
    x29 = x[29];
    x30 = x[30];
    x31 = x[31];
    y0 = y[0];
    y1 = y[1];
    y2 = y[2];
    y3 = y[3];
    y4 = y[4];
    y5 = y[5];
    y6 = y[6];
    y7 = y[7];
    y8 = y[8];
    y9 = y[9];
    y10 = y[10];
    y11 = y[11];
    y12 = y[12];
    y13 = y[13];
    y14 = y[14];
    y15 = y[15];
    y16 = y[16];
    y17 = y[17];
    y18 = y[18];
    y19 = y[19];
    y20 = y[20];
    y21 = y[21];
    y22 = y[22];
    y23 = y[23];
    y24 = y[24];
    y25 = y[25];
    y26 = y[26];
    y27 = y[27];
    y28 = y[28];
    y29 = y[29];
    y30 = y[30];
    y31 = y[31];
    // preliminary sum digits
    s0 = x0 + y0;
    s1 = x1 + y1;
    s2 = x2 + y2;
    s3 = x3 + y3;
    s4 = x4 + y4;
    s5 = x5 + y5;
    s6 = x6 + y6;
    s7 = x7 + y7;
    s8 = x8 + y8;
    s9 = x9 + y9;
    s10 = x10 + y10;
    s11 = x11 + y11;
    s12 = x12 + y12;
    s13 = x13 + y13;
    s14 = x14 + y14;
    s15 = x15 + y15;
    s16 = x16 + y16;
    s17 = x17 + y17;
    s18 = x18 + y18;
    s19 = x19 + y19;
    s20 = x20 + y20;
    s21 = x21 + y21;
    s22 = x22 + y22;
    s23 = x23 + y23;
    s24 = x24 + y24;
    s25 = x25 + y25;
    s26 = x26 + y26;
    s27 = x27 + y27;
    s28 = x28 + y28;
    s29 = x29 + y29;
    s30 = x30 + y30;
    s31 = x31 + y31;
    // initial generate conditions
    g0 = s0>255;
    g1 = s1>255;
    g2 = s2>255;
    g3 = s3>255;
    g4 = s4>255;
    g5 = s5>255;
    g6 = s6>255;
    g7 = s7>255;
    g8 = s8>255;
    g9 = s9>255;
    g10 = s10>255;
    g11 = s11>255;
    g12 = s12>255;
    g13 = s13>255;
    g14 = s14>255;
    g15 = s15>255;
    g16 = s16>255;
    g17 = s17>255;
    g18 = s18>255;
    g19 = s19>255;
    g20 = s20>255;
    g21 = s21>255;
    g22 = s22>255;
    g23 = s23>255;
    g24 = s24>255;
    g25 = s25>255;
    g26 = s26>255;
    g27 = s27>255;
    g28 = s28>255;
    g29 = s29>255;
    g30 = s30>255;
    g31 = s31>255;
    // initial propagate conditions
    p0 = s0==255;
    p1 = s1==255;
    p2 = s2==255;
    p3 = s3==255;
    p4 = s4==255;
    p5 = s5==255;
    p6 = s6==255;
    p7 = s7==255;
    p8 = s8==255;
    p9 = s9==255;
    p10 = s10==255;
    p11 = s11==255;
    p12 = s12==255;
    p13 = s13==255;
    p14 = s14==255;
    p15 = s15==255;
    p16 = s16==255;
    p17 = s17==255;
    p18 = s18==255;
    p19 = s19==255;
    p20 = s20==255;
    p21 = s21==255;
    p22 = s22==255;
    p23 = s23==255;
    p24 = s24==255;
    p25 = s25==255;
    p26 = s26==255;
    p27 = s27==255;
    p28 = s28==255;
    p29 = s29==255;
    p30 = s30==255;
    p31 = s31==255;
    // carry propagation prefix tree
    // up-level 1
    g1 = g0 & p1 | g1;
    p1 = p1 & p0;
    g3 = g2 & p3 | g3;
    p3 = p3 & p2;
    g5 = g4 & p5 | g5;
    p5 = p5 & p4;
    g7 = g6 & p7 | g7;
    p7 = p7 & p6;
    g9 = g8 & p9 | g9;
    p9 = p9 & p8;
    g11 = g10 & p11 | g11;
    p11 = p11 & p10;
    g13 = g12 & p13 | g13;
    p13 = p13 & p12;
    g15 = g14 & p15 | g15;
    p15 = p15 & p14;
    g17 = g16 & p17 | g17;
    p17 = p17 & p16;
    g19 = g18 & p19 | g19;
    p19 = p19 & p18;
    g21 = g20 & p21 | g21;
    p21 = p21 & p20;
    g23 = g22 & p23 | g23;
    p23 = p23 & p22;
    g25 = g24 & p25 | g25;
    p25 = p25 & p24;
    g27 = g26 & p27 | g27;
    p27 = p27 & p26;
    g29 = g28 & p29 | g29;
    p29 = p29 & p28;
    g31 = g30 & p31 | g31;
    p31 = p31 & p30;
    // up-level 2
    g3 = g1 & p3 | g3;
    p3 = p3 & p1;
    g7 = g5 & p7 | g7;
    p7 = p7 & p5;
    g11 = g9 & p11 | g11;
    p11 = p11 & p9;
    g15 = g13 & p15 | g15;
    p15 = p15 & p13;
    g19 = g17 & p19 | g19;
    p19 = p19 & p17;
    g23 = g21 & p23 | g23;
    p23 = p23 & p21;
    g27 = g25 & p27 | g27;
    p27 = p27 & p25;
    g31 = g29 & p31 | g31;
    p31 = p31 & p29;
    // up-level 3
    g7 = g3 & p7 | g7;
    p7 = p7 & p3;
    g15 = g11 & p15 | g15;
    p15 = p15 & p11;
    g23 = g19 & p23 | g23;
    p23 = p23 & p19;
    g31 = g27 & p31 | g31;
    p31 = p31 & p27;
    // up-level 4
    g15 = g7 & p15 | g15;
    p15 = p15 & p7;
    g31 = g23 & p31 | g31;
    p31 = p31 & p23;
    // up-level 5
    g31 = g15 & p31 | g31;
    p31 = p31 & p15;
    // down-level 7
    // down-level 8
    g23 = g15 & p23 | g23;
    p23 = p23 & p15;
    // down-level 9
    g11 = g7 & p11 | g11;
    p11 = p11 & p7;
    g19 = g15 & p19 | g19;
    p19 = p19 & p15;
    g27 = g23 & p27 | g27;
    p27 = p27 & p23;
    // down-level 10
    g5 = g3 & p5 | g5;
    p5 = p5 & p3;
    g9 = g7 & p9 | g9;
    p9 = p9 & p7;
    g13 = g11 & p13 | g13;
    p13 = p13 & p11;
    g17 = g15 & p17 | g17;
    p17 = p17 & p15;
    g21 = g19 & p21 | g21;
    p21 = p21 & p19;
    g25 = g23 & p25 | g25;
    p25 = p25 & p23;
    g29 = g27 & p29 | g29;
    p29 = p29 & p27;
    // down-level 11
    g2 = g1 & p2 | g2;
    p2 = p2 & p1;
    g4 = g3 & p4 | g4;
    p4 = p4 & p3;
    g6 = g5 & p6 | g6;
    p6 = p6 & p5;
    g8 = g7 & p8 | g8;
    p8 = p8 & p7;
    g10 = g9 & p10 | g10;
    p10 = p10 & p9;
    g12 = g11 & p12 | g12;
    p12 = p12 & p11;
    g14 = g13 & p14 | g14;
    p14 = p14 & p13;
    g16 = g15 & p16 | g16;
    p16 = p16 & p15;
    g18 = g17 & p18 | g18;
    p18 = p18 & p17;
    g20 = g19 & p20 | g20;
    p20 = p20 & p19;
    g22 = g21 & p22 | g22;
    p22 = p22 & p21;
    g24 = g23 & p24 | g24;
    p24 = p24 & p23;
    g26 = g25 & p26 | g26;
    p26 = p26 & p25;
    g28 = g27 & p28 | g28;
    p28 = p28 & p27;
    g30 = g29 & p30 | g30;
    p30 = p30 & p29;
    // compute final sum digits
    s[0] = s0 % 256;
    s[1] = (s1+(g0?1:0)) % 256;
    s[2] = (s2+(g1?1:0)) % 256;
    s[3] = (s3+(g2?1:0)) % 256;
    s[4] = (s4+(g3?1:0)) % 256;
    s[5] = (s5+(g4?1:0)) % 256;
    s[6] = (s6+(g5?1:0)) % 256;
    s[7] = (s7+(g6?1:0)) % 256;
    s[8] = (s8+(g7?1:0)) % 256;
    s[9] = (s9+(g8?1:0)) % 256;
    s[10] = (s10+(g9?1:0)) % 256;
    s[11] = (s11+(g10?1:0)) % 256;
    s[12] = (s12+(g11?1:0)) % 256;
    s[13] = (s13+(g12?1:0)) % 256;
    s[14] = (s14+(g13?1:0)) % 256;
    s[15] = (s15+(g14?1:0)) % 256;
    s[16] = (s16+(g15?1:0)) % 256;
    s[17] = (s17+(g16?1:0)) % 256;
    s[18] = (s18+(g17?1:0)) % 256;
    s[19] = (s19+(g18?1:0)) % 256;
    s[20] = (s20+(g19?1:0)) % 256;
    s[21] = (s21+(g20?1:0)) % 256;
    s[22] = (s22+(g21?1:0)) % 256;
    s[23] = (s23+(g22?1:0)) % 256;
    s[24] = (s24+(g23?1:0)) % 256;
    s[25] = (s25+(g24?1:0)) % 256;
    s[26] = (s26+(g25?1:0)) % 256;
    s[27] = (s27+(g26?1:0)) % 256;
    s[28] = (s28+(g27?1:0)) % 256;
    s[29] = (s29+(g28?1:0)) % 256;
    s[30] = (s30+(g29?1:0)) % 256;
    s[31] = (s31+(g30?1:0)) % 256;
    s[32] = (g31?1:0);
}