Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

Design a circuit that can add two 2-digit BCD numbers, A1A0 and B1B0 to produce

ID: 3562116 • Letter: D

Question

Design a circuit that can add two 2-digit BCD numbers, A1A0 and B1B0 to produce the three-digit BCD sum
S2S1S0. Use two instances of your circuit from part IV to build this two-digit BCD adder. Perform the steps
below:
1. Use switches SW15?8 and SW7?0 to represent 2-digit BCD numbers A1A0 and B1B0, respectively. The
value of A1A0 should be displayed on the 7-segment displays HEX7 and HEX6, while B1B0 should be on
HEX5 and HEX4. Display the BCD sum, S2S1S0, on the 7-segment displays HEX2, HEX1 and HEX0.

Note: Part IV asks to do a circuit that adds two BCD digits. I don't have this code yet.

Explanation / Answer

1.bcdadd_1digit.v

module bcdadd_1digit(cin, x, y, s, cout);

            input cin;

            input [3:0] x, y;

            output reg [3:0] s;

            output reg cout;

            reg [4:0] z;

            always@(cin, x, y)

                        begin

                                    z=x+y+cin;

                                    if(z<10) {cout, s}=z;

                                    else {cout, s} = z+6;

                        end

endmodule

bcdadd_2digit.v

module bcdadd_2digit(A1, A0, B1, B0, S2, S1, S0);

            input [3:0] A1, A0, B1, B0;

            output [3:0] S2, S1, S0;

            wire [1:0] C;

             bcdadd_1digit bcd0(1'b0, A0, B0, S0, C[0]);

            bcdadd_1digit bcd1(C[0], A1, B1, S1, C[1]);

            assign S2[3:1] = 3'b000;

            assign S2[0] = C[1];

endmodule

lab2_part3.v

module lab2_part3(SW, LEDR, HEX7, HEX6, HEX5, HEX4, HEX3,

HEX2, HEX1, HEX0);

            input [15:0] SW;

            output [0:6] , HEX7, HEX6, HEX5, HEX4, HEX3, HEX2, HEX1, HEX0;

          output [15:0] LEDR;

           assign LEDR = SW;

            assign HEX3 =7

Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
Chat Now And Get Quote