Login  Register

Stuck on PC

Posted by mwy on Nov 20, 2019; 8:08pm
URL: http://nand2tetris-questions-and-answers-forum.52.s1.nabble.com/Stuck-on-PC-tp4033903.html

Here is what I have tried so far but it seems to be stuck on line 4:


```
/**
 * A 16-bit counter with load and reset control bits.
 * if      (reset[t] == 1) out[t+1] = 0
 * else if (load[t] == 1)  out[t+1] = in[t]
 * else if (inc[t] == 1)   out[t+1] = out[t] + 1  (integer addition)
 * else                    out[t+1] = out[t]
 */

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

    PARTS:



    Mux16(a=in, b=false, sel=reset, out=outa);

    Register(in=outa, load=load, out=regout);

    Mux16(a=outa, b=regout, sel=load, out=loadout);

    Inc16(in=regout, out=reginc);



    Mux16(a=loadout, b=reginc, sel=inc, out=out);

}```


I am still trying to figure out what I am doing wrong. Any pointers? Some guidance? I see that there are answers on the Internet, but I am trying to figure it on my own.

All help is really appreciated.