Login  Register

Re: My submission says my ALU failed but when I test it on my side it passes?

Posted by MichaelJohnOB on Dec 02, 2023; 2:42am
URL: http://nand2tetris-questions-and-answers-forum.52.s1.nabble.com/My-submission-says-my-ALU-failed-but-when-I-test-it-on-my-side-it-passes-tp4037502p4037505.html

Screen_Shot_2023-12-01_at_9.png

Here is a screenshot of my submission. It says that it fails at line 3. But when I run it on my side, it works just fine.

Here is my code if it helps:

    //FOR X

    Mux16(a=x, b=false, sel= zx, out=outx);

    Not16(in=outx, out=notfinalx);

    Mux16(a=outx, b=notfinalx, sel= nx, out=outfinalx);

    //FOR Y

    Mux16(a=y, b=false, sel= zy, out=outy);

    Not16(in=outy, out=notfinaly);

    //select between x and notx based on zx

    Mux16(a=outy, b=notfinaly, sel= ny, out=outfinaly);

    //For F

    And16(a=outfinalx, b=outfinaly, out=andfinalxy);

    Add16(a=outfinalx, b=outfinaly, out=addfinalxy);

    Mux16(a=andfinalxy, b=addfinalxy, sel= f, out=outxy);

    //For no

    Not16(in=outxy, out=notxandy);

    Mux16(a=outxy, b=notxandy, sel= no, out=out, out=out1);

    //For zr

    And16(a=out1, b=false, out[0..7]=finalout1, out[8..15]=finalout2);

    Or8Way(in=finalout1, out=orout1);

    Or8Way(in=finalout2, out=orout2);

    Or(a=orout1, b=orout2, out=finalorout);

    Mux(a=true, b=false, sel= finalorout, out=zr);

    //For ng

    Mux(a=false, b=true, sel= finalorout, out=ng);