Hardware Simulator

classic Classic list List threaded Threaded
5 messages Options
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Hardware Simulator

bmurch
Using CentOS 6.5. The Hardware simulator runs, but doesn't produce expected results?
eg:
the Or, And, and sometimes Not (when a=0) do not seem to work:
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/Xor.hdl

/**
 * Exclusive-or gate:
 * out = not (a == b)
 */

CHIP Xor {
    IN a, b;
    OUT out;

    PARTS:
    // Put your code here:
        Or(a=a, b=b, out=w1);
        Nand(a=a, b=b, out=w2);
        And(a=w1, b=w2, out=out);
}

Script Produces:
|   a   |   b   |  out  |
|   0   |   0   |   0   |
|   0   |   1   |   0   |
|   1   |   0   |   0   |
|   1   |   1   |   0   |

And this from the book example:
// 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/Xor.hdl

/**
 * Exclusive-or gate:
 * out = not (a == b)
 */

CHIP Xor {
    IN a, b;
    OUT out;

    PARTS:
    // Put your code here:
        Not(in=a, out=nota);
        Not(in=b, out=notb);
        And(a=a, b=notb, out=w1);
        And(a=nota, b=b, out=w2);
        Or(a=w1, b=w2, out=out);
}

Also Produces:
|   a   |   b   |  out  |
|   0   |   0   |   0   |
|   0   |   1   |   0   |
|   1   |   0   |   0   |
|   1   |   1   |   0   |
nota fails a=0 in out=0
notb works a=1 in out=0
And fails a=0 and b=0, zero out should be 1
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: Hardware Simulator

cadet1620
Administrator
bmurch wrote
Using CentOS 6.5. The Hardware simulator runs, but doesn't produce expected results?
eg:
the Or, And, and sometimes Not (when a=0) do not seem to work:
...
[Xor.tst] Script Produces:
|   a   |   b   |  out  |
|   0   |   0   |   0   |
|   0   |   1   |   0   |
|   1   |   0   |   0   |
|   1   |   1   |   0   |
I see in the titles of your screen shots that you are working in the projects/01 directory.

Have you implemented and tested the Not, And and Or chips? The prototype files for all parts in the projects\01 directory have no implementation so their outputs will always be 0, as you are describing.

--Mark
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: Hardware Simulator

bmurch
No I have not. I will do that. I just tried the first one in the book to see if things were working properly. I will work on the And, Not and Or chips first. I didn't even think of that.

Thanks
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: Hardware Simulator

cadet1620
Administrator
One thing you can do is to put Xor.hdl, Xor.tst and Xor.cmp in an otherwise empty directory and play with them. That will force the Hardware Simulator to use its built-in implementations of the other chips.

--Mark
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: Hardware Simulator

GalenaAlysonCanada
Thank you.  I had the same confusion...  :-)
Loading...