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

Write the Verilog code for a two-input, two-bit adder. The inputs are to be set

ID: 3530499 • Letter: W

Question

Write the Verilog code for a two-input, two-bit adder. The inputs are to be set by switches SW0-SW3 the three-bit result is to be displayed on LED0-2. Then write the Verilog code to add two hexadecimal integers stored in 4 bits each. The result should be placed in two hex integers of four bits each. The inputs should be set by SW0-3 and SW4-7. The inputs and the result should display on the four 7-segment displays. The right two displays will be the two addends and the left two displays will be the two hex representations of the sum. A simple google search will give you the Verilog for a 7-segment display decoder. NOTE: the DE0 display is 'on' if the input is 0 and 'o ' if the input is 1. This may require you to modify the output of the 7-segment decode module.

Explanation / Answer

// Full Adder rtl module full_adder (in_x, in_y, carry_in, sum_out, carry_out); input in_x; input in_y; input carry_in; output sum_out; output carry_out; wire w_sum1; wire w_carry1; wire w_carry2; assign carry_out = w_carry1 | w_carry2; // Instantiate two half-adders to make the circuit. half_adder u1_half_adder ( .in_x(in_x), .in_y(in_y), .out_sum(w_sum1), .out_carry(w_carry1) ); half_adder u2_half_adder ( .in_x(w_sum1), .in_y(carry_in), .out_sum(sum_out), .out_carry(w_carry2) ); endmodule

Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Chat Now And Get Quote