Prev Problem
Next Problem

64. Full Adder

Back To All Submissions
Previous Submission
Next Submission

Solving Approach

How do you plan to solve it?

 

Code

// Half Adder primitive
module half_adder (
    input  a, b,
    output sum, carry
);
    // Write code here
    assign sum = a ^ b;
    assign carry = a & b;
endmodule

// Full Adder using 2 Half Adders
module full_adder_struct (
    input  a, b, cin,
    output sum, cout
);
    // Write code here
    wire t0,t1,t2;
    wire t3,t4,t5;
    half_adder ha0(a,b,t0,t1);
    half_adder ha1(cin,t0,sum,t2);
    half_adder ha2(t1,t2,t3,t4);
    half_adder ha3(t3,t4,cout,t5);
   // or g0(cout,t1,t2);

endmodule

 

Was this helpful?
Upvote
Downvote