Tuesday, May 9, 2017

Verilog Program for 32-bit Carry Skip Adder

module CSA32(cout,S,A,B,cin);
    output [31:0]S;
    output cout;
    input [31:0]A,B;
    input cin;
    wire c1,c2,c3,C4,C5,C6,C7,c8,c9,c10,c11,c12,c13,c14,c15,c16,c17,c18,c19,c20,c21,c22,c23,c24,c25,c26,c27,c28,c29,c30,c31,
    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;
    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],C16,A[15],B[14],C15);
    full_adder F17(S[16],c17,A[16],B[15],C16);
    full_adder F18(S[17],C18,A[17],B[16],C17);
    full_adder F19(S[18],c19,A[18],B[17],C18);
    full_adder F20(S[19],c20,A[19],B[18],c19);
    full_adder F21(S[20],c21,A[20],B[19],c20);
    full_adder F22(S[21],C22,A[21],B[21],c21);
    full_adder F23(S[22],C23,A[22],B[22],C22);
    full_adder F24(S[23],C24,A[23],B[23],C23);
    full_adder F25(S[24],C25,A[24],B[24],C24);
    full_adder F26(S[25],c26,A[25],B[25],C25);
    full_adder F27(S[26],C27,A[26],B[26],C26);
    full_adder F28(S[27],c28,A[27],B[27],C27);
    full_adder F29(S[28],c29,A[28],B[28],c28);
    full_adder F30(S[29],c30,A[29],B[29],c29);
    full_adder F31(S[30],C31,A[30],B[30],c30);
    full_adder F32(S[31],COUT,A[31],B[31],C31);
    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]);
    and g16(p16,A[16],B[16]);
    and g17(p17,A[17],B[17]);
    and g18(p18,A[18],B[18]);
    and g19(p19,A[19],B[19]);
    and g20(p20,A[20],B[20]);
    and g21(p21,A[21],B[21]);
    and g22(p22,A[22],B[22]);
    and g23(p24,A[23],B[23]);
    and g24(p25,A[24],B[24]);
    and g25(se,p0,p1,p2,p3);
    and g26(se2,p4,p5,p6,p7);
    and g27(se3,p8,p9,p10,p11);
    and g28(se4,p12,p13,p14,p15);
    and g29(se5,p16,p17,p18,p19);
    and g30(se6,p20,p21,p22,p23);
    and g31(se7,p24,p25,p26,p27);
    and g32(se8,P28,p29,p30,P31);
    mux2x1 m1(cout1,c3,cout,se1);
    mux2x1 m2(cout2,c7,cout1,se2);
    mux2x1 m3(cout3,c11,cout2,se3);
    mux2x1 m4(cout4,c15,cout3,se4);
    mux2x1 m5(cout5,c19,cout4,se5);
    mux2x1 m6(cout6,c23,cout5,se6);
    mux2x1 m7(cout7,c27,cout6,se7);
    mux2x1 m8(cout8,c28,cout7,se8);
endmodule;

No comments:

Post a Comment