|
Here's a 4 bit multiplier... simple to extend.
CHIP Mul4 {
IN a[4], b[4];
OUT sum[8];
PARTS:
Mux16(b[0..3]=a[0..3], b[4..15]=false, a[0..15]=false, sel=b[0], out=s1);
Mux16(b[1..4]=a[0..3], b[5..15]=false, b[0]=false, a[0..15]=false, sel=b[1], out=s2);
Mux16(b[2..5]=a[0..3], b[6..15]=false, b[0..1]=false, a[0..15]=false, sel=b[2], out=s3);
Mux16(b[3..6]=a[0..3], b[7..15]=false, b[0..2]=false, a[0..15]=false, sel=b[3], out=s4);
Add16(a=s1, b=s2, out=i1);
Add16(a=s3, b=s4, out=i2);
Add16(a=i1, b=i2, out[0..7]=sum);
}
|