
I tried ALU using mux4way16
CHIP ALU {
IN
x[16], y[16], // 16bit inputs
zx, // zero the x input?
nx, // negate the x input?
zy, // zero the y input?
ny, // negate the y input?
f, // compute out = x + y (if 1) or x & y (if 0)
no; // negate the out output?
OUT
out[16], // 16bit output
zr, // 1 if (out == 0), 0 otherwise
ng; // 1 if (out < 0), 0 otherwise
PARTS:
// Put you code here:
Not16(in=x,out=notx);
Mux4Way16(a=x,b=false,c=notx,d=true,sel[0]=zx,sel[1]=nx,out=x1);
Not16(in=y,out=noty);
Mux4Way16(a=y,b=false,c=noty,d=true,sel[0]=zy,sel[1]=ny,out=y1);
Add16(a=x1,b=y1,out=temp1);
And16(a=x1,b=y1,out=temp2);
Mux16(a=temp1,b=temp2,sel=f,out=out1);
Not16(in=out1,out=notout1);
Mux16(a=out1,b=notout1,sel=no,out=out,out[15]=ng,out[0..7]=t1,out[8..15]=t2);
Or8Way(in=t1,out=k1);
Or8Way(in=t2,out=k2);
Or(a=k1,b=k2,out=k3);
Not(in=k3,out=zr);
}
when I am loading script and try to run it it throws me error as comparison failure at line 3
can i know my error
