PageRenderTime 574ms CodeModel.GetById 181ms app.highlight 0ms RepoModel.GetById 177ms app.codeStats 0ms

/2/HalfAdder.hdl

http://github.com/happy4crazy/elements_of_computing_systems
Unknown | 20 lines | 16 code | 4 blank | 0 comment | 0 complexity | 33d322f07d60d5fe889c47ee7bb892c8 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/02/HalfAdder.hdl
 5
 6/**
 7 * Half adder. Computes sum, the least significnat bit of a + b,
 8 * and carry, the most significnat bit of a + b.
 9 */
10
11CHIP HalfAdder {
12
13    IN  a, b;
14    OUT sum,   // LSB of a + b
15        carry; // MSB of a + b
16
17    PARTS:
18    Xor(a=a, b=b, out=sum);
19    And(a=a, b=b, out=carry);
20}