所以,我基本上需要创建一个 PC.hdl,但从 x2 8 位寄存器开始。这是起点:
// This file is BASED ON part of www.nand2tetris.org
// and the book "The Elements of Computing Systems"
// by Nisan and Schocken, MIT Press.
// File name: project03starter/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];
PARTS:
// Something to start you off: you need *two* 8-bit registers
Register(in=nextLow, out=out[0..7], out=currentLow, load=true);
Register(in=nextHigh, out=out[8..15], out=currentHigh, load=true);
// Handling 'inc' to increment the 16-bit value also gets tricky
// ... this might be useful
And(a=inc, b=lowIsMax, out=incAndLowIsMax);
// ...
// The rest of your code goes here...
}
我知道如何通过仅处理 16 位来正常执行此操作,但我不确定如何使用 8 位寄存器来解决此问题。
任何人都可以帮助我正确的解决方案吗?
谢谢。