I'm unsure why this isn't loading in to the hardware simulator

Posted by Ktesibios on
URL: http://nand2tetris-questions-and-answers-forum.52.s1.nabble.com/I-m-unsure-why-this-isn-t-loading-in-to-the-hardware-simulator-tp4037496.html

I know that the program won't load into the hardware sim, if the program is wrong, however i can't see where I'm going wrong. This is the code that I have made for the CPU. I can't seem to find where I have gone wrong


CHIP CPU {

    IN  inM[16],         // M value input  (M = contents of RAM[A])
        instruction[16], // Instruction for execution
        reset;           // Signals whether to re-start the current
                         // program (reset==1) or continue executing
                         // the current program (reset==0).

    OUT outM[16],        // M value output
        writeM,          // Write to M?
        addressM[15],    // Address in data memory (of M)
        pc[15];          // address of next instruction

    PARTS:
    // Put your code here:
        Mux16(a=aregout, b=inM, sel=instruction[12], out=aluy);
        ALU(x=alux, y=aluy, zx=instruction[11], nx=instruction[10], zy=instruction[9], ny=instruction[8], f=instruction[7], no=instruction[6], out=outM, out=aluout, zr=zr, ng=ng);
        DRegister(in=aluout, load=instruction[4], out=alux);
        ARegister(in=ain, load=instruction[5], out=aregout, out=addressM);
        Mux16(a=instruction, b=aluout, sel=instruction[15], out=ain);
        And(a=instruction[2], b=ng, out=jlt);
        And(a=instruction[1], b=zr, out=jeq);
        Nand(a=zr, b=ng, out=gt);
        And(a=gt, b=instruction[0], out=jgt);
        Or(a=jgt, b=jlt, out=jm);
        Or(a=jr, b=jeq, out=pcl);
        PC(in=aregout, load=pcl, inc=true, reset=reset, out=pc);
        And(a=instruction[3], b=instruction[3], out=writeM);
}