Skip to content

compucat/Rhombus

Repository files navigation

Rhombus

an emulator for LFT's "Parallelogram" FPGA demo

In his "Parallelogram" demo, Linus Akesson, aka LFT, used an FPGA to implement a custom CPU, a GPU composed of a blitter and 10 pixel shaders, a VGA backend to support the GPU, and an FM synthesizer to create a demo the likes of which are few and far between. The demo itself is packed with the FPGA configuration, embedded in the 16 KB CPU cache. If we could get a copy of this ROM, I'd like to attempt to create a platform so those without FPGAs (such as myself) can run the demo and develop their own.

This is also partly one of my own personal challenges: to write an emulator. It probably won't be the easiest thing in the world, but who cares? I'm going to try it.

##Current state (v0.0.5):

  • CPU: almost all instructions implemented
  • SDL: image output works, still need to implement framebuffer copying from FPGA RAM.
  • Blitter: not started yet
  • Audio: not started yet
  • Manager: No timing control, graphics updates every 1,260,000 emulated CPU cycles (equivalent of 50 Hz with a 63 MHz CPU)

This emulator is written in plain old C. I'm starting out by writing a CPU interpreter core for LFT's custom CPU. The CPU runs at 63 MHz and accesses RAM through a 16 KB cache. I'm doing away with the cache to simplify things-hopefully this won't mess up any techniques that rely on (mis)use of the cache. The demo binary will be preloaded into RAM instead of the cache as it is in hardware, but LFT's hardware eventually writes the binary back into RAM anyway.

Video utilizes a modular API to allow for different graphics backends. My stock backend will use SDL 1.2 and be written to "just work" as simply and easily as possible rather than be terribly efficient or accurate.

The blitter and pixel shaders will use a software interpreter; I don't want to go too deep yet and write a recompiler for GLSL (supported in some versions of SDL).

I'll probably borrow someone else's FM synthesizer library to produce sound-it'll make things a bit easier.

The code is being developed in Orwell Dev-C++, which creates a proprietary project file and autogenerated Makefile. However, as the only library used (SDL 1.2) is multiplatform, it sbould be relatively portable.

File listing:

  • Makefile.win: autogenerated by Dev-C++
  • README.md: you're reading it right now
  • Rhombus.dev: Orwell Dev-C++ project file
  • Rhombus.exe: Windows 32-bit binary, compiled with TDM-GCC
  • Rhombus.layout: autogenerated by Dev-C++
  • cpu.c: Contains CPU interpreter core
  • cpu.o: generated by gcc
  • example.c: Dev-C++'s OpenGL example file, commented out
  • example.o: Take a wild guess. :)
  • main.c: Handles user I/O, cycles the CPU
  • main.o: Do I really have to explain this again?
  • notes.c: My personal annotations, commented out. Made as a ".c" file to allow it to show up in Dev-C++
  • notes.o: A blank file-why does gcc insist on outputting ".o" files for completely commented out source files?
  • rom.bin: A binary file containing a 16k ROM for the CPU. Currently contains whatever test code I happen to throw in there.
  • Probably some other files I haven't bothered to list.

(I really need to learn how to use gitignore!)

Note that LFT's demo is currently only available packed inside of his FPGA binary, effectively making it impossible to obtain. Eventually, unless LFT posts his source Verilog and demo on his website, I'll probably have to contact him for some more details. I'll want to test with custom test code for the majority of development, however, as his demo is compressed and prepended with decompression code-a nightmare to debug.

About

an emulator for LFT's "Parallelogram" FPGA demo

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published