PageRenderTime 364ms CodeModel.GetById 181ms app.highlight 0ms RepoModel.GetById 181ms app.codeStats 0ms

/1/Mux.hdl

http://github.com/happy4crazy/elements_of_computing_systems
Unknown | 21 lines | 17 code | 4 blank | 0 comment | 0 complexity | f940861c89c82bf752303eaa0ecf934a 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/Mux.hdl
 5
 6/** 
 7 * Multiplexor.  If sel=0 then out = a else out = b.
 8 * In other words, mux(a,b,s) = a!s + bs
 9 */
10
11CHIP Mux {
12
13    IN  a, b, sel;
14    OUT out;
15
16    PARTS:
17    Not(in=sel,out=notsel);
18    And(a=a, b=notsel, out=left);
19    And(a=b, b=sel, out=right);
20    Or(a=left, b=right, out=out);
21}