Status: Tags: Links: HACK CPU - Nand2Tetris Project 5
HACK CPU Implementation
Notes
- Took a lot longer than I expected
- I managed to formulate most of the CPU independently, but had troubles with the control inputs for the registers and mux chips
- I think the main issue that prevented my code from running was the way I calculated the
writeMoutput, as I used anOr Gateinstead of anAnd Gate - It was nice to spend some quality time trying to troubleshoot without the assistane of a compiler :p
- I think the main issue that prevented my code from running was the way I calculated the
Code
|
|
Truth Table
| time | inM | instruction | reset | outM | writeM | addre | pc | DRegister |
|---|---|---|---|---|---|---|---|---|
| 0+ | 0 | 0011000000111001 | 0 | ******* | 0 | 0 | 0 | 0 |
| 1 | 0 | 0011000000111001 | 0 | ******* | 0 | 12345 | 1 | 0 |
| 1+ | 0 | 1110110000010000 | 0 | ******* | 0 | 12345 | 1 | 12345 |
| 2 | 0 | 1110110000010000 | 0 | ******* | 0 | 12345 | 2 | 12345 |
| 2+ | 0 | 0101101110100000 | 0 | ******* | 0 | 12345 | 2 | 12345 |
| 3 | 0 | 0101101110100000 | 0 | ******* | 0 | 23456 | 3 | 12345 |
| 3+ | 0 | 1110000111110000 | 0 | ******* | 0 | 23456 | 3 | 11111 |
| 4 | 0 | 1110000111110000 | 0 | ******* | 0 | 11111 | 4 | 11111 |
| 4+ | 0 | 0000001111101011 | 0 | ******* | 0 | 11111 | 4 | 11111 |
| 5 | 0 | 0000001111101011 | 0 | ******* | 0 | 1003 | 5 | 11111 |
| 5+ | 0 | 1110001100001000 | 0 | 11111 | 1 | 1003 | 5 | 11111 |
| 6 | 0 | 1110001100001000 | 0 | 11111 | 1 | 1003 | 6 | 11111 |
| 6+ | 0 | 0000001111101100 | 0 | ******* | 0 | 1003 | 6 | 11111 |
| 7 | 0 | 0000001111101100 | 0 | ******* | 0 | 1004 | 7 | 11111 |
| 7+ | 0 | 1110001110011000 | 0 | 11110 | 1 | 1004 | 7 | 11110 |
| 8 | 0 | 1110001110011000 | 0 | 11109 | 1 | 1004 | 8 | 11110 |
| 8+ | 0 | 0000001111101000 | 0 | ******* | 0 | 1004 | 8 | 11110 |
| 9 | 0 | 0000001111101000 | 0 | ******* | 0 | 1000 | 9 | 11110 |
| 9+ | 11111 | 1111010011110000 | 0 | ******* | 0 | 1000 | 9 | -1 |
| 10 | 11111 | 1111010011110000 | 0 | ******* | 0 | 32767 | 10 | -1 |
| 10+ | 11111 | 0000000000001110 | 0 | ******* | 0 | 32767 | 10 | -1 |
References: