A CHIP-8 console on an FPGA #FPGA #Gaming #TinyFPGA

CHIP-8 console on FPGA

Paweł Marczewski (GitHub user pwmarcz) posts the code for a CHIP-8 console on an FPGA. Specifically, it is a CHIP-8 game console emulator working on FPGA chip (TinyFPGA BX).

There was also some manual testing needed in order to get both the screen and the keypad to work. I wrote some simple programs to run on the chip, and corrected some misconceptions I have on CHIP-8 behavior (for instance, memory loads and stores include multiple registers, and sprite drawing wraps around). I was able to correct my Rust CHIP-8 emulator in the process; it’s funny how it was able to run many games despite getting these things completely wrong.

The CHIP-8 specification includes 16 one-byte registers (V0 to VF) and 20 two-byte words of stack. Initially I wanted them to be separate arrays, but it was really hard to coordinate access so that they get synthesized as RAM, so I decided to map them to memory instead (see the memory map described at the top of cpu.v).

I also mapped screen contents to system memory, so two different modules (CPU and screen) had to compete for memory access somehow. I decided to pause the CPU (i.e. not make it process the next instruction) whenever we want to read the screen contents.

See the whole project on GitHub and we look forward to more great projects on the TinyFPGA BX.