Help in code

classic Classic list List threaded Threaded
3 messages Options
Reply | Threaded
Open this post in threaded view
|

Help in code

sarab
Guys i am new to it....I am trying to implement NOT gate....since the implementation is missing from the project file...i am opening the NOT.hdl in notepad and writing this..
// 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/Not.hdl

/**
 * Not gate:
 * out = not in
 */

CHIP Not {
    IN in;
    OUT out;

    PARTS:
Not(in=in,out=out);
}

But when i try to load it , the hardware simulator shows loading chip....but nothing happens...
please help...
Reply | Threaded
Open this post in threaded view
|

Re: Help in code

cadet1620
Administrator
sarab wrote
CHIP Not {
    IN in;
    OUT out;

    PARTS:
Not(in=in,out=out);
}

But when i try to load it , the hardware simulator shows loading chip....but nothing happens...
please help...
The problem is that when the Hardware Simulator tries to load this chip, when it encounters the "Not(in=in,out=out);" part it loads the Not chip which again encounters the "Not(" part which loads the Not chip.... so it gets hung in a loop.

When you are making the Not chip, the only chip that exists is the Nand. Therefore the only chip that can be used in the PARTS: section of the Not is the Nand chip.

Your Not chip must be
CHIP Not {
...
    PARTS:
    Nand(a=___, b=___, out=___);
}
You need to figure out what goes in the blanks.

Once you have made and tested your Not, you can use Nand and Not to build And.

Be sure to read the Hardware Construction Survival Kit.

--Mark
Reply | Threaded
Open this post in threaded view
|

Re: Help in code

sarab
thanx :)