| alu | ||
| asm | ||
| cpu | ||
| mem | ||
| test1 | ||
| .gitignore | ||
| build.sh | ||
| LICENSE | ||
| Makefile | ||
| readme.md | ||
| tangprimer20k.cst | ||
| test.sh | ||
nandgame hardware implementation
This repository contains an hardware (verilog) implementation of the https://nandgame.com CPU.
License
This projects is licensed under the AGPLv3. For more details please see the LICENSE file.
Usage
Assembler
First you need to build the assembler, to do this run make asm. There is also a disassembler that you can build with make disasm. They're then accessible as ./build/nandgame_asm and ./build/nandgame_disasm respectively.
The basic invocation of the assembler is ./build/nandgame_asm test.asm.txt test.bytes. Use -h or --help to print out help for additional options.
The assembler is needed in order to transfrom human readable assembly code (like in the software part of nandgame) into an linear array of 16bit instructions for the CPU to be placed in ROM. For more information about the (slightly) extended syntax of the assembly language, see the documentation of the assembler itself in asm/readme.md.
FPGA Hardware
The hardware is written in verilog and was tested on the Tang Primer 20k. To build it you'll need to:
-
Install manta, a hardware compontent used for debugging the CPU.
- Create a venv:
python3 -m venv venv - Activate the venv
source venv/bin/activate - Install manta
pip install --upgrade git+https://github.com/fischermoseley/manta.git
- Create a venv:
-
Run
./build.shto build the hardware & upload it to your tang primer 20k. If currently not connected, you can upload it later withopenFPGALoader -b tangprimer20k ./build/cpu.fs. -
Run (with activated venv / manta installed) the "debugger", that also uploads your assembled program to the CPU:
python ./test1/debug.py ./test.bytes. This also requies the disassembler to be builded so it can decode the current instruction the CPU wants to execute.
The CPU is a stepped one, so you'll need to manually pulse the clock by pressing the button labeled "S1" on your board.