Administrator
|
You are correct, the Hardware Simulator does not support connecting a 1-bit signal to a multi-bit input, except for true and false which are special constants.
I initially wrote my ALU the same way you are, so I wrote a helper chip I called Bus16 with a 1-bit in and a 16-bit out. It contained
And16(a=true, b[0]=in, b[1]=in, ... b[15]=n, out=out);
Then the code becomes
Bus16(in=zx, out=zx16);
Not16(in=zx16, out=nzx16);
etc.
which isn't too ugly.
As I was writing the rest of the ALU, I realized that there was a way using a single chip from chapter 1 to do the conditional zeroing. I'll let you puzzle that out yourself.
After I got done with the hardware chapters, I went back and did a cleanup pass using things I'd learned about N2T HDL, including rewriting my ALU.
Note that you don't need to write "a[0..15]=x[0..15]"; writing "a=x" means connect all the bits.
--Mark
|