如何解决HDL-PC.hdl,但从x2 8位寄存器开始
因此,我基本上需要创建一个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位寄存器来执行此操作。
有人可以帮助我提供正确的解决方案吗?
谢谢。
解决方法
假设您有一个8位加法器,则可以使用2个加法器实现一个16位加法器,一个加法器计算currentLow + 1,另一个加法器计算currentHigh +(低位加法器的输出)
版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 dio@foxmail.com 举报,一经查实,本站将立刻删除。