Tuesday, November 20, 2012

Boolean Logic : Activity 5

Activity 5 : Build XOR from primitive NAND



// This file is part of the materials accompanying the book 
// "The Elements of Computing Systems" by Nisan and Schocken, 
// MIT Press. Book site: www.idc.ac.il/tecs
// File name: projects/01/Xor.hdl

/**
 *  Exclusive-or gate: out = !(a == b).
 */

CHIP Xor {

    IN a, b;
    OUT out;

    PARTS:
    // Put your code here.
    Nand(a=a, b=a, out=nota);
    Nand(a=b, b=b, out=notb);

    Nand(a=a, b=notb, out=w1);
    Nand(a=w1, b=w1, out=a1);

    Nand(a=nota, b=b, out=w2);
    Nand(a=w2, b=w2, out=a2);


    Nand(a=a1, b=a1, out=p1);
    Nand(a=a2, b=a2, out=p2);
    Nand(a=p1, b=p2, out=out);

    
}

////////////////////////////////////////////////////

hmm.. so what we do is make truth table - write canonical rep - and replace the and, or and not def with those of nand which we found out in previous activities.

truth table -> canonical form -> substitute nand def






Downloads : 



No comments:

Post a Comment