|
/**
* 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:
// Put your code here:
Mux16(a = o1, b = false, sel = reset, out = o0);
Register(in = in, load = load, out = o1);
Inc16(in = o1, out = o2);
Mux16(a = o1, b = o2, sel = inc, out = o3);
Mux16(a = o3, b = o0, sel = reset, out = out);
}
Here is my implementation and I select MUX16 as the fial chip to output result. I cannot figure out what's wrong. Thanks in advanced.
|