//** ******Full Adder ******************
module fulladder(sum, c_out, x, y, c_in);
output sum, c_out;
input x, y, c_in;
wire a, b, c;
xor (a, x, y);
xor (sum, a, c_in);
and (b, x, y);
and (c, a, c_in);
or (c_out, c, b);
endmodule
//********* 4-Bit Adder **********************
module FourBitAdder(sum, c_out, x, y, c_in);
output [3:0] sum;
output c_out;
input [3:0] x, y;
input c_in;
wire c1, c2, c3;
fulladder fa0(sum[0], c1, x[0], y[0], c_in);
fulladder fa1(sum[1], c2, x[1], y[1], c1);
fulladder fa2(sum[2], c3, x[2], y[2], c2);
fulladder fa3(sum[3], c_out, x[3], y[3], c3);
endmodule
