Help with And!

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

Help with And!

thespacious
Hello, so you all may think I'm stupid after this but Oh well.
So Here is what I have for my and code:

CHIP And {
    IN a, b;
    OUT out;

    PARTS:
    Not(in=a, out=nota);
    Not(in=a, out=notb);
    Nand(a=nota, b=notb, out=out);
   
}

So yeah, that is wrong, but having in=a, out=notb gets me through the eval for a=0, b=1 I'm just not sure how to tell the simulator to do that same thing but with b when it evals a=1, b=0.

So I figure my approach is just bad, I'm going over the book but I'm just not getting the answers I need, can anyone help?
Reply | Threaded
Open this post in threaded view
|

Re: Help with And!

thespacious
haha, just realized if I fix that typo I made an or gate.
Reply | Threaded
Open this post in threaded view
|

Re: Help with And!

cadet1620
Administrator
In reply to this post by thespacious
thespacious wrote
Hello, so you all may think I'm stupid after this but Oh well.
So Here is what I have for my and code:

...

So yeah, that is wrong, but having in=a, out=notb gets me through the eval for a=0, b=1 I'm just not sure how to tell the simulator to do that same thing but with b when it evals a=1, b=0.

So I figure my approach is just bad, I'm going over the book but I'm just not getting the answers I need, can anyone help?
The only stupid question is the one you don't ask!

The thing to realize here is that the Not function is its own inverse: ~(~x) = x.
How can you use this to remove the Not that's built into the Nand?

BTW, figure out what function your code implements. You'll want it later!

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

Re: Help with And!

thespacious
Figured it out, thanks a ton Mark!