A hardware implementation of the nandgame cpu and a assembler/disassembler for writing nandgame assembly
Find a file
2024-12-18 01:58:08 +01:00
alu Adding license header 2024-09-02 11:40:21 +02:00
asm asm: add "asm block" macro parameter type to give an macro entire blocks of assembly 2024-12-18 01:58:08 +01:00
cpu Adding license header 2024-09-02 11:40:21 +02:00
mem Adding license header 2024-09-02 11:40:21 +02:00
test1 Adding license header 2024-09-02 11:40:21 +02:00
.gitignore Initial commit 2024-09-01 09:18:29 +02:00
build.sh Building manta.v in build.sh 2024-09-12 18:11:19 +02:00
LICENSE Add LICENSE file 2024-09-12 17:54:37 +02:00
Makefile Adding license header 2024-09-02 11:40:21 +02:00
readme.md Add readme's 2024-09-12 18:30:26 +02:00
tangprimer20k.cst Initial commit 2024-09-01 09:18:29 +02:00
test.sh Adding license header 2024-09-02 11:40:21 +02:00

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
  • Run ./build.sh to build the hardware & upload it to your tang primer 20k. If currently not connected, you can upload it later with openFPGALoader -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.