I am trying to build a PC CHIP, but am getting the error message, Line 19, out(8) and out(16) have different bus widths

```
// 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);
  
}   
```

getting the error message, Line 19, out(8) and out(16) have different bus widths. Im not sure what im doing wrong here could someone help.

1

There are 1 answers

0
MadOverlord On

When I run your code, I get a different error: Line 26, incIn has no source pin. Also, you've got outputs from one component feeding into input for prior components, which is not illegal but it does make your logic harder to follow; when possible you want the flow of data through the chip to be top to bottom.

You may wish to rethink your design with this kind of flow in mind. One thing to keep in mind is that in addition to the explicit input value you also have an implicit input value (the register).

A simple design pattern that may help you is to first derive all the possible outputs (the 4 listed in the instructions), then use a chain of Muxes to pass through the correct value and store it in the register at the end of the chip.