A C++20/CMake command-line emulator for statically linked, bare-metal RV32I ELF programs.
cmake -S . -B build -DCMAKE_BUILD_TYPE=Release
cmake --build build -j
ctest --test-dir build --output-on-failure
./build/riscv-emu path/to/program.elf --traceBuild the assembly examples (requires a RISC-V cross toolchain, optional):
sh examples/build.sh
./build/riscv-emu examples/build/hello.elfriscv-emu <elf> [--max-instructions N] [--ram-size SIZE] [--trace]
--max-instructions N(-n): stop after N instructions (default 10000000).--ram-size SIZE: RAM capacity; decimal,0x-hex,K/M/Gsuffixes (default 16M).--trace: printPC: raw disassemblyper instruction to stdout.- UART bytes are printed to stdout; final statistics always print.
- Exit status:
0for--help;1for load failure or any halt/trap (includingECALL/EBREAK, which stop execution by design);2for instruction-limit exit.
- Static ELF32 little-endian RISC-V (
ET_EXEC,EM_RISCV),PT_LOADsegments mapped atp_paddrwith BSS zero-fill; entry = ELF entry point. - RAM at
0x80000000(default 16 MiB, configurable); UART TX byte at0x10000000. - Byte store to UART transmits; byte load returns 0; wider MMIO traps.
ECALL/EBREAKhalt with a reported trap (no guest handler yet).- Single-threaded, no CSRs, no floating-point/atomics/compressed/M-extension.
See docs/ for the ISA list, memory map, CLI details, limitations, and
compatibility matrix.