0

这是一个例子来说明我的意思。如果我在我的 中包含以下内容ALU,则无效:

chip ALU {
  // ...
  PARTS:
  // out4 is the output of some internal chip
  Or8Way(
    in[0..7]=out4[0..7],
    out=outa
  );

  Or8Way(
    in[0..7]=out4[8..15],
    out=outb
  );

  Or(a=outa, b=outb, out=out);
}

但是……如果我把那个代码块做成自己的Or16Way芯片,

CHIP Or16Way {
    IN in[16];
    OUT out;

    PARTS:
    Or8Way(
        in[0..7]=in[0..7],
        out=out0
    );

    Or8Way(
        in[0..7]=in[8..15],
        out=out1
    );

    Or(a=out0, b=out1, out=out);

}

然后在 中使用它ALU

ALU {
  // ...
  Parts:
    Or16Way(in=out4, out=or);
}

一切安好。为什么是这样?在一种情况下,我索引了输入引脚,在另一种情况下,我索引了内部引脚。为什么一个允许,另一个不允许?

4

0 回答 0