/////////////////////////////////////////////////////////////////////////////// // File Downloaded from http://www.nandland.com /////////////////////////////////////////////////////////////////////////////// module full_adder ( i_bit1, i_bit2, i_carry, o_sum, o_carry ); input i_bit1; input i_bit2; input i_carry; output o_sum; output o_carry; wire w_WIRE_1; wire w_WIRE_2; wire w_WIRE_3; assign w_WIRE_1 = i_bit1 ^ i_bit2; assign w_WIRE_2 = w_WIRE_1 & i_carry; assign w_WIRE_3 = i_bit1 & i_bit2; assign o_sum = w_WIRE_1 ^ i_carry; assign o_carry = w_WIRE_2 | w_WIRE_3; // FYI: Code above using wires will produce the same results as: // assign o_sum = i_bit1 ^ i_bit2 ^ i_carry; // assign o_carry = (i_bit1 ^ i_bit2) & i_carry) | (i_bit1 & i_bit2); // Wires are just used to be explicit. endmodule // full_adder module carry_lookahead_adder #(parameter WIDTH) ( input logic[WIDTH-1:0] i_add1, input logic[WIDTH-1:0] i_add2, output [WIDTH:0] o_result ); wire [WIDTH:0] w_C; wire [WIDTH-1:0] w_SUM; logic [WIDTH-1:0] w_G, w_P; // Create the Full Adders genvar ii; generate for (ii=0; ii