module alu(a,b,s,cin,f,cout,lc);
parameter n=2;
input [n-1:0]a,b;
input [2:0]s;
input cin;
output [n-1:0]f;
output cout;
inout lc;
assign lc=1;
reg [n:0]c;
reg [n-1:0]f;
reg [n-1:0]x,y,z;
reg cout;
integer k;
always @(a or b or s[2] or s[1] or s[0] or cin)
begin
c[0]=cin;
for (k=0;k<n;k=k+1)
begin
x[k]=a[k]|(s[2]&~s[0]&(b[k]^s[1]));
y[k]=(s[0]&b[k])|(s[1]&(~b[k]));
z[k]=(~s[2])&c[k];
f[k]=x[k]^y[k]^z[k];
c[k+1]=(x[k]&y[k])|(y[k]&z[k])|(z[k]&x[k]);
end
cout=c[n]&~s[2];
end
endmodule