AND
CHIP And {
IN a, b;
OUT out;
PARTS:
// Put your code here:
Nand(a=a,b=b,out=ab);
Not(in=ab,out=out);
}
NOT
CHIP Not {
IN in;
OUT out;
PARTS:
// Put your code here:
Nand(a=in, b=in, out=out);
}
OR
CHIP Or {
IN a, b;
OUT out;
PARTS:
// Put your code here:
Not(in=a,out=na);
Not(in=b,out=nb);
Nand(a=na,b=nb,out=out);
}
XOR
CHIP Xor {
IN a, b;
OUT out;
PARTS:
// Put your code here:
Not(in=a,out=na);
Not(in=b,out=nb);
And(a=a,b=nb,out=c1);
And(a=na,b=b,out=c2);
Or(a=c1,b=c2,out=out);
}
MUX
CHIP Mux {
IN a, b, sel;
OUT out;
PARTS:
// Put your code here:
Not(in=sel,out=nsel);
And(a=a,b=nsel,out=c1);
And(a=b,b=sel,out=c2);
Or(a=c1,b=c2,out=out);
}
DMUX
CHIP DMux {
IN in, sel;
OUT a, b;
PARTS:
// Put your code here:
Not(in=sel,out=nsel);
And(a=in,b=nsel,out=a);
And(a=in,b=sel,out=b);
}