/* 4bits Carry Lookahead Adder */ submod_class cadd4 { input a<4>, b<4>; input inv_b; input c_in; output out<4>, p<4>, g<4>, e<4>; output pout, gout; instrin do; instr_arg do(a, b, inv_b, c_in); } module cadd4 { input a<4>, b<4>; input inv_b; input c_in; output out<4>, p<4>, g<4>, e<4>; output pout, gout; instrin do; tmp tmp_b<4>; instruct do par { any { inv_b : tmp_b = ^b<3> || ^b<2> || ^b<1> || ^b<0>; else : tmp_b = b; } p = (a<3> | tmp_b<3>) || (a<2> | tmp_b<2>) || (a<1> | tmp_b<1>) || (a<0> | tmp_b<0>); g = (a<3> & tmp_b<3>) || (a<2> & tmp_b<2>) || (a<1> & tmp_b<1>) || (a<0> & tmp_b<0>); e = (a<3> @ tmp_b<3>) || (a<2> @ tmp_b<2>) || (a<1> @ tmp_b<1>) || (a<0> @ tmp_b<0>); out = (e<3> @ ((c_in & p<0> & p<1> & p<2>) | (g<0> & p<1> & p<2>) | (g<1> & p<2>) | g<2>)) || (e<2> @ ((c_in & p<0> & p<1>) | (g<0> & p<1>) | g<1>)) || (e<1> @ ((c_in & p<0>) | g<0>)) || (e<0> @ c_in); pout = p<0> & p<1> & p<2> & p<3>; gout = (g<0> & p<1> & p<2> & p<3>) | (g<1> & p<2> & p<3>) | (g<2> & p<3>) | g<3>; } }