0

I'm tryng to build this chip:

// This file is part of www.nand2tetris.org
// and the book "The Elements of Computing Systems"
// by Nisan and Schocken, MIT Press.
// File name: projects/01/Mux4Way16.hdl

/**
 * 4-way 16-bit multiplexor:
 * out = a if sel == 00
 *       b if sel == 01
 *       c if sel == 10
 *       d if sel == 11
 */

CHIP Mux4Way16 {
    IN a[16], b[16], c[16], d[16], sel[2];
    OUT out[16];

    PARTS:
    // Put your code here:

And that what i wrote ontil now -

    PARTS:
    // Put your code here:
    Xor(a=sel[0], b=sel[1], out=finalSel);
    Not(in=finalSel, out=notFinalSel);
    Mux16(a=a, b=b, sel=finalSel, out=aAndB);
    Mux16(a=c, b=d, sel=notFinalSel, out=cAndd);
    Mux16(a=aAndB, b=cAndd, sel=sel[0], out=out);

}

And for some reason it's not working.. Screenshot from the ‏‏HardwareSimulator

someone know why?

Meni
  • 3
  • 1
  • While a Hardware Description Language this isn't VHDL (Very High Scale Integer Circuit Hardware Design Language), See Appendix A of "The Elements of Computing System" by Noam Nisan and Shimon Schocken. The course materials (and simulator) are available through [the official website of Nand to Tetris courses](https://www.nand2tetris.org/) That may preclude help other than through the [tag:nand2tetris] tag. Don't use snippets which are intended for HTML and it's ilk. Pictures aren't adequate as a problem statement. –  Jan 12 '21 at 21:02

1 Answers1

1

Your logic for selecting what input to pass through appears to be incorrect. You should test it by creating a truth table for finalSel, notFinalSel, aAndB, cAndd and out for each of the 4 control conditions.

In general, when doing these kinds of problems, the KISS principle holds; Keep It Simple and Stupid. You don't need any fancy logical manipulation of your sel[] bits, you can just use them directly. So once you get your version fixed (and understand where you went wrong), try doing a version that just consists of 3 Mux16's and nothing else. Once you have both versions working, you'll then understand the error that caused you to go down the wrong path in your first attempt, and that will be a valuable lesson going forward.

Have fun!

MadOverlord
  • 1,034
  • 6
  • 11