Tuesday, November 20, 2012

Boolean Logic : Activity 3

Activity 3 : Build AND 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/And.hdl

/**
 * And gate: out = 1 if {a==1 and b==1}, 0 otherwise
 */

CHIP And {
    IN a, b;
    OUT out;

    PARTS:
    // Put your code here.
    //Nand(a='Nand(a=a, b=b, out=w1)', b='Nand(a=a, b=b, out=w2)', out=out);
    Nand(a=a, b=b, out=w1);
    Nand(a=w1, b=w1, out=out);
}


////////////////////////////////////////////////////////////////
Another way would be :
Nand(a=a, b=b, out=w1);
Not(in=w1, out=out);


I wonder although if we could write it as Nand(a=Nand(a=a, b=b, out=w1), b=Nand(a=a, b=b, out=w2), out=out);
Am I missing something ??




Downloads:

No comments:

Post a Comment