nand2tetris/projects/02/HalfAdder.hdl

19 lines
412 B
VHDL
Raw Normal View History

2020-05-19 12:42:52 +00:00
// This file is part of www.nand2tetris.org
// and the book "The Elements of Computing Systems"
// by Nisan and Schocken, MIT Press.
// File name: projects/02/HalfAdder.hdl
/**
* Computes the sum of two bits.
*/
CHIP HalfAdder {
IN a, b; // 1-bit inputs
2020-05-20 09:52:50 +00:00
OUT sum, // Right bit of a + b
2020-05-19 12:42:52 +00:00
carry; // Left bit of a + b
PARTS:
2020-05-20 09:52:50 +00:00
Xor(a=a, b=b, out=sum);
And(a=a, b=b, out=carry);
2020-05-19 12:42:52 +00:00
}