73 lines
1.0 KiB
TypeScript
73 lines
1.0 KiB
TypeScript
export const cmp = `| a | b |sel|out|
|
|
| 0 | 0 | 0 | 0 |
|
|
| 0 | 0 | 1 | 0 |
|
|
| 0 | 1 | 0 | 0 |
|
|
| 0 | 1 | 1 | 1 |
|
|
| 1 | 0 | 0 | 1 |
|
|
| 1 | 0 | 1 | 0 |
|
|
| 1 | 1 | 0 | 1 |
|
|
| 1 | 1 | 1 | 1 |`;
|
|
export const hdl = `// 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/1/Mux.hdl
|
|
/**
|
|
* Multiplexor:
|
|
* if (sel = 0) out = a, else out = b
|
|
*/
|
|
CHIP Mux {
|
|
IN a, b, sel;
|
|
OUT out;
|
|
|
|
PARTS:
|
|
//// Replace this comment with your code.
|
|
}`;
|
|
export const tst = `// 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/1/Mux.tst
|
|
|
|
load Mux.hdl,
|
|
compare-to Mux.cmp,
|
|
output-list a b sel out;
|
|
|
|
set a 0,
|
|
set b 0,
|
|
set sel 0,
|
|
eval,
|
|
output;
|
|
|
|
set sel 1,
|
|
eval,
|
|
output;
|
|
|
|
set a 0,
|
|
set b 1,
|
|
set sel 0,
|
|
eval,
|
|
output;
|
|
|
|
set sel 1,
|
|
eval,
|
|
output;
|
|
|
|
set a 1,
|
|
set b 0,
|
|
set sel 0,
|
|
eval,
|
|
output;
|
|
|
|
set sel 1,
|
|
eval,
|
|
output;
|
|
|
|
set a 1,
|
|
set b 1,
|
|
set sel 0,
|
|
eval,
|
|
output;
|
|
|
|
set sel 1,
|
|
eval,
|
|
output;`;
|