module CSA16(cout,S,A,B,cin);
output [15:0]S;
output cout;
input [15:0]A,B;
input cin;
wire c1,c2,c3,C4,C5,C6,C7,c8,c9,c10,c11,c12,c13,c14,c15,c16,P0,P1,P2,P3,p4,p5,p6,p7,p8,p9,p10,p11,p12,p13,p14,p15;
full_adder F1(S[0],c1,A[0],B[0],CIN);
full_adder F2(S[1],c2,A[1],B[1],c1);
full_adder F3(S[2],c3,A[2],B[2],c2);
full_adder F4(S[3],C4,A[3],B[3],c3);
full_adder F5(S[4],C5,A[4],B[4],C4);
full_adder F6(S[5],C6,A[5],B[5],C5);
full_adder F7(S[6],C7,A[6],B[6],C6);
full_adder F8(S[7],c8,A[7],B[7],C7);
full_adder F9(S[8],C9,A[8],B[8],C8);
full_adder F10(S[9],c10,A[9],B[9],C9);
full_adder F11(S[10],c11,A[10],B[10],c10);
full_adder F12(S[11],c12,A[11],B[11],c11);
full_adder F13(S[12],C13,A[12],B[12],c12);
full_adder F14(S[13],C14,A[13],B[13],C13);
full_adder F15(S[14],C15,A[14],B[14],C14);
full_adder F16(S[15],Cout,A[15],B[14],C15);
and g0(p0,A[0],B[0]);
and g1(p1,A[1],B[1]);
and g2(p2,A[2],B[2]);
and g3(p3,A[3],B[3]);
and g4(p4,A[4],B[4]);
and g5(p5,A[5],B[5]);
and g6(p6,A[6],B[6]);
and g7(p7,A[7],B[7]);
and g8(p8,A[8],B[8]);
and g9(p9,A[9],B[9]);
and g10(p10,A[10],B[10]);
and g11(p11,A[11],B[11]);
and g12(p12,A[12],B[12]);
and g13(p13,A[13],B[13]);
and g14(p14,A[14],B[14]);
and g15(p15,A[15],B[15]);
mux2x1 m1(cout1,c3,cout,se1);
mux2x1 m2(cout2,c7,cout1,se2);
mux2x1 m3(cout3,c11,cout2,se3);
mux2x1 m4(cout4,c15,cout3,se4);
endmodule;
output [15:0]S;
output cout;
input [15:0]A,B;
input cin;
wire c1,c2,c3,C4,C5,C6,C7,c8,c9,c10,c11,c12,c13,c14,c15,c16,P0,P1,P2,P3,p4,p5,p6,p7,p8,p9,p10,p11,p12,p13,p14,p15;
full_adder F1(S[0],c1,A[0],B[0],CIN);
full_adder F2(S[1],c2,A[1],B[1],c1);
full_adder F3(S[2],c3,A[2],B[2],c2);
full_adder F4(S[3],C4,A[3],B[3],c3);
full_adder F5(S[4],C5,A[4],B[4],C4);
full_adder F6(S[5],C6,A[5],B[5],C5);
full_adder F7(S[6],C7,A[6],B[6],C6);
full_adder F8(S[7],c8,A[7],B[7],C7);
full_adder F9(S[8],C9,A[8],B[8],C8);
full_adder F10(S[9],c10,A[9],B[9],C9);
full_adder F11(S[10],c11,A[10],B[10],c10);
full_adder F12(S[11],c12,A[11],B[11],c11);
full_adder F13(S[12],C13,A[12],B[12],c12);
full_adder F14(S[13],C14,A[13],B[13],C13);
full_adder F15(S[14],C15,A[14],B[14],C14);
full_adder F16(S[15],Cout,A[15],B[14],C15);
and g0(p0,A[0],B[0]);
and g1(p1,A[1],B[1]);
and g2(p2,A[2],B[2]);
and g3(p3,A[3],B[3]);
and g4(p4,A[4],B[4]);
and g5(p5,A[5],B[5]);
and g6(p6,A[6],B[6]);
and g7(p7,A[7],B[7]);
and g8(p8,A[8],B[8]);
and g9(p9,A[9],B[9]);
and g10(p10,A[10],B[10]);
and g11(p11,A[11],B[11]);
and g12(p12,A[12],B[12]);
and g13(p13,A[13],B[13]);
and g14(p14,A[14],B[14]);
and g15(p15,A[15],B[15]);
mux2x1 m1(cout1,c3,cout,se1);
mux2x1 m2(cout2,c7,cout1,se2);
mux2x1 m3(cout3,c11,cout2,se3);
mux2x1 m4(cout4,c15,cout3,se4);
endmodule;
No comments:
Post a Comment