And.hdl

And.hdl

Hello,

I have got this right but I would like to know the following

Nand(a=a,b=b,out=w);
Nand (a=w, b=w, out=out);

1)How I can show the expression as one statement instead of two.

2)I am confused with the second Nand gate I have used. Shouldn't the Nand gate take 2 inputs. I kind of get it but in the explanations I have seen the output from the first Nand gate goes out as a single line of of input into the second Nand gate into a box (that's what I call, sorry for my ignorance). To me it looks like a Not gate.

Once again many thanks to Mark and others for being so patient and doing such a wonderful work.

Re: And.hdl

The first thing that you need to understand is that HDL is not a programming language; it is a Hardware Description Language. It describes the connections of wires in a circuit diagram.

When you write something like
Part1(..., out=w);
Part2(a=w, b=w, ...);
you are describing a wire that connects from the output of Part1 to both input A and input B of Part2.

In your case, since you have already written your Not gate, you should use it as the second part in your And, rather than using 2 Nand gates.

This is why you should make and test the parts in the order that they are presented in the book. Each part you make can use the earlier parts as building blocks. Some of the parts you will make would require hundreds of Nand gates it that was the only kind of gate you used.