PageRenderTime 19ms CodeModel.GetById 16ms app.highlight 1ms RepoModel.GetById 1ms app.codeStats 0ms

/1/Or.hdl

http://github.com/happy4crazy/elements_of_computing_systems
Unknown | 28 lines | 22 code | 6 blank | 0 comment | 0 complexity | e8981e1f6d23e0c0a7ca8a7a281bf18e MD5 | raw file
 1// This file is part of the materials accompanying the book 
 2// "The Elements of Computing Systems" by Nisan and Schocken, 
 3// MIT Press. Book site: www.idc.ac.il/tecs
 4// File name: projects/01/Or.hdl
 5
 6/**
 7 * Or gate. out = a or b
 8 */
 9
10/**
11 * x + y = not( not(x) not(y))
12 */
13
14CHIP Or {
15
16    IN  a, b;
17    OUT out;
18
19    PARTS:
20    // Nand(a=a, b=a, out=left);
21    // Nand(a=b, b=b, out=right);
22    // Nand(a=left, b=right, out=out);
23
24    Not(in=a, out=nota);
25    Not(in=b, out=notb);
26    And(a=nota, b=notb, out=neitheranorb);
27    Not(in=neitheranorb, out=out);
28}