// ************************************************************************** // // // // 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 // // // // ************************************************************************** // [16]nat x; [16]nat y; [17]nat s; thread RadixBAddCarryLookahead16 { [16]bool g; [16]bool p; // preliminary sum digits s[0] = x[0] + y[0]; s[1] = x[1] + y[1]; s[2] = x[2] + y[2]; s[3] = x[3] + y[3]; s[4] = x[4] + y[4]; s[5] = x[5] + y[5]; s[6] = x[6] + y[6]; s[7] = x[7] + y[7]; s[8] = x[8] + y[8]; s[9] = x[9] + y[9]; s[10] = x[10] + y[10]; s[11] = x[11] + y[11]; s[12] = x[12] + y[12]; s[13] = x[13] + y[13]; s[14] = x[14] + y[14]; s[15] = x[15] + y[15]; // initial generate conditions g[0] = s[0]>255; g[1] = s[1]>255; g[2] = s[2]>255; g[3] = s[3]>255; g[4] = s[4]>255; g[5] = s[5]>255; g[6] = s[6]>255; g[7] = s[7]>255; g[8] = s[8]>255; g[9] = s[9]>255; g[10] = s[10]>255; g[11] = s[11]>255; g[12] = s[12]>255; g[13] = s[13]>255; g[14] = s[14]>255; g[15] = s[15]>255; // initial propagate conditions p[0] = s[0]==255; p[1] = s[1]==255; p[2] = s[2]==255; p[3] = s[3]==255; p[4] = s[4]==255; p[5] = s[5]==255; p[6] = s[6]==255; p[7] = s[7]==255; p[8] = s[8]==255; p[9] = s[9]==255; p[10] = s[10]==255; p[11] = s[11]==255; p[12] = s[12]==255; p[13] = s[13]==255; p[14] = s[14]==255; p[15] = s[15]==255; // carry propagation prefix tree // up-level 1 g[1] = g[0] & p[1] | g[1]; p[1] = p[1] & p[0]; g[3] = g[2] & p[3] | g[3]; p[3] = p[3] & p[2]; g[5] = g[4] & p[5] | g[5]; p[5] = p[5] & p[4]; g[7] = g[6] & p[7] | g[7]; p[7] = p[7] & p[6]; g[9] = g[8] & p[9] | g[9]; p[9] = p[9] & p[8]; g[11] = g[10] & p[11] | g[11]; p[11] = p[11] & p[10]; g[13] = g[12] & p[13] | g[13]; p[13] = p[13] & p[12]; g[15] = g[14] & p[15] | g[15]; p[15] = p[15] & p[14]; // up-level 2 g[3] = g[1] & p[3] | g[3]; p[3] = p[3] & p[1]; g[7] = g[5] & p[7] | g[7]; p[7] = p[7] & p[5]; g[11] = g[9] & p[11] | g[11]; p[11] = p[11] & p[9]; g[15] = g[13] & p[15] | g[15]; p[15] = p[15] & p[13]; // up-level 3 g[7] = g[3] & p[7] | g[7]; p[7] = p[7] & p[3]; g[15] = g[11] & p[15] | g[15]; p[15] = p[15] & p[11]; // up-level 4 g[15] = g[7] & p[15] | g[15]; p[15] = p[15] & p[7]; // down-level 6 // down-level 7 g[11] = g[7] & p[11] | g[11]; p[11] = p[11] & p[7]; // down-level 8 g[5] = g[3] & p[5] | g[5]; p[5] = p[5] & p[3]; g[9] = g[7] & p[9] | g[9]; p[9] = p[9] & p[7]; g[13] = g[11] & p[13] | g[13]; p[13] = p[13] & p[11]; // down-level 9 g[2] = g[1] & p[2] | g[2]; p[2] = p[2] & p[1]; g[4] = g[3] & p[4] | g[4]; p[4] = p[4] & p[3]; g[6] = g[5] & p[6] | g[6]; p[6] = p[6] & p[5]; g[8] = g[7] & p[8] | g[8]; p[8] = p[8] & p[7]; g[10] = g[9] & p[10] | g[10]; p[10] = p[10] & p[9]; g[12] = g[11] & p[12] | g[12]; p[12] = p[12] & p[11]; g[14] = g[13] & p[14] | g[14]; p[14] = p[14] & p[13]; // compute final sum digits s[0] = s[0] % 256; s[1] = (s[1]+(g[0]?1:0)) % 256; s[2] = (s[2]+(g[1]?1:0)) % 256; s[3] = (s[3]+(g[2]?1:0)) % 256; s[4] = (s[4]+(g[3]?1:0)) % 256; s[5] = (s[5]+(g[4]?1:0)) % 256; s[6] = (s[6]+(g[5]?1:0)) % 256; s[7] = (s[7]+(g[6]?1:0)) % 256; s[8] = (s[8]+(g[7]?1:0)) % 256; s[9] = (s[9]+(g[8]?1:0)) % 256; s[10] = (s[10]+(g[9]?1:0)) % 256; s[11] = (s[11]+(g[10]?1:0)) % 256; s[12] = (s[12]+(g[11]?1:0)) % 256; s[13] = (s[13]+(g[12]?1:0)) % 256; s[14] = (s[14]+(g[13]?1:0)) % 256; s[15] = (s[15]+(g[14]?1:0)) % 256; s[16] = (g[15]?1:0); }