2

I am using the HDL from the Nand2Tetris (Elements of Computing Systems) book, and whilst looking at example gate implementations online I regularly notice something along the lines of;

CHIP ExampleZeroer {
    IN a[16], sel;
    OUT out[16];

    PARTS:
    Mux16(a=a, b=false, sel=sel, out=out);
}

In the above example false is never declared anywhere. I see similar examples using the apparent keyword true also. If false is some kind of pre-declared keyword or short-hand then where does the value come from, or what is it short-hand for?

I have implemented all of my gates without using this shorthand but it bothers me that I can't understand where the value could come from.

Rudi Kershaw
  • 12,332
  • 7
  • 52
  • 77

1 Answers1

3

Yes, you can use false and true as inputs. In the context of a chip, they are equivalent to connecting the pin to the power source or the ground.

MadOverlord
  • 1,034
  • 6
  • 11
  • Would you be able to expand on how the power source or ground is accessed from the chip? Wouldn't that require new inputs? – Rudi Kershaw Jul 18 '16 at 14:41
  • 3
    No. All chips are assumed to have power and ground available (because chips don't work without them!), so you always have true and false available. If you want, you can just think of true and false as predefined inputs you always have available. @RudiKershaw – MadOverlord Jul 19 '16 at 15:30