In order to produce a menu system for the tiny-fpga-game-soc, I have produced a version of PicoSoC for the TinyFPGA BX that runs code from BRAMs and does not use the flash memory.
This should be usable for more than just the game menu application.
The picorv32 Risc-V CPU uses 4 BRAMs for its registers etc., leaving 28 BRAMs (14kB) for use for code, data, heap and stack.
Like tiny-fpga-game-soc, the C code for the SoC is in Arduino-style libraries, and there are currently libraries for:
- Direct access to the ili9341 LCD
- Read and write the SD card on the back of the LCD
- Read and write access to the flash memory
- Buttons via GPIO pins
- Uart for debugging
- i2c access to Nintendo controllers (including Nunchuks)
- Millisecond delay function
The audio and video libraries used by the Game SoC will not work on this SoC because they need BRAMs or timer interrupts, but a simpler audio system would be possible.
Access to the LCD screen is directly from code sending commands and data using the ili9341 protocol, using the 8-bit parallel 8080 interface. Currently I use the default small font from the Adafruit GFX library to write character data to the screen, but graphics is also possible. I implemented a fast flood-fill mode for clearing the screen, which was otherwise rather slow.
This SoC will run on the PCB that @Fabien has built, but SD card access will not work on that as it does not include the wiring for the SD card.
The main purpose of this Soc was to produce a menu system for the Game SoC.
The menu application does the following:
- Reads the root directory of a FAT32 SD card and displays the contents as a menu on the LCD screen
- Each file in the root directory is assumed to be a game (or other) application with the hardware.bin and firmware.bin files for the application concatenated.
- The Select button is used to select a game, and start is pressed to start it
- The file is then read from the SD card and the hardware.bin and firmware.bin portions written to the TinyFPGA BX flash memory
- A warm boot is then done
This starts the game application.
Unfortunately after running the game, the menu has been wiped from the flash memory and replaced with the game. To leave the menu in flash, I will need to reconfigure the TinyFPGA BX to support 3 configurations rather than the current 2 in its multi-boot configuration. I will need @lukevalenty’s help with that.
But as I said, the RAM-only SoC is usable for more than just this game menu. It runs much faster than versions of PicoSoC that use flash memory.
I have not quite finished the game menu yet, but all the features of the SoC are working.