How to use helper gates ?

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

How to use helper gates ?

OppaErich
Hi,

for the full adder I built 3WayXor, -And and -Or and used them in FullAdder.hdl. When I try to load this, I get an error "A gate class name is expected."

CHIP FullAdder {
    IN a, b, c;  // 1-bit inputs
    OUT sum,     // Right bit of a + b + c
        carry;   // Left bit of a + b + c

    PARTS:
    // Put you code here:
    3WayXor (... <- Error pointing to this line.

[oppa@oppa-F28 tools]$ cd ../projects/02/
[oppa@oppa-F28 02]$ ls
3WayAnd.hdl  Add16.tst       ALU.tst         FullAdder.tst   HalfAdder.tst
3WayOr.hdl   ALU.cmp         FullAdder.cmp   HalfAdder.cmp   Inc16.cmp
3WayXor.hdl  ALU.hdl         FullAdder.hdl   HalfAdder.hdl   Inc16.hdl
Add16.cmp    ALU-nostat.cmp  FullAdder.hdl~  HalfAdder.hdl~  Inc16.tst
Add16.hdl    ALU-nostat.tst  FullAdder.out   HalfAdder.out

Regards,
Stephan
Reply | Threaded
Open this post in threaded view
|

Re: How to use helper gates ?

cadet1620
Administrator
Part names can not start with a number.

I think that they are limited to characters A-Z, a-z, 0-9.

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

Re: How to use helper gates ?

OppaErich
Hi,

OK. So I renamed those which just yields the next error.

CHIP Xor3In {
    IN a, b, c;  // 1-bit inputs
    OUT out,     // XOR(a,b,c) = a+b+c=1

    PARTS:
    // Put you code here:
    Xor (a=a, b=b, out=axorb);  <- Pin name expected
    Xor (a=axorb, b=c, out=out);
}
Reply | Threaded
Open this post in threaded view
|

Re: How to use helper gates ?

OppaErich
Ha,

gotcha. OUT out,   <- Has to be OUT out;

And the full adder passed each test.
Reply | Threaded
Open this post in threaded view
|

Re: How to use helper gates ?

OppaErich
Hi,

is there something like a library folder where I can put these hdl files for reuse ?

Have fun,
Stephan
Reply | Threaded
Open this post in threaded view
|

Re: How to use helper gates ?

cadet1620
Administrator
OppaErich wrote
is there something like a library folder where I can put these hdl files for reuse ?
You can put them in the nand2tetris/tools/builtInChips directory and they will be found like the other built-in parts.

If you do this, don't forget that you will still need to include them in the projectN.zip files that you submit to Coursera.

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

Re: How to use helper gates ?

Jim Willette
Actually, it is better to leave the built-in chips in that directory and put your own in /nand2tetris/MyChips. They are both searched. They are saved as source, however. Except for those written in Java they are not complied, but rather interpreted. You won't notice the difference.