HDL-PC.HDL,但从x2 8位寄存器开始

HDL-PC.HDL,但从x2 8位寄存器开始,hdl,nand2tetris,Hdl,Nand2tetris,所以,我基本上需要创建一个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

所以,我基本上需要创建一个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位加法器,您可以使用两个加法器实现一个16位递增器,其中一个计算currentLow+1,另一个计算currentHigh+(低位加法器的进位输出)

谢谢。你能帮我了解一下这个实现的代码吗?我有一个“Add8”芯片。我特别不确定如何在这种HDL语言中进行像“currentLow+1”这样的整数加法。Stackoverflow的意义不是为你做作业,而是帮助你理解做作业需要知道什么。如果您有一个8位加法器,您可以通过将其中一个输入设置为00000001的固定值,使其成为递增器。一旦你弄明白了怎么做,其他8位应该很容易。也就是说,递增式是加法的一种非常特殊的情况。我建议您回过头来学习上一个半加法器的经验教训,并考虑如何将该功能单元连接起来,以提供一个只向输入端添加一个电路的电路。