Hi All,
Please Help!!!
I have been able to implement And gate, Or gate, Not gate from Nand gate.
However, I am unable to implement the And16 gate as I cannot find the syntax to do so. I have tried the following but none of these work:
1:
// This file is part of www.nand2tetris.org
// and the book "The Elements of Computing Systems"
// by Nisan and Schocken, MIT Press.
// File name: projects/1/And16.hdl
/**
* 16-bit And gate:
* for i = 0, ..., 15:
* out[i] = a[i] And b[i]
* select Format in Hardware simulator to binary
*/
CHIP And16 {
IN a[16], b[16];
OUT out[16];
PARTS:
And(a[16]=a[0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15], b[16]=b[0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15], out[16);
}
2:
// This file is part of www.nand2tetris.org
// and the book "The Elements of Computing Systems"
// by Nisan and Schocken, MIT Press.
// File name: projects/1/And16.hdl
/**
* 16-bit And gate:
* for i = 0, ..., 15:
* out[i] = a[i] And b[i]
* select Format in Hardware simulator to binary
*/
CHIP And16 {
IN a[16], b[16];
OUT out[16];
PARTS:
And(a[0..16]=0, b[0..16]=1, out[16]);
}
3:
// This file is part of www.nand2tetris.org
// and the book "The Elements of Computing Systems"
// by Nisan and Schocken, MIT Press.
// File name: projects/1/And16.hdl
/**
* 16-bit And gate:
* for i = 0, ..., 15:
* out[i] = a[i] And b[i]
* select Format in Hardware simulator to binary
*/
CHIP And16 {
IN a[16], b[16];
OUT out[16];
PARTS:
And(a=a[0], b=b[0], out);
And(a=a[1], b=b[1], out);
And(a=a[2], b=b[2], out]);
And(a=a[3], b=b[3], out);
And(a=a[4], b=b[4], out);
And(a=a[5], b=b[5], out);
And(a=a[6], b=b[6], out);
And(a=a[7], b=b[7], out);
And(a=a[8], b=b[8], out);
And(a=a[9], b=b[9], out};
And(a=a[10], b=b[10], out);
And(a=a[11], b=b[11], out);
And(a=a[12], b=b[12], out);
And(a=a[13], b=b[13], out);
And(a=a[14], b=b[14], out);
And(a=a[15], b=b[15], out);
}
John