r/FPGA • FPGA Hobbyist • Jul 27 '26

Something more than a basic RISC-V

Enable HLS to view with audio, or disable this notification

There have been a few posts recently asking for ideas of what could be the next step after building a basic pipelined RISC-V. So here is what I've been playing with for the past year or so - to give an idea of what is possible at the hobbyist level.

This system has

  • Softcore CPU - loosely based on RISC-V, but my own ISA.
    • Runs at 125Mhz on a CycloneV FPGA (DE1-SOC but not using the HPS side)
    • 4-stage pipeline, plus scoreboard to track inflight instructions and avoid hazards
    • Integer and floating point ops
    • DCache and ICache, plus region based memory protection
    • My own programming language and compiler to target it
  • SDRAM controller connected to 64Mb of external memory
  • DMA based VGA system
    • 640*480 display in 8 bit indexed color
  • A hardware blitter (DMA based)
    • Can do draw lines / rectangles / and image copy
    • Supports X/Y scaling (12 bit fixed point precision) and transparency
  • Amiga-style Copper, used to change color palette synced to scanlines
  • 8 channel audio (8 bit samples at 44Khz)
    • DSP to do frequency scaling, interpolation, volume and mixing
  • PS2 mouse / keyboard
  • UART (used to load game assets from host PC)

For the software running on it, I've used the game assets (sprites, sounds and track layout) from ReAssembler's port of Outrun to the Amiga, and used them in a fairly simple track racing game.

Sorry for the wobbly video - I was holding phone in one hand whilst playing the game in the other.

FalconCpu/falcon5

EDIT: No AI was used in writing the rtl or the game code (other than autocomplete in vscode). Some AI was used for testcase generation, brainstorming ideas, and for converting the file formats of the game assets.

419 Upvotes

24 comments sorted by

18

u/dettus_Xx_ Jul 28 '26

What? No question about your CV? 😄

Love the game!!!!

18

u/Falcon731 FPGA Hobbyist Jul 28 '26

No question about your CV?

😄
Definitely one of the perks of being retired is never having to worry about a CV anymore.

7

u/HuyenHuyen33 Jul 27 '26

Did you run OS on it before running game (software) ?

14

u/Falcon731 FPGA Hobbyist Jul 27 '26

Not really. I've been developing an OS for the hardware, and bits of the OS code do get called from the game (eg the routines to load data over the UART), but as it stands the game is running on bare metal.

10

u/IQueryVisiC Jul 27 '26

Wasn’t didn’t every blitter access memory directly ( through Agnes)?

5

u/Falcon731 FPGA Hobbyist Jul 27 '26

On the original amiga yes.

For my version I don't have an Address Generator block per-se, instead each of the bus masters generate their own address requests, and arbitration for SDRAM access is done via an AXI style bus.

4

u/dmpk2k Jul 28 '26

I dig it. You even made your own language.

Where does your ISA deviate from RISC-V? What was the most painful part of development? Since you're pushing pixels and samples, any thoughts about vector processing? And roughly how many hours a week did you spend on this?

4

u/Falcon731 FPGA Hobbyist Jul 28 '26

I started sketching out the ISA quite a few years ago, before I had even heard of RISC-V. I got most of my inspiration from ARM and MIPS, but did things how it made sense to me. Built an emulator for it, and coded up a few things, but never really took it very far. It was only later when I read up on RISC-V, I Found I'd converged to more or less exactly the same set of instructions, just with totally different encodings and a bit different assembly language syntax.

Then in 2021 I took semi-retirement from work, and wanted a hobby to keep my mind active. So the idea of brushing up my digital design skills, and having a go at designing a computer from scratch.

Initially I was going to try to build it on a breadboard. But then as I started getting into FPGA's, I thought I'd go that way instead.

In the end building the CPU itself was pretty straightforward. I found getting the memory system and caches far harder. And I've spent way more time writing the compiler than the rtl.

As for vector instructions, I've toyed with the idea, but never got very far. Trying to get a compiler to auto vectorize code seems like a very major task that I really don't have much motivation for. So if I did add vector instructions they would probably only be usable from assembly language (Or maybe I'd just add a Vec3d type data type into the compiler).

What I'm planning on doing instead is add a dedicated 3d pipeline to the hardware. Implement the coordinate transform, Lighting, clipping, perspective divide and triangle setup in RTL.

2

u/tudor088 Jul 28 '26

how many bits is the cpu?

4

u/Falcon731 FPGA Hobbyist Jul 28 '26

32 bit.

1

u/moviefotodude Jul 28 '26

Very nice work. Open source?

2

u/Falcon731 FPGA Hobbyist Jul 29 '26

Yep - the github's in the post. The game code is in falconOs/outrun

The bit that is missing is the code to extract the assets from the SEGA rom's.

1

u/DimensionMaximum988 Jul 29 '26

How many hours did it took you to build it from scratch?

1

u/Falcon731 FPGA Hobbyist Jul 29 '26

Haven't got a clue ;-)

I've been working on this on and off since 2021.

The game itself took a couple of months - but nowhere near full time.

1

u/DimensionMaximum988 Jul 30 '26

Wow, that's an amazing level of dedication.

1

u/Falcon731 FPGA Hobbyist Jul 30 '26

By far the hardest part was writing a compiler to target my CPU. That been more than half the total time.

1

u/DimensionMaximum988 Jul 31 '26

If one aims to do something like this, what resources should one follow?

1

u/Falcon731 FPGA Hobbyist Jul 31 '26

Just make it up as you go along.

The whole thing is a learning excercise.

1

u/murixum Jul 29 '26

Impressive. Very nice. Let's see Paul Allen's FPGA.

1

u/Myndale Jul 29 '26

I can hear the music in my head when I watch this.

1

u/Mean_Assistance_5498 Aug 16 '26

This is a lot like what I'm doing...only you are much farther along and actually have a game running on it! I'd love to see what else is possible on your platform.