我正在尝试构建 PC 芯片,但收到错误消息,第 19 行、out(8) 和 out(16) 具有不同的总线宽度

问题描述 投票:0回答:1

我正在尝试构建 PC 芯片,但收到错误消息,第 19 行、out(8) 和 out(16) 具有不同的总线宽度

```
// 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:
    Register(in=resetMuxOut, load=true, out=out, out=regOut);
    Inc16(in=incIn, out=incOut);

    Mux16(a=loadMuxOut, b[0..15]=false, sel=reset, out=resetMuxOut);
    Mux16(a=incMuxOut, b=in, sel=load, out=loadMuxOut);
    Mux16(a=regOut, b=incOut, sel=inc, out=incMuxOut);
  
}   
```

得到错误信息,19号线,out(8)和out(16)有不同的总线宽度。我不确定我在这里做错了什么有人可以帮忙吗?

hdl nand2tetris
1个回答
0
投票

当我运行你的代码时,我收到一个不同的错误:第 26 行,incIn 没有源引脚。此外,您还可以将一个组件的输出输入到先前组件的输入中,这并不违法,但确实使您的逻辑更难以遵循;如果可能,您希望数据通过芯片的流动是从上到下的。

您可能希望根据这种流程重新考虑您的设计。要记住的一件事是,除了显式输入值之外,您还有隐式输入值(寄存器)。

一个可以帮助您的简单设计模式是首先导出所有可能的输出(指令中列出的 4 个),然后使用多路复用器链传递正确的值并将其存储在芯片末尾的寄存器中.

© www.soinside.com 2019 - 2024. All rights reserved.