Internal buses

Posted by Polo on
URL: http://nand2tetris-questions-and-answers-forum.52.s1.nabble.com/Internal-buses-tp4026592.html

Hello,

I have a problem with internal bus :

Between two Multi-Bit gates, we don't need to write the whidth of the bus ?
I mean that we should write it like that ? :

CHIP test {
        IN a[16], b[16];
        OUT out[16];
       
        PARTS:
        Add16(a=a, b=b, out=addab);
        Not16(in=addab, out=notaddab);
}

And then, between one 16-bits gate and 16 one-bit gate, how do i have to write it ?

CHIP test {
        IN a[16], b[16];
        OUT out[16];
       
        PARTS:
        Add16(a=a, b=b, out=addab);
        Not16(in=addab, out=notaddab);
       
        Not(in=?, out=out[0]);
        Not(in=?, out=out[1]);
        Not(in=?, out=out[2]);
        Not(in=?, out=out[3]);
        Not(in=?, out=out[4]);
        Not(in=?, out=out[5]);
        Not(in=?, out=out[6]);
        Not(in=?, out=out[7]);
        Not(in=?, out=out[8]);
        Not(in=?, out=out[9]);
        Not(in=?, out=out[10]);
        Not(in=?, out=out[11]);
        Not(in=?, out=out[12]);
        Not(in=?, out=out[13]);
        Not(in=?, out=out[14]);
        Not(in=?, out=out[15]);
}

And finally, if I want to implement a 16-bit Adder after 32 1-bit gates (just an example) :

CHIP test {
        IN a[16], b[16];
        OUT out[16];
       
        PARTS:
       
        Not(in=a[0], out=?);
        Not(in=a[1], out=?);
        Not(in=a[2], out=?);
        Not(in=a[3], out=?);
        Not(in=a[4], out=?);
        Not(in=a[5], out=?);
        Not(in=a[6], out=?);
        Not(in=a[7], out=?);
        Not(in=a[8], out=?);
        Not(in=a[9], out=?);
        Not(in=a[10], out=?);
        Not(in=a[11], out=?);
        Not(in=a[12], out=?);
        Not(in=a[13], out=?);
        Not(in=a[14], out=?);
        Not(in=a[15], out=?);
       
        Not(in=b[0], out=?);
        Not(in=b[1], out=?);
        Not(in=b[2], out=?);
        Not(in=b[3], out=?);
        Not(in=b[4], out=?);
        Not(in=b[5], out=?);
        Not(in=b[6], out=?);
        Not(in=b[7], out=?);
        Not(in=b[8], out=?);
        Not(in=b[9], out=?);
        Not(in=b[10], out=?);
        Not(in=b[11], out=?);
        Not(in=b[12], out=?);
        Not(in=b[13], out=?);
        Not(in=b[14], out=?);
        Not(in=b[15], out=?);
       
        Add16(a=?, b=?, out=out[16]);
       
}

Hope you will understand what is my problem (i'm french, and not really bilingual   )