Login  Register

Re: Stuck on PC

Posted by Nandy on May 11, 2021; 8:40am
URL: http://nand2tetris-questions-and-answers-forum.52.s1.nabble.com/Stuck-on-PC-tp4033903p4035995.html

Does the order of statements matter in PC?

Why does the first part works but not the second in the code below?

CHIP PC {
    IN in[16],load,inc,reset;
    OUT out[16];

    PARTS:
    // Put your code here:
/***/
    Inc16(in=oo, out=o1);//Add
    Mux16(a=oo, b=o1, sel=inc, out=o2);
   
    Mux16(a=o2, b=in, sel=load, out=o3); //write
   
    Mux16(a=o3, b=false, sel=reset, out=o4); //reset
   
    Register(in=o4, load=true, out=out, out=oo);
   
/***    
    Mux16(a=oo, b=in, sel=load, out=o1); //write
   
    Mux16(a=o1, b=false, sel=reset, out=o2); //reset
   
    Inc16(in=o2, out=o3);//Add
    Mux16(a=o2, b=o3, sel=inc, out=o4);
   
   
    Register(in=o4, load=true, out=out, out=oo);
   
***/
}