module ClaFour( cOut, sum, aOp, bOp, cIn);
output cOut;
output [ 3:0] sum;
input [ 3:0] aOp;
input [ 3:0] bOp;
input cIn;
wire [ 3:0] pro;
wire [ 3:0] gen;
wire [ 3:0] car;
assign car[ 0] = cIn;
genvar bt;
generate
for (bt = 0; bt < 4; bt = bt + 1)
begin
assign pro[ bt] = aOp[ bt] ^ bOp[ bt];
assign gen[ bt] = aOp[ bt] & bOp[ bt];
assign sum[ bt] = pro[ bt] ^ car[ bt];
end
endgenerate
assign car[ 1] = gen[ 0] | cIn & pro[ 0];
assign car[ 2] = gen[ 1] | pro[ 1] & gen[ 0] | pro[ 1] & pro[ 0] & cIn;
assign car[ 3]
= gen[ 2] | pro[ 2] & gen[ 1] | pro[ 2] & pro[ 1] & gen[ 0]
| pro[ 2] & pro[ 1] & pro[ 0] & cIn;
assign cOut
= gen[ 3] | pro[ 3] & gen[ 2] | pro[ 3] & pro[ 2] & gen[ 1]
| pro[ 3] & pro[ 2] & pro[ 1] & gen[ 0]
| pro[ 3] & pro[ 2] & pro[ 1] & pro[ 0] & cIn;
endmodule