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
// internal signal decleration 
wire ripple_sum_1, ripple_carry_1, ripple_carry_2, ripple_sum_2; 
// the first half adder 
half_adder unit_1 
(
    .a    ( a             ),
    .b    ( b             ),
    .sum  ( ripple_sum_1  ),
    .carry( ripple_carry_1)
) ; 
// the second half adder 
half_adder unit_2 
(
    .a    ( ripple_sum_1  ),
    .b    ( cin           ),
    .sum  ( ripple_sum_2  ),
    .carry( ripple_carry_2)
) ;
// output signal 
assign sum  = ripple_sum_2 ; 
assign cout = ripple_carry_2|ripple_carry_1; 
endmodule

 

Was this helpful?
Upvote
Downvote