romasi wrote
Below is my attempt to get a Mux4Way (1-bit) to work as 16-bit.
...
And16(a=a, b[0]=notsel0, b[1..15]=false, out=w1);
The problem with this approach is that you need to connect all 16 of the
b inputs of the And16s to the various
sel[N] and
notselN signals.
And16(a=a, b[0]=notsel0, b[1]=notsel0, b[2]=notsel0, b[3]=notsel0,
b[4]=notsel0, b[5]=notsel0, b[6]=notsel0, b[7]=notsel0,
b[8]=notsel0, b[9]=notsel0, b[10]=notsel0, b[11]=notsel0,
b[12]=notsel0, b[13]=notsel0, b[14]=notsel0, b[15]=notsel0, out=w1);
It's a lot of typing to do this for all the And gates!
If you made a Mux4Way, make the Mux4Way16 using 16 Mux4Ways like you made And16 out of 16 Ands.
To make a Mux4Way16 out of 3 Mux16s, don't think about it as Boolean algebra; think about it functionally. It often helps to think about it from the output working backwards.
If
sel[1] is 0, the output needs to be either
a or
b. If it is 1 the output needs to be either
c or
d.
Mux16 (sel=sel[1], a=ab, b=cd, out=out);
Use 2 more Mux16s to make the
ab and
cd signals.
You can make the Mux8Way16 with 3 muxes using the same technique with a combination of Mux16 and Mux4Way16 parts.
--Mark