Re: Internal pin to bus

Posted by Christer Nilsson on
URL: http://nand2tetris-questions-and-answers-forum.52.s1.nabble.com/Internal-pin-to-bus-tp4026005p4027763.html

I'm defining Mux16 and I need to expand 1 bit to 16.

So I defined Expand16

CHIP Expand16 {
    IN in;
    OUT out[16];

    PARTS:
   
    Dummy(in=in, out=out[0]);
    Dummy(in=in, out=out[1]);
    Dummy(in=in, out=out[2]);
    Dummy(in=in, out=out[3]);

    Dummy(in=in, out=out[4]);
    Dummy(in=in, out=out[5]);
    Dummy(in=in, out=out[6]);
    Dummy(in=in, out=out[7]);

    Dummy(in=in, out=out[8]);
    Dummy(in=in, out=out[9]);
    Dummy(in=in, out=out[10]);
    Dummy(in=in, out=out[11]);

    Dummy(in=in, out=out[12]);
    Dummy(in=in, out=out[13]);
    Dummy(in=in, out=out[14]);
    Dummy(in=in, out=out[15]);

}

and Dummy:

CHIP Dummy {
    IN in;
    OUT out;

    PARTS:
   
    Not(in=in, out=x);
    Not(in=x, out=out);

}

Then I can define Mux16:

CHIP Mux16 {
    IN a[16], b[16], sel;
    OUT out[16];

    PARTS:
    Expand16(in=sel, out=sel16);
    Not16(in=sel16,  out=nsel16);

    And16(a=nsel16, b=a, out=sela);
    And16(a= sel16, b=b, out=selb);
    Or16(a=sela, b=selb, out=out);

}

Is there a way to expand copper without using expensive gates?