Petter Reinholdtsen

Entries from February 2026.

Free software toolchain for the simplest RISC-V CPU in a small FPGA?
27th February 2026

On Wednesday I had the pleasure of attending a presentation organized by the Norwegian Unix Users Group on implementing RISC-V using a small FPGA. This project is the result of a university teacher wanting to teach students assembly programming using a real instruction set, while still providing a simple and transparent CPU environment. The CPU in question implements the smallest set of opcodes needed to still call the CPU a RISC-V CPU, the RV32I base set. The author and presenter, Kristoffer Robin Stokke, demonstrated how to build both the FPGA setup and a small startup code providing a "Hello World" message over both serial port and a small LCD display. The FPGA is programmed using VHDL, the entire source code is available from github, but unfortunately the target FPGA setup is compiled using the proprietary tool Quartus. It is such a pity that such a cool little piece of free software should be chained down by non-free software, so my friend Jon Nordby set out to see if we can liberate this small RISC-V CPU. After all, it would be unforgivable sin to force students to use non-free software to study at the University of Oslo.

The VHDL code for the CPU instructions itself is only 1138 lines, if I am to believe wc -l lib/riscv_common/* lib/rv32i/*. On the small FPGA used during the talk, the entire CPU, ROM, display and serial port driver only used up half the capacity. These days, there exists a free software toolchain for FPGA programming not only in Verilog but also in VHDL, and we hope the support in yosys, ghdl, and yosys-plugin-ghdl (sadly and strangely enough, removed from Debian unstable) is complete enough to at least build this small and simple project with some minor portability fixes. Or perhaps there are other approaches that work better? The first patches are already floating on github, to make the VHDL code more portable and to test out the build. If you are interested in running your own little RISC-V CPU on a FPGA chip, please get in touch.

At the moment we sadly have hit a GHDL bug, which we do not quite know how to work around or fix:

******************** GHDL Bug occurred ***************************
Please report this bug on https://github.com/ghdl/ghdl/issues
GHDL release: 5.0.1 (Debian 5.0.1+dfsg-1+b1) [Dunoon edition]
Compiled with unknown compiler version
Target: x86_64-linux-gnu
/scratch/pere/src/fpga/memstick-fpga-riscv-upstream/
Command line:

Exception CONSTRAINT_ERROR raised
Exception information:
raised CONSTRAINT_ERROR : synth-vhdl_expr.adb:1763 discriminant check failed
******************************************************************

Thus more work is needed. For me, this simple project is the first stepping stone for a larger dream I have of converting the MESA machine controller system to build its firmware using a free software toolchain. I just need to learn more FPGA programming first. :)

As usual, if you use Bitcoin and want to show your support of my activities, please send Bitcoin donations to my address 15oWEoG9dUPovwmUL9KWAnYRtNJEkP1u1b.

Tags: english, nuug, robot.
Lanseringsfest lørdag 14. februar for «Ada og Zangemann - En fortelling om programvare, rullebrett og bringebæris»
10th February 2026

I samarbeid med foreningen NUUG og Free Software Foundation Europe lanseres min siste bok «Ada og Zangemann - En fortelling om programvare, rullebrett og bringebæris» med en slippfest i Oslo førstkommende lørdag. NUUG-arrangementet er del av FSFEs «I Love Free Software Day» og finner sted på Cafe Amsterdam klokken 14:00 førstkommende lørdag 2026-02-14, der en kan møte i hvert fall noen av oversetterne og ta en titt på fysiske eksemplar av boken.

Digital selvråderett blir i disse dager viktigere og viktigere for flere og flere, og boken gir en fin introduksjon til hvordan kontroll over eget utstyr er viktig slik at selv barn og besteforeldre kan forstå det. Ses vi på lørdag?

Jeg tenker ta med mine eksemplarer av de øvrige bøkene jeg har gitt ut, hvis noen vil ta en titt på disse, men har desverre ingen eksemplarer til salgs.

Som vanlig, hvis du bruker Bitcoin og ønsker å vise din støtte til det jeg driver med, setter jeg pris på om du sender Bitcoin-donasjoner til min adresse 15oWEoG9dUPovwmUL9KWAnYRtNJEkP1u1b. Merk, betaling med bitcoin er ikke anonymt. :)

Tags: freeculture, norsk.

RSS Feed

Created by Chronicle v4.6