4 ms·
Writing a Tiny RISC-V Emulator [video]
- sylware 4y agoMister ffmpeg/tinycc/qemu/(much more) did just that: https://bellard.org https://bellard.org
- fwsgonzo 4y agoI definitely recommend people to consider the base ISA of RISC-V if they want to try to implement a CPU or even full-system emulation. I understand that implementing a GameBoy emulator might be more attractive because you are working towards something graphical that you can eventually play, and that's what I did first. It was a fun project! You can also get something similar with RISC-V, eg. Doom (SDL example: https://github.com/fwsGonzo/libriscv/tree/master/examples/doom https://github.com/fwsGonzo/libriscv/tree/master/examples/do...) The road to fully working DOOM will probably be shorter because you will only have to implement RV32I and then an ELF loader. The rest is handled through SDL2 outside of the emulator, and I/O is handled through system calls from Doom running as a guest inside it. Note that DOOM does not support 64-bit. Otherwise, if you want to start out with emulating something smaller or something from your childhood check out r/emudev on reddit. A very helpful and nice community there.
- HideousKojima 4y agoCHIP-8 is another easy target for beginners. You're technically implementing an interpreter rather than writing an emulator, but 99% of the principles are the same.
- 1vuio0pswjnm7 4y agoAt 4:22, he says watching buildroot run "it really feels like you are gaining a couple of IQ every single time." LOL. Over many years I spent too much time staring at NetBSD kernels and other binaries building under build.sh. I think I am generally dumber as a result. Perhaps one becomes a little more knowledgeable about UNIX but certainly not more knowledgeable about life. There is something relaxing about watching UNIX compile though. I can relate to his complaint about bulding python and cmake. I just compiled cmake yesterday. Wow it is slow. I could build multiple BSD kernels in the time it takes to compile cmake. At the end, he makes a comment about how the boot console is really fast but once it is disabled the system is much slower. He wants to stay in the boot console but does not know how. This is easy on NetBSD. Even though terminal emulators for X11 can be really fast and allow for cut and paste, I prefer VGA textmode. Here is another tiny emulator with a RISC-V buildroot port. I like this one because it works with musl. https://www.bellard.org/tinyemu/ https://www.bellard.org/tinyemu/ https://www.bellard.org/tinyemu/buildroot.html https://www.bellard.org/tinyemu/buildroot.html
- 1vuio0pswjnm7 4y agoTBH, I think there are multiple RISC-V emulators that support musl.