Hello, I'm having problems to test my ALU.hdl file. It doesn't open at all in the Hardware Simulator, and I've tried different implementations that I found on the Internet just to see if it was my code's fault, but none of them have worked. The Hardware Simulator has worked for all of the previous chips successfully, so I don't know what is wrong.
Here's the code that I wrote:
CHIP ALU {
IN
x[16], y[16], // 16-bit 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]; // 16-bit output
zr, // 1 if (out == 0), 0 otherwise
ng; // 1 if (out < 0), 0 otherwise
PARTS:
Mux16 (a=x, b[0..15]=false, sel=zx, out=zxOUT); //Zero the x
Not16 (in=zxOUT, out=notZX); //Negate x
Mux16 (a=zxOUT, b=notZX, sel=nx, out=nxOUT);
Mux16 (a=y, b[0..15]=false, sel=zy, out=zyOUT); //Zero the y
Not16 (in=zyOUT, out=notZY); //Negate y
Mux16 (a=zyOUT, b=notZY, sel=ny, out=nyOUT);
Add16 (a=nxOUT, b=nyOUT, out=xPLUSy); //X + Y
And16 (a=nxOUT, b=nyOUT, out=xANDy); //X & Y
Mux16 (a=xANDy, b=xPLUSy, sel=f, out=fOUT);
Not16 (in=fOUT, out=notF); //Negate output
Mux16 (a=fOUT, b=notF, sel=no, out=out);
Nand (a=out[15], b=true, out=ng); //ng
Or8Way (in=out[0..7], out=orLEFT); //zr
Or8Way (in=out[8..15], out=orRIGHT);
Or (in=orLEFT, b=orRIGHT, out=orOUT);
Not (in=orOUT, out=zr);
}