2019-08-09 – Part 1 – The Pipe Dream
In 2019 there are any number of off-the-shelf CPU cores which can be used in FPGA projects, some imitating long-established CPUs such as x86, MC68000, Z80, MIPS, ARM, etc – and some more specifically targetted at the FPGA space, such as NIOS, Microblaze, ZPU, Moxie and suchlike. So why on earth would I consider creating a brand new one from scratch?
As always, because I wanted to learn something, and because even though there are so many existing options, there are still applications for which none of them is ideal.
My design goal is to create a CPU that’s reasonably small – not much bigger than ZPUFlex – so takes up somewhere in the region of 1500 logic elements, while being somewhat faster and offering better code density. Ideally I want something that can supplant the ZPU for control module applications and allow me to reduce the amount of block RAM I have to devote to the code.
A few years ago I ported three of the PACE arcade cores – namely Pacman, Pengo and Moon Patrol – to the Turbo Chameleon cartridge. Since then the original pacedev.net site seems to have gone down, but the source repo is now on github. Over the last few days, in odd moments I’ve cloned that repo, and added support for the new Chameleon V2 hardware – and now have the same three arcade cores working on the new hardware.
The cores can be downloaded here. Please note, these are straight ports of the cores to V2 hardware – do not attempt to flash them to an original Chameleon.
All three cores can be played using a PS/2 keyboard or a CDTV pad.
Coins can be added using the leftmost button on the Chameleon itself, the Run/Stop key on the C64, the 5 key on a PS/2 keyboard, or the Power button on a CDTV pad.
The Start button is mapped to the middle button on the Chameleon, the cursor up/down key on the C64, the 1 key on a PS/2 keyboard, or the Play button on a CDTV pad.
All three games can be played with a joystick, too – however Moon Patrol requires a second button.
Here’s an initial port of the Sega Megadrive / Genesis FGPA core to Chameleon V2 hardware.
Please note, this is specific to V2 hardware – do not attempt to flash this core to V1 hardware. There are no improvements to the existing V1 core, it’s merely a port of the existing version and doesn’t yet incorporate upstream improvements.
The on-screen display is toggled with F12, and gamepads can be emulated using either the CDTV control pad (port 1 only, buttons A and Start are mapped to volume down and volume up, respectively) or a PS/2 keyboard.
On the PS/2 keyboard, port 1’s controls are Cursor Up/Down/Left/Right, Right Ctrl, Right Alt, Right Shift and Enter.
Port 2’s controls are W, S, A, D, Left Ctrl, Left Alt, Left Shift and Caps Lock.
I found out recently that there is now a second version of the Turbo Chameleon 64 cartridge for the Commodore 64. The reason for this is, apparently, that the Cyclone III FPGA that was used in the original design has been superceded and is difficult to obtain at affordable prices. For this reason Individual Computers have redesigned the cartridge to use a Cyclone 10 FPGA instead. The model chosen is essentially the same thing in a different package, so porting cores would simply be a case of recompiling with the new device and pinout as the target – except they’ve also taken the opportunity to make small improvements to the design. For this reason it now takes a little bit of work to port existing cores to the V2 hardware.
I now have an initial build of the Minimig core for V2 hardware, which is available as before on the Minimig TC64 Snapshots page.
Edit: Since the V2 hardware is likely to attract newcomers to the Chameleon platform, I should explain what to do with the two files in the snapshop archive:
- The fampiga_tc64v2.rbf file is the core itself, and needs to be flashed into the Chameleon cartridge using the Chaco utility.
- The OSD_CA01.sys file is the firmware for the secondary CPU core that runs the menu system and disk emulation, and needs to be written to the root directory of an SD card. The card will also need to contain a Kickstart image, named kick.rom
Another point to bear in mind is that the core doesn’t yet attempt to translate the C64 keyboard to the Amiga – so far just the run/stop key is used to toggle the OSD – so you will need a PS/2 keyboard to use the core for anything that requires keyboard input.
Source is availabe, as before, on github.
Here’s an updated snapshot of the FPGA Megadrive / Genesis core for both Chameleon64 and MIST with the latest memory speed improvements. I’m hopeful that this will pretty much eliminate the sprite issues that have been present in previous releases:
Part 3: Tweaking the VDP implementation
In the second part of this series, I increased the throughput of the Megadrive core’s SDRAM controller, which gave nearly but not quite enough extra bandwidth to solve the sprite display problems. To improve things yet further I need to look at the VDP implementation itself…
Following the SDRAM-related improvements to the Megadrive / Genesis core that I’ve covered in my last couple of posts, here’s an updated snapshot for both the Chameleon and MIST boards:
While it’s still not perfect, the glitches should be much less noticeable, and hopefully there will no more missing platforms or missiles making games unplayable!
Part 2: Saving cycles
In the first part of this series I covered some basic tidy-ups to the code to make it easier to maintain. Now I’ll look at how we can speed things up.
The Megadrive/Genesis core has been plagued from the start with graphical issues that result from the SDRAM controller not responding quickly enough. Over the last few days I’ve finally put some time into understanding the SDRAM controller used by the project and spent some time improving its throughput.
I’ve just made available an updated version of the Sega Megadrive / Genesis core for the Turbo Chameleon 64. The only change is to the joystick handling – I’ve untangled the joystick directions and remapped the buttons slightly.
There’s still not a lot of point in using a traditional 1-button C64 joystick with this, but I’ve also fixed a bug in my previous attempt which prevented the CDTV infra-red controller from working. This does now work, and the buttons are mapped as follows:
Play / Pause => Megadrive Start
Volume Up => Megadrive A
A => Megadrive B
B => Megadrive C
I’ve mapped Volume UP to button A simply because it physically feels in the right place. The CDTV pad isn’t super-responsive, so trying to use for serious gameplay is an exercise in frustration, but it does work, and the controllers are readily available from AmigaKit.
The new core can be found here: fpgagen_chameleon_20180305.zip