我正在实施第一章的计数器。3. 这是我的代码:
// This file is part of www.nand2tetris.org
// and the book "The Elements of Computing Systems"
// by Nisan and Schocken, MIT Press.
// File name: projects/03/a/PC.hdl
/**
* 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];
//sel=0; a;sel=1;b
PARTS:
//reset
Not16(in=true, out=resetted);
//inc
Inc16(in=t, out=incremented);
//Choose input between reset and out[t]
Mux16(a=t,b=resetted,sel=reset,out=o1);
//Choose input between o1 and in[t](load)
Mux16(a=o1, b=in,sel=load,out=o2);
//Choose input between o2 and inc
Mux16(a=o2,b=incremented, sel=inc, out=o3);
Register(in=o3, load=load, out=t, out=out);
}
在这个测试中似乎失败了:
set in -32123,
tick,
output
这是第 5 行,我找不到我的错误。任何帮助表示赞赏