/* * add16c.sfl --- 16-Bit Carry Lookahead Adder */ module add16 { submod_type cla4 { input a<4>, b<4>, ci; output y<4>, co, go, po; instrin enable; instr_arg enable(a, b, ci); } submod_type lcg4 { input g<4>, p<4>, ci; output c0, c1, c2, go, po; instrin enable; instr_arg enable(g, p, ci); } input a<16>, b<16>, ci; output y<16>, co; instrin enable; cla4 CLA0; cla4 CLA1; cla4 CLA2; cla4 CLA3; lcg4 LCG; tmp c0, c1, c2; tmp g0, g1, g2, g3; tmp p0, p1, p2, p3; tmp s0<4>, s1<4>, s2<4>, s3<4>; instruct enable par { c0 = LCG.enable(g3||g2||g1||g0, p3||p2||p1||p0, ci).c0; c1 = LCG.enable(g3||g2||g1||g0, p3||p2||p1||p0, ci).c1; c2 = LCG.enable(g3||g2||g1||g0, p3||p2||p1||p0, ci).c2; g0 = CLA0.enable(a< 3: 0>, b< 3: 0>, ci).go; g1 = CLA1.enable(a< 7: 4>, b< 7: 4>, c0).go; g2 = CLA2.enable(a<11: 8>, b<11: 8>, c1).go; g3 = CLA3.enable(a<15:12>, b<15:12>, c2).go; p0 = CLA0.enable(a< 3: 0>, b< 3: 0>, ci).po; p1 = CLA1.enable(a< 7: 4>, b< 7: 4>, c0).po; p2 = CLA2.enable(a<11: 8>, b<11: 8>, c1).po; p3 = CLA3.enable(a<15:12>, b<15:12>, c2).po; s0 = CLA0.enable(a< 3: 0>, b< 3: 0>, ci).y; s1 = CLA1.enable(a< 7: 4>, b< 7: 4>, c0).y; s2 = CLA2.enable(a<11: 8>, b<11: 8>, c1).y; s3 = CLA3.enable(a<15:12>, b<15:12>, c2).y; co = CLA3.enable(a<15:12>, b<15:12>, c2).co; y = s3 || s2 || s1 || s0; } } /* add16 */ /* * Carry Lookahead Adder */ module cla4 { input a<4>, b<4>, ci; output y<4>, co, go, po; instrin enable; tmp c0, c1, c2; instruct enable par { c0 = (a<0> & b<0>) | ((a<0> | b<0>) & ci); c1 = (a<1> & b<1>) | ((a<1> | b<1>) & a<0> & b<0>) | ((a<1> | b<1>) & (a<0> | b<0>) & ci); c2 = (a<2> & b<2>) | ((a<2> | b<2>) & a<1> & b<1>) | ((a<2> | b<2>) & (a<1> | b<1>) & a<0> & b<0>) | ((a<2> | b<2>) & (a<1> | b<1>) & (a<0> | b<0>) & ci); go = (a<3> & b<3>) | ((a<3> | b<3>) & a<2> & b<2>) | ((a<3> | b<3>) & (a<2> | b<2>) & a<1> & b<1>) | ((a<3> | b<3>) & (a<2> | b<2>) & (a<1> | b<1>) & a<0> & b<0>); po = (a<3> | b<3>) & (a<2> | b<2>) & (a<1> | b<1>) & (a<0> | b<0>); co = go | (po & ci); /* co = (a<3> & b<3>) | ((a<3> | b<3>) & a<2> & b<2>) | ((a<3> | b<3>) & (a<2> | b<2>) & a<1> & b<1>) | ((a<3> | b<3>) & (a<2> | b<2>) & (a<1> | b<1>) & a<0> & b<0>) | ((a<3> | b<3>) & (a<2> | b<2>) & (a<1> | b<1>) & (a<0> | b<0>) & ci); */ y = a @ b @ (c2 || c1 || c0 || ci); } } /* cla4 */ /* * Lookahead Carry Generator */ module lcg4 { input g<4>, p<4>, ci; output c0, c1, c2, go, po; instrin enable; instruct enable par { c0 = g<0> | (p<0>&ci); c1 = g<1> | (p<1>&g<0>) | (p<1>&p<0>&ci); c2 = g<2> | (p<2>&g<1>) | (p<2>&p<1>&g<0>) | (p<2>&p<1>&p<0>&ci); go = g<3> | (p<3>&g<2>) | (p<3>&p<2>&g<1>) | (p<3>&p<2>&p<1>&g<0>); po = p<3> & p<2> & p<1> & p<0>; } } /* lcg4 */