16bit Mux

Posted by NanD on
URL: http://nand2tetris-questions-and-answers-forum.52.s1.nabble.com/16bit-Mux-tp4025605.html

I am not sure how to approach this one.

    Not(in=sel, out=notsel);
        And16(a[0..15]=a, b[0..15]=notsel, out[0..15]=out1);
        And16(a[0..15]=b, b[0..15]=sel, out[0..15]=out2);
        Not16(in[0..15]=out1, out[0..15]=notout1);
        Not16(in[0..15]=out2, out[0..15]=notout2);
        And16(a[0..15]=notout1, b[0..15]=notout2, out[0..15]=out3);
        Not16(in[0..15]=out3, out[0..15]=out);

That was my attempted solution, but HDL tells me that I can't put the value of the single bus 'sel' and 'notsel' into all 16 buses of the 16bit gates.

Does this just mean I have to expand everything out? Or is there a way to turn 'sel' into 16 bits of the same value?

Thanks!