Close

FPGA core, component selection and joypad wiring

A project log for Spartan Mini FPGA handheld NES

A handheld FPGA based NES which utilizes the Spartan 6 FPGA by Xilinx.

jon-thomassonJon Thomasson 03/07/2018 at 17:080 Comments

I've been fortunate recently to have a few rainy days where I can further test my fpga board. I decided it would be fun to try and port an NES core to my board. I chose to try out this core built by Brian Bennett. This one seemed pretty well structured, and simple enough that I could hopefully add onto it in the future.

The first step for me was to update the constraint file of the project to map to the pins I had configured on the Spartan Mini. This was relatively straightforward. Next I plopped on my bread board shield and began to build up the connections needed to display the vga video. The way this core works is it uploads rom files from the computer to the fpga via the usb to uart link. After fiddling with the app for a bit, I was able to get games to load and display on the monitor. :slight_smile:

Next I thought it would be fun to swap out the VGA connection for a small TFT pixel clocked LCD I bought at Adafruit. I used the TFT Friend board Adafruit sells to connect the TFT display. The connection was fairly straightforward. The 8 bit rgb signal was wired into the most significant bits of the display, along with the hsync, vsync, data enable, and pixel clock pins. The video sync module was modified to allow for an 800x480 display area to accommodate the resolution of the TFT. To center the image in the display I'm just shifting the x value of the sync module by 80 pixels in order to compensate for the wider screen.

For the audio, I used an Adafruit PAM8302A amplifier board to run the sound output to an old pc speaker. The last piece I needed was the controller. The project was setup to use an original NES controller, which I didn't have. I decided to try and build my own controller on a breadboard and get it working that way. The actual build of the controller was pretty simple, I just arranged some tactile buttons with pull down resistors on a breadboard in a way that resembled an NES controller. 

The inner workings of an NES controller are fairly simple, basically the 8 buttons are hooked to a parallel to serial shift register which is mapped to the memory location $4016. Writing to that address latches out each individual button state. In my controller module i have 2 8 bit registers to hold the state of my buttons. Whenever $4016 is read the bits are shifted out one per clock cycle onto the data bus. To test the controller out I found a Controller Test rom online that was simple to use. It basically just lights up the buttons as they're pressed.

Here's the finished prototype:

Discussions