Activity 6 : Build MUX by using (NAND, OR, AND, NOT)
Write truth table -> canonical form
/**
* Multiplexor. If sel==1 then out=b else out=a.
*/
CHIP Mux {
IN a, b, sel;
OUT out;
PARTS:
// Put your code here.
Not(in=a, out=nota);
Not(in=b, out=notb);
Not(in=sel, out=notsel);
And(a=nota, b=b, out=a1);
And(a=a, b=b, out=a2);
Or(a=a1, b=a2, out=o1);
And(a=sel, b=o1, out=p1);
And(a=a, b=notb, out=a3);
Or(a=a2, b=a3, out=o2);
And(a=notsel, b=o2, out=p2);
Or(a=p1, b=p2, out=out);
}
Write truth table -> canonical form
/**
* Multiplexor. If sel==1 then out=b else out=a.
*/
CHIP Mux {
IN a, b, sel;
OUT out;
PARTS:
// Put your code here.
Not(in=a, out=nota);
Not(in=b, out=notb);
Not(in=sel, out=notsel);
And(a=nota, b=b, out=a1);
And(a=a, b=b, out=a2);
Or(a=a1, b=a2, out=o1);
And(a=sel, b=o1, out=p1);
And(a=a, b=notb, out=a3);
Or(a=a2, b=a3, out=o2);
And(a=notsel, b=o2, out=p2);
Or(a=p1, b=p2, out=out);
}
On simplifying further :
way 2 >
/**
* Multiplexor. If sel==1 then out=b else out=a.
*/
CHIP Mux {
IN a, b, sel;
OUT out;
PARTS:
// Put your code here.
Not(in=a, out=nota);
Not(in=b, out=notb);
Not(in=sel, out=notsel);
And(a=a, b=b, out=a3);
And(a=nota, b=b, out=t1);
And(a=t1, b=sel, out=a1);
And(a=a, b=notb, out=t2);
And(a=t2, b=notsel, out=a2);
Or(a=a1, b=a2, out=o1);
Or(a=o1, b=a3, out=out);
}
Both the above solutions were built sequentially. Now its time to shorten it..
way 3>
/**
* Multiplexor. If sel==1 then out=b else out=a.
*/
CHIP Mux {
IN a, b, sel;
OUT out;
PARTS:
// Put your code here.
Not(in=sel, out=notsel);
And(a=a, b=notsel, out=w1);
And(a=b, b=sel, out=w2);
Or(a=w1, b=w2, out=out);
}
Downloads :
No comments:
Post a Comment