OnionSoC v2.2: My Open-Source RISC-V SoC, Tested on FPGA
I have been building a RISC-V system-on-chip from scratch for a while now. Today OnionSoC v2.2 is merged to main and the whole thing is public under Apache-2.0:
That means the RTL, the Python golden model, the testbenches, the firmware, the FPGA build scripts, the board logs and the reports. Nothing is held back. You can clone it, simulate it, put it on an Arty board and check every number in this post yourself.
This post covers what is new in v2.2, how it performs on real hardware, how it compares with other cores (open source and commercial), and where it is still weak.
What is OnionSoC?
OnionSoC is a microcontroller-class SoC built around my own RV32IM core. The core is a classic 5-stage pipeline with forwarding, branch prediction, an instruction cache and a data cache. Around it sit an AXI-Lite interconnect and a set of peripherals: UART, SPI, I2C, GPIO, PWM, timer, DMA, watchdog, JTAG debug, and a fixed-point MAC accelerator. The firmware is plain C.
docs/figures/v2.2/soc_top.svg in the repo.The flow is the same for every block:
- Write a Python golden model first, so I know exactly what the hardware should do.
- Write the RTL by hand in SystemVerilog. No HLS, no Chisel, no generators.
- Verify against the model with cocotb, and run the official riscv-tests suite on the core.
Every module is documented with why it exists, the maths behind it and the design reasoning. Open-source SoCs were only used as references and benchmarks, never as code.
What is new in OnionSoC v2.2?
v2.1 was a fast, well-tested core. v2.2 is about making it behave like a real microcontroller you could ship firmware on.
User mode and memory protection (PMP)
The core now has a privileged machine mode and an unprivileged user mode, with a memory protection unit (RISC-V PMP, 8 regions). User code that touches memory it does not own traps instead of corrupting the system. The riscv-tests suite passes 159 of 159 in both machine and user mode, with the trace matching the instruction-set simulator.
docs/figures/v2.2/pmp.svg.A priority interrupt controller
The old simple interrupt block is replaced by a CLIC-style controller with priority levels and vectored handling, so an urgent interrupt can preempt a less urgent one. On the board, a vectored interrupt reaches its handler in 12 cycles, and 10 through the common entry.
Sleep and stop modes with wake-up
The SoC can gate clocks to idle parts and stop the core, then wake on an interrupt. Wake-up takes 6 cycles from sleep and 5 from stop on the board. The SoC drives an “awake” output so a board LED can show the state.
Custom SIMD and DSP instructions
I added a set of packed integer instructions (37 of them, based on a draft of the RISC-V P extension) for 8-bit and 16-bit data. This is where the biggest wins are:
- int8 dot products: 3.4x to 6.3x faster than scalar code
- a small neural-network layer: 5.5x faster
- a Q15 FIR filter: 4x faster
- every result is bit-exact against the scalar reference, checked on the board, not only in simulation.
simdbench_71m4.log. Longer vectors gain more because the fixed loop overhead is spread over more elements.Why does a dot product get faster with SIMD? A scalar loop does one multiply-accumulate per element. With four int8 lanes in one 32-bit register, one instruction does four of them, so the ideal ceiling is 4x for the arithmetic. The measured 6.3x on 256 elements beats that because the packed loop also needs a quarter of the loads, a quarter of the loop branches and no separate sign-extension per byte. The 64-element case lands at 3.4x because setup and the final reduction take a bigger share of a short loop.
docs/figures/v2.2/simd.svg.How does OnionSoC v2.2 perform on real hardware?
I do not own an FPGA. All board testing was done on an Arty A7-35T (Xilinx Artix-7) through fpgas.online, a free remote FPGA service, with the board watched over a webcam while the logs came back over UART.
| Metric | v2.1 | v2.2 |
|---|---|---|
| Clock on Arty A7-35T | 62.5 MHz | 71.4 MHz |
| CoreMark | 212 | 240 (+13%) |
| CoreMark/MHz | 3.39 | 3.37 |
| CPI on CoreMark | 1.11 | 1.12 |
| v1 demo firmware | 9/10 | 10/10 |
| v2 demo firmware | 15/18 | 16/18 |
CoreMark is a score per second, so it is the per-clock figure times the clock. You can check the headline number from the two values in the table:
The +13% comes from the higher clock, not from a faster core. Per clock, v2.2 is very slightly slower than v2.1 (, a 0.7% drop). The cause is a registered grant in the bus crossbar that I added to help timing; it costs one cycle per bus transaction and buys more MHz. I would rather report that than round it away.
The two v2 demo failures are one real gap: that test talks to an I2C EEPROM, and the remote board does not have one fitted. Everything else passes. The board runs also take exactly the cycle counts the Verilator model predicts: 11,878,431 cycles for 40 CoreMark iterations, in simulation and on the board.
I posted the first board bring-up (v2.1, 212 CoreMark at 62.5 MHz) as a thread on X, with the webcam video:
I built a RISC-V SoC from scratch, and it now runs on a real FPGA.
Shounak Das (@TheScienceLoop) 2 December 2026
OnionSoC: 212 CoreMark at 62.5 MHz on an Artix-7, CPI 1.11, timing met. Open source, Apache-2.0
One side note, to be complete: a build without the v2.2 features closed timing at 80 MHz and scored 269 CoreMark. So the new features cost about 9 MHz of clock (8.6 MHz exactly). That is the price of protection checks and wider datapaths, and I think it is worth paying, but it is there.
How does it compare with other RISC-V and Arm cores?
CoreMark/MHz is the fairest single number for comparing cores at different clock speeds, because it removes the clock and the process from the picture. It does not capture area, power or features, so read the table with that in mind.
| Core | Type | CoreMark/MHz |
|---|---|---|
| Arm Cortex-M33 | commercial | ~4.0 |
| Andes N22 | commercial | ~3.95 |
| Hazard3 (RP2350) | open source | 3.8 to 4.15 |
| Arm Cortex-M4 | commercial | ~3.42 |
| OnionSoC v2.2 | open source | 3.37 |
| Arm Cortex-M3 | commercial | ~3.34 |
| Ibex (max perf config) | open source | 3.13 |
| CV32E40P | open source | 3.11 |
| VexRiscv | open source | 2.57 |
| Arm Cortex-M0+ | commercial | ~2.4 |
| PicoRV32 | open source | ~0.5 |
Commercial figures are the vendors’ published numbers; open-source figures are from each project’s own reports. SiFive’s E20 and E31 class cores also land below OnionSoC per clock.
What I take from this:
- Among open-source cores, only Hazard3 is clearly ahead per clock. OnionSoC beats Ibex, CV32E40P, VexRiscv and PicoRV32. Those are mature, well-engineered projects, so I am happy with that, but it is per-clock only.
- Against commercial parts, OnionSoC sits around Cortex-M3 and close to Cortex-M4, and ahead of Cortex-M0+. It is behind Cortex-M33 and Andes N22.
- Feature-wise, v2.2 closes the gap that bothered me most in v2.1: no user mode and no memory protection. Those are now in.
Where is OnionSoC still weak?
Being honest about this matters more to me than the table above.
- It is bigger than the small cores. Ibex is roughly 1.7x smaller. The v2.2 SoC uses about 17k LUTs on the Artix-7, around 82% of the 35T part. That is not small.
- Fmax is low for Artix-7. 71.4 MHz is fine for a microcontroller, but good designs on this FPGA family run faster. There are known timing paths I still need to cut.
- It is FPGA, not silicon. The v2.1 core has been taken through a full RTL-to-GDS flow in the open Sky130 process, but nothing has been fabricated, and v2.2 has not been laid out yet.
- No compressed instructions. Without the RISC-V C extension, code is roughly 25 to 30% bigger than on most competing cores. That matters on a microcontroller with small memory.
- Some of it rests on draft specs. The interrupt controller and the SIMD instructions follow RISC-V drafts that are not ratified yet. If the specs change, the compiler intrinsics will need to follow.
The 82% figure is easy to check. The Artix-7 35T has 20,800 LUTs, and the v2.2 build uses 17,123 of them:
That leaves under 3,700 LUTs for anything else you might want to add on this part. The repo notes where some could come back: the four 9×9 SIMD lane multipliers are built from LUTs today, and moving them into the DSP48 blocks (6 of 90 used) would free several hundred.
Built with no hardware budget
The whole project was built with zero hardware cost. I do not own an FPGA, and my laptop has 8 GB of RAM, which is not enough for Vivado or a full physical-design run. So:
- Simulation, Vivado synthesis and place-and-route, and the OpenLane RTL-to-GDS runs all happened on cloud servers paid for with free credits.
- Board testing happened on the free remote Arty, with a webcam pointed at the LEDs.
If you are a student and think you need a lab and an expensive board to do serious digital design, you do not. You need patience and a good test plan. If you are starting from the basics, the posts on logic gates and truth tables, UART baud-rate error, I2C pull-up resistor values and how PWM works cover the ideas behind several of the blocks in Figure 1.
How to try OnionSoC
The repository has everything:
rtl/for the SoC and core,model/for the golden model,tb/for the cocotb testssw/for firmware, including CoreMark and the SIMD benchmarkfpga/for the Vivado build and the raw board logs behind every number abovedocs/for per-module design notes, the generation-by-generation comparison and the reports
Issues and pull requests are welcome, especially from anyone who wants to run it on a different board or push the Fmax up.
What comes next
The next big step is v3: a ground-up rewrite of the core, with compressed instructions, a better timing structure, and one genuinely new idea rather than another catch-up feature. Before that, I want v2.2 taken through the Sky130 flow the same way v2.1 was.
If you build something with it, or find a bug, I would like to hear about it.
Repo: github.com/oniondas/onion-soc · License: Apache-2.0
Frequently asked questions
What is OnionSoC?
OnionSoC is an open-source, microcontroller-class system-on-chip built around a hand-written RV32IM RISC-V core with a 5-stage pipeline, branch prediction and instruction and data caches. Around it sit an AXI interconnect, UART, SPI, I2C, GPIO, PWM, timer, DMA, watchdog, JTAG debug and a fixed-point MAC accelerator. It is released under Apache-2.0.
How fast is OnionSoC v2.2?
On an Arty A7-35T board at 71.4 MHz it scores 240 CoreMark, which is 3.37 CoreMark per MHz. That is 13% more than v2.1 on the same board, and the gain comes from the higher clock, not from a faster core.
How does OnionSoC compare with Arm Cortex-M cores?
Per clock, OnionSoC v2.2 (3.37 CoreMark/MHz) sits around the Cortex-M3 (about 3.34) and a little below the Cortex-M4 (about 3.42 to 3.54 depending on the source). It is ahead of the Cortex-M0+ (about 2.4) and behind the Cortex-M33 and Andes N22 (about 4).
Can I run OnionSoC without owning an FPGA board?
Yes. The whole SoC simulates in Verilator and cocotb, and all board testing for v2.2 was done on a free remote Arty A7-35T through fpgas.online, with the board watched over a webcam and the logs returned over UART.
Does OnionSoC support compressed RISC-V instructions?
Not yet. v2.2 has no C extension, so its code is roughly 25 to 30% larger than on cores that run compressed code. Compressed instructions are planned for v3.
Sources
- OnionSoC repository, v2.2 results and board logs: github.com/oniondas/onion-soc (
docs/v2.2/RESULTS.md,fpga/vivado/results/v2.2/board_71mhz/) - EEMBC CoreMark benchmark: eembc.org/coremark
- Arm Cortex-M comparison table (2022): documentation-service.arm.com
- CoreMark/MHz table for Cortex-M cores: WikiChip
- Andes N22 (3.95 CoreMark/MHz): CNX Software
- Hazard3: github.com/Wren6991/Hazard3
- Ibex: github.com/lowRISC/ibex
- CV32E40P CoreMark (Gallmann et al., CARRV 2021): carrv.github.io
- VexRiscv: github.com/SpinalHDL/VexRiscv
- PicoRV32: github.com/YosysHQ/picorv32
- riscv-tests: github.com/riscv-software-src/riscv-tests
- Remote FPGA boards: fpgas.online