-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathHalfAdder.js
38 lines (34 loc) · 1.04 KB
/
HalfAdder.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
/* HalfAdder
* ===========================================
* "Before you can be full, you must be half" - FullAdder (circa 2018)
*
* The aim of the game here is that imagine the named arguments a, b are
* wires leading into your chip. Each wire can either be a '1' (high) or '0' (low).
* Now imagine there are another two wires, z and c leading out of your chip.
* The HalfAdder's job is twofold. It needs to work out the a + b (z wire)
* and also the carry out of a + b (c wire).
*
* Note: you will need to use the logic gates defined in ../gates
* For example, if you want to use XOR in this chip,
* add the following to the top of the file:
* const XOR = require('../gates/XOR');
*
* TRUTH TABLE
* a | b || z | c
* --------------------------
* 0 | 0 || 0 | 0
* 0 | 1 || 1 | 0
* 1 | 0 || 1 | 0
* 1 | 1 || 0 | 1
*/
const HalfAdder = (() => {
function HalfAdder ({ a, b }) {
// start here
return {
z: '0',
c: '0',
};
};
return HalfAdder;
})();
module.exports = HalfAdder;