How does one use arrays (representing busses) in HDL?
For example, I have the following code:
/**
* 16-bit bitwise And:
* for i = 0..15: out[i] = (a[i] and b[i])
*/
CHIP And16 {
IN a[16], b[16];
OUT out[16];
PARTS:
// Put your code here:
}
Assuming I have And
already implemented, how could I implement this?
I'd rather not have the following:
And(a=a[0],b=b[0],out=out[0]);
And(a=a[1],b=b[1],out=out[1]);
...
And(a=a[14],b=b[14],out=out[14]);
And(a=a[15],b=b[15],out=out[15]);
There are no arrays in HDL. In section 1.3 of the nand2tetris companion book, he says
So besides writing a trivial script in Python to avoid all that typing, you're not missing anything.