Thank you!! I think I figured it out.
This is what I got:
And(a=b, b=sel, out=b1);
And(a=a, b=nsel, out=ar);
Or(a=ar, b=b1, out=out);
so the first one returns b when sel is 1 (not 0)
and the second and return a when sel is 0 (so i does the same thing with the first and but after i changed it to the opposite meaning,1 )
and then the Or statement is to see which one needs to be returned.
if sel was 0
that means that the first and will always return 0 therefore not affecting the last or statement
if sel was 1
then the second and will return 0 therefore not affecting the last or statement
if i got this right, I hope I did
Yes, that is correct. And for these smaller gates the course material includes full tests. So if the tests pass you know it's working correctly.
There are more "mechanical" ways to come up with implementation for this, in the sense that you just follow a few steps and you get the result. You can search for "from truth table to normal form" (DNF and CNF are the two normal forms so you may see this in the results) and for "Karnaugh map" (often abbreviated as K-Maps). Both are good to know, but they are impractical to use for bigger and more complex gates.