+/TECS
git clone https://git.julia.blue/+/TECS
5e97a3a
v1.0
1/** 2 * A 16-bit counter with load and reset control bits. 3 * if (reset[t] == 1) out[t+1] = 0 4 * else if (load[t] == 1) out[t+1] = in[t] 5 * else if (inc[t] == 1) out[t+1] = out[t] + 1 (integer addition) 6 * else out[t+1] = out[t] 7 */ 8 9CHIP PC { 10 IN in[16],load,inc,reset; 11 OUT out[16]; 12 13 PARTS: 14 Inc16(in=w1,out=w2); 15 Mux16(a=w1,b=w2,sel=inc,out=w3); 16 Mux16(a=w3,b=in,sel=load,out=w4); 17 And16(a=w1,b=false,out=w5); 18 Mux16(a=w4,b=w5,sel=reset,out=w6); 19 Register(in=w6,load=true,out=w1,out=out); 20}