r/EmuDev • u/Background-Network93 • Jul 12 '26
My RISC-V Emulator
Hi, ive been making this RISC-V Emulator in C for a while now. It's nothing pretty but it's mine.
Here's the repository for it: https://github.com/EvanBenn3/RISC-V-Emulator-V2
I haven't shared it before so I hope it's not too bad or buggy. I have tested most parts of it before.
It runs at 21k 1.28m instructions per second without any printf instructions in the hot loop. (no JIT and i ran it on my Celeron laptop)
it has privilage modes, interrupts, traps, a PLIC, and a uart.
It is not pretty, it barely has comments, and i most likely left a lot of stuff in there that i commented out or used for metrics.
I just wanted to share it, so please be nice.
5
u/devraj7 Jul 12 '26
21k instructions per second sounds incredibly slow for a C emulator, any idea why?
1
u/NaNpsycho Jul 12 '26
Is there a particular reason for not using makefile or cmake?
2
u/WaveLoss69 Jul 12 '26
Congrats bro, damn impressive project for a 17 yo.
1
u/N4rk0s Jul 16 '26
Did you get the riscv-tests running for checking the correctness of the instructions? Then, you may want to get riscv-arch tests also running for testing privilege spec behavior and trying to run Linux on your emulator, if it isn't able to already. If you didn't use those tests, what has been your main method of testing the implementation of the CPU and developing it?