/** * 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: Inc16(in=w1,out=w2); Mux16(a=w1,b=w2,sel=inc,out=w3); Mux16(a=w3,b=in,sel=load,out=w4); And16(a=w1,b=false,out=w5); Mux16(a=w4,b=w5,sel=reset,out=w6); Register(in=w6,load=true,out=w1,out=out); }