Skip to content
4YCAaaa edited this page Jan 4, 2023 · 1 revision
  • Adds two 16-bit values.
  • The most significant carry bit is ignored.
CHIP Add16 {
    IN a[16], b[16];
    OUT out[16];

    PARTS:
   // Put you code here:
   FullAdder(a=a[0],b=b[0],c=false,carry=d,sum=out[0]);
   FullAdder(a=a[1],b=b[1],c=d,carry=e,sum=out[1]);
   FullAdder(a=a[2],b=b[2],c=e,carry=f,sum=out[2]);
   FullAdder(a=a[3],b=b[3],c=f,carry=g,sum=out[3]);
   FullAdder(a=a[4],b=b[4],c=g,carry=h,sum=out[4]);
   FullAdder(a=a[5],b=b[5],c=h,carry=i,sum=out[5]);
   FullAdder(a=a[6],b=b[6],c=i,carry=j,sum=out[6]);
   FullAdder(a=a[7],b=b[7],c=j,carry=k,sum=out[7]);
   FullAdder(a=a[8],b=b[8],c=k,carry=l,sum=out[8]);
   FullAdder(a=a[9],b=b[9],c=l,carry=m,sum=out[9]);
   FullAdder(a=a[10],b=b[10],c=m,carry=n,sum=out[10]);
   FullAdder(a=a[11],b=b[11],c=n,carry=o,sum=out[11]);
   FullAdder(a=a[12],b=b[12],c=o,carry=p,sum=out[12]);
   FullAdder(a=a[13],b=b[13],c=p,carry=q,sum=out[13]);
   FullAdder(a=a[14],b=b[14],c=q,carry=r,sum=out[14]);
   FullAdder(a=a[15],b=b[15],c=r,carry=s,sum=out[15]);
}
Clone this wiki locally