Write a 4 bit ripple adder that uses instances of this fulladder FA shown below,
ID: 2267741 • Letter: W
Question
Write a 4 bit ripple adder that uses instances of this fulladder FA shown below, A and B are inputs, Cin is the carry in, Sum is the output sum, Cout is the carry out, and OF indicates overflow which is determined by the (carryin to the last bit) xor (the carry out) module FA( input A, B, Cin, output C, Cout ); assign C = (Ang) assign Cout A&B; | A&Cin; | B&Cin; endmodule ACin; // this is you 4 bit ripple adder, fill in your code using instances of FA module FA4(input [3:0] A, B, input Cin, output [3:0] Sum, output Cout, OF );Explanation / Answer
Code : Full Adder
module FA(
input A,B,Cin
output C,Cout
);
assign C = (A^B)^Cin;
assign Cout = A&B | A&Cin | B&Cin;
endmodule
Code : 4 Bit Ripple Carry Adder
module FA4(
input [3:0] A,B,
input Cin
output [3:0] Sum,
output Cout, OF
);
wire c1,c2;
FA FA_1(A[0],B[0],Cin,Sum[0],c1),
FA_2(A[1],B[1],c1,Sum[1],c2),
FA_3(A[2],B[2],c2,Sum[2],OF),
FA_4(A[3],B[3],OF,Sum[3],Cout);
endmodule
Related Questions
Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
drjack9650@gmail.com
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.