https://github.com/9oelm/risc-v-web-simulator
Yet another RISC-V Simulator on the web, running on Webassembly! https://riscv.vercel.app/
https://github.com/9oelm/risc-v-web-simulator
cpp javascript risc-v risc-v-emulator risc-v-simulator riscv-emulator riscv-simulator simulator webassembly
Last synced: 18 days ago
JSON representation
Yet another RISC-V Simulator on the web, running on Webassembly! https://riscv.vercel.app/
- Host: GitHub
- URL: https://github.com/9oelm/risc-v-web-simulator
- Owner: 9oelM
- License: mit
- Created: 2022-05-11T00:28:22.000Z (about 3 years ago)
- Default Branch: main
- Last Pushed: 2024-05-02T02:55:56.000Z (about 1 year ago)
- Last Synced: 2025-03-30T23:41:12.515Z (about 2 months ago)
- Topics: cpp, javascript, risc-v, risc-v-emulator, risc-v-simulator, riscv-emulator, riscv-simulator, simulator, webassembly
- Language: TypeScript
- Homepage: https://riscv.vercel.app/
- Size: 2.69 MB
- Stars: 33
- Watchers: 3
- Forks: 3
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# risc-v-web-simulator
Yet another RISC-V Simulator on the web, for fun. Based on [Kite](https://github.com/yonsei-icsl/kite), RISC-V architecture simulator I used for my computer architecture class ([EEE3530](https://icsl.yonsei.ac.kr/eee3530/)) at Yonsei University. Turned it into Webassembly to use it on web. Again, it's just for fun.... and probably education. Lol.
## Use it!
https://riscv.vercel.app/
## Instructions
Detailed instruction on how to use it is found at [the repository of Kite](https://github.com/yonsei-icsl/kite).
## Developing
### Modification of Kite's code
To enable communication with javascript from Webassembly binary, a few things have been changed in Kite's code:- Kite does not receive files as an input anymore. It receives `const char* program_code, const char* memory_state, const char* reg_state` as parameters and runs it. `const char*` is directly supplied from javascript.
- No more build flags (`-DDEBUG`, `-DDATA_FWD`, `-DBR_PRED`); They are also directly supplied from javascript as well.
- Kite throws error instead of `cerr` and `exit(1);`. For example:
```cpp
if(val != 1) {
throw std::logic_error("Cache Error: number of sets must be a power of two");
}
```
This allows javascript to catch an error and display the error message.
- [Emscripten](https://github.com/emscripten-core/emscripten) is used to compile C++ into Webassembly. More details in compile.sh.## Todo
- cleanup duplicate css styles (now just copied and pasted cuz im lazy)## References
- https://github.com/9oelM/emscripten-cplusplus-webpack-example
- https://stackoverflow.com/questions/21816960/how-to-pass-strings-between-c-and-javascript-via-emscripten
- https://stackoverflow.com/questions/46815205/how-to-pass-a-string-to-c-code-compiled-with-emscripten-for-webassembly
- https://stackoverflow.com/questions/59532379/how-to-call-javascript-method-from-c-with-parameters-using-em-js
- https://marcoselvatici.github.io/WASM_tutorial/