Mux gate

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

Mux gate

ron2308
I would be grateful for assistance  - what is wrong with my code.
I'm copying it here - no respond from the simulator, but it did not work out.
I made it according to the DNF

    PARTS:
    // Put your code here:
        Not (in=sel, out=notsel);
        And (a=a, b=notsel, out=w1);
        And (a=sel, b=b, out=w2);
        Xor (a=w1, b=w2, out=out);
}
Thank you, Ron
Reply | Threaded
Open this post in threaded view
|

Re: Mux gate

WBahn
Administrator
That should work, assuming you've implemented all of the other parts.

While an Xor will work, the typical implementation simply uses an Or.
Reply | Threaded
Open this post in threaded view
|

Re: Mux gate

ron2308
Thank you very much, I'm grateful for your answer.
I thought of the option of or,
but some how I have in mind that "sel" appears as  avariable of 0 and 1 simultaneosly, in order to give the value 1.
I know there is a logicel mistake in my mind, I cannot find it.

Thanks,
rou
Reply | Threaded
Open this post in threaded view
|

Re: Mux gate

WBahn
Administrator
No signal can be 0 and 1 simultaneously (this isn't quantum computing!).

Your 'sel' and 'notsel' are mutually exclusive -- one of them is a 0 and the other is a 1. When you And them with their respective inputs, the one that is 0 forces the output of that channel to be 0 regardless of the value of the input. If one input to an Or or an Xor is 0, then the output is equal to the other input. Hence they become equivalent in this instance.
Reply | Threaded
Open this post in threaded view
|

Re: Mux gate

ron2308
Thank you very much,
Ron