5 ms·
A tiny C header-only RISC-V emulator
- kreelman 4y agoFar out. This is amazing. The links included... Linux in a pixel shader ?!?! What? Very cool.
- squarefoot 4y agoCNLohr is a well known youtuber among electronics enthusiasts; take a look at his channel and you won't be disappointed. https://www.youtube.com/@CNLohr/videos https://www.youtube.com/@CNLohr/videos
- raible 4y agoThis is an awesome project. In the video you mention that you might drop it... please don't!
- mlindner 4y agoJust curious but as someone who doesn't understand the awesomeness, can you explain what it's useful for? I can't think of what I might use this for.
- sitkack 4y agoThis is a full system simulator with an emulated RISC-V CPU in under a 1000 lines of clean C, in two files, so you can include it basically any program (STB style FTW).
- jononor 4y agoOne could use it to test (embedded) code targetting RISC-V, without needing to use hardware. Unit tests is the easiest, since they preferably do no I/O. But also integration test by providing an I/O implementation (using a Hardware Abstraction Layer), and driving I/O from the tests. Such testing is easier to do when one has C access to the simulator, and not having to implement the I/O via some virtual device shuffling bytes etc. And since its just a C header/library, on can just distribute, include and build the simulator alone with the project/tests. As opposed to relying on the user having qemu (or similar) installed. I will consider using it for emlearn (a Machine Learning Library for microcontrollers).
- stevefan1999 4y agoReminds me of 8086tiny [1] [1]: https://github.com/alblue/8086tiny https://github.com/alblue/8086tiny
- justahuman74 4y agoWhat happens on a 'nommu' linux system when a program tries to access memory that it should not?
- cnlohr 4y agoDepends. If it's some random spot in the memory space, it gets an access violation and the kernel kills it. Otherwise, if it's still a "valid" memory address, it's allowed to access it. Even if it's say, within kernel space.
- dvh 4y agoPosts like these get 8 comments on hn but relationships posts get 100s. It it because of the bikeshedding or are hn users just obsessed with relationships?
- stevewatson301 4y agoThese kinds of posts have a very high bar to provide a thoughtful comment on. I'd suggest checking lobste.rs if you're into only CS/programming stuff.
- saagarjha 4y agoHacker News commenters are drawn, like moths to a flame, to topics they think they can understand.
- bippingchip 4y agoThis is impressive! I’ll admit: My first reaction was: cool but why not just use qemu to get a more full fledged system, add rv64 etc? But the readme explains it very well, I admire the dedication and consistency it takes to stick to rv32 no MMU only to be able yo fit it into very minimal environments in the end. (I myself tend to be much more prone to allowing feature creep :)
- sylware 4y agoGood. I would have like some 64bits though. And Mr. Bellard did the same thing (but not packaged is a nice header): https://bellard.org https://bellard.org
- solarkraft 4y agoCNLohr does a lot of super cool stuff. I highly recommend checking out more of his stuff. How I think of him is similar to how people talk about Fabrice Bellard: He keeps pumping out reliably cool stuff in pretty different areas. His streams are cool too.
- aew4ytasghe5 4y agoThis video goes along with the github link: Writing a Really Tiny RISC-V Emulator by CNLohr https://www.youtube.com/watch?v=YT5vB3UqU_E https://www.youtube.com/watch?v=YT5vB3UqU_E