Tuesday, May 9, 2017

Verilog Program for 4-bit Carry look Ahead Adder


module cla_4bit(a,b,cin,sum,cout);
    input [3:0]a,b;
    input cin;
    output [3:0]sum;
    output cout;
    //assign cin=1'b0;
    wire p0,p1,g0,w0;
    and (g0,a[0],b[0]);
    xor (p0,a[0],b[0]);
    and (w0,p0,cin);
    or (cout,g0,w0);
    xor (p0,a[0],b[0]);
    xor (p1,a[1],b[1]);
    xor (p2,a[2],b[2]);
    xor (p3,a[3],b[3]);
    xor (sum[0],p0,cin);
    xor (sum[1],p1,c1);
    xor (sum[2],p2,c2);
    xor (sum[3],p3,cout);
endmodule;

No comments:

Post a Comment